Skip to content

Commit 7456354

Browse files
committed
fix e2e test
1 parent e2923a1 commit 7456354

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

pkg/konnector/controllers/cluster/serviceexport/status/status_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func NewController(
110110

111111
return obj.DeepCopy(), nil
112112
},
113+
updateConsumerObject: func(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
114+
return consumerClient.Resource(gvr).Namespace(obj.GetNamespace()).Update(ctx, obj, metav1.UpdateOptions{})
115+
},
113116
updateConsumerObjectStatus: func(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
114117
return consumerClient.Resource(gvr).Namespace(obj.GetNamespace()).UpdateStatus(ctx, obj, metav1.UpdateOptions{})
115118
},

pkg/konnector/controllers/cluster/serviceexport/status/status_reconcile.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3233
type 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

Comments
 (0)