@@ -27,12 +27,14 @@ import (
2727 "k8s.io/klog/v2"
2828
2929 "github.com/kube-bind/kube-bind/pkg/konnector/controllers/cluster/serviceexport/isolation"
30+ konnectortypes "github.com/kube-bind/kube-bind/pkg/konnector/types"
3031)
3132
3233type reconciler struct {
3334 isolationStrategy isolation.Strategy
3435
3536 getConsumerObject func (ns , name string ) (* unstructured.Unstructured , error )
37+ updateConsumerObject func (ctx context.Context , obj * unstructured.Unstructured ) (* unstructured.Unstructured , error )
3638 updateConsumerObjectStatus func (ctx context.Context , obj * unstructured.Unstructured ) (* unstructured.Unstructured , error )
3739
3840 deleteProviderObject func (ctx context.Context , ns , name string ) error
@@ -77,6 +79,20 @@ func (r *reconciler) reconcile(ctx context.Context, obj *unstructured.Unstructur
7779 return err
7880 }
7981
82+ // Set provider source metadata annotations on the consumer object so
83+ // the consumer side can trace where the object came from. This requires
84+ // a full object update because UpdateStatus does not persist metadata.
85+ annotated := downstream .DeepCopy ()
86+ konnectortypes .SetSourceMetadataAnnotations (annotated , obj .GetNamespace (), string (obj .GetUID ()),
87+ konnectortypes .ProviderNamespaceAnnotationKey , konnectortypes .ProviderUIDAnnotationKey )
88+ if ! reflect .DeepEqual (downstream .GetAnnotations (), annotated .GetAnnotations ()) {
89+ logger .Info ("Updating downstream object provider annotations" )
90+ var err error
91+ if downstream , err = r .updateConsumerObject (ctx , annotated ); err != nil {
92+ return err
93+ }
94+ }
95+
8096 // let the isolation perform any changes it desires
8197 if err := r .isolationStrategy .MutateStatus (downstream , * consumerKey ); err != nil {
8298 return err
0 commit comments