diff --git a/staging/operator-lifecycle-manager/test/e2e/downstream_csv_namespace_labeler_plugin_test.go b/staging/operator-lifecycle-manager/test/e2e/downstream_csv_namespace_labeler_plugin_test.go index c9ee8733ea..08700c5974 100644 --- a/staging/operator-lifecycle-manager/test/e2e/downstream_csv_namespace_labeler_plugin_test.go +++ b/staging/operator-lifecycle-manager/test/e2e/downstream_csv_namespace_labeler_plugin_test.go @@ -2,7 +2,6 @@ package e2e import ( "context" - "github.com/blang/semver/v4" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -88,11 +87,18 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() { }).Should(HaveKeyWithValue(plugins.NamespaceLabelSyncerLabelKey, "true")) // delete label - ns := &v1.Namespace{} - Expect(determinedE2eClient.Get(context.Background(), k8scontrollerclient.ObjectKeyFromObject(&testNamespace), ns)).To(Succeed()) - nsCopy := ns.DeepCopy() - delete(nsCopy.Annotations, plugins.NamespaceLabelSyncerLabelKey) - Expect(determinedE2eClient.Update(context.Background(), nsCopy)).To(Succeed()) + // NOTE: not using the determined client here because it shouldn't be used for update operations due to + // race conditions (the updated resource could change b/w 'get' and 'update' operations + c := ctx.Ctx().E2EClient() + Eventually(func() error { + ns := &v1.Namespace{} + if err := c.Get(context.Background(), k8scontrollerclient.ObjectKeyFromObject(&testNamespace), ns); err != nil { + return err + } + nsCopy := ns.DeepCopy() + delete(nsCopy.Annotations, plugins.NamespaceLabelSyncerLabelKey) + return c.Update(context.Background(), nsCopy) + }).Should(BeNil()) // namespace should be labeled Eventually(func() (map[string]string, error) { diff --git a/staging/operator-lifecycle-manager/test/e2e/util.go b/staging/operator-lifecycle-manager/test/e2e/util.go index 2c970addc5..642601e56a 100644 --- a/staging/operator-lifecycle-manager/test/e2e/util.go +++ b/staging/operator-lifecycle-manager/test/e2e/util.go @@ -1068,7 +1068,7 @@ func HaveMessage(goal string) gtypes.GomegaMatcher { func SetupGeneratedTestNamespaceWithOperatorGroup(name string, og operatorsv1.OperatorGroup) corev1.Namespace { ns := corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ - Name: name, + Name: name, Labels: map[string]string{}, }, } diff --git a/staging/operator-lifecycle-manager/test/e2e/util/e2e_determined_client.go b/staging/operator-lifecycle-manager/test/e2e/util/e2e_determined_client.go index f93df8cb95..03313ec817 100644 --- a/staging/operator-lifecycle-manager/test/e2e/util/e2e_determined_client.go +++ b/staging/operator-lifecycle-manager/test/e2e/util/e2e_determined_client.go @@ -28,6 +28,11 @@ func (m *DeterminedE2EClient) Create(context context.Context, obj k8scontrollerc return nil } +// Update retries update operation until success or timeout +// +// Deprecation: do not use this method as it's not resilient to the case where the resource has changed out of band +// it will conflict until it times out. +// There's no priority to fix this client implementation - please use regular client instead func (m *DeterminedE2EClient) Update(context context.Context, obj k8scontrollerclient.Object, options ...k8scontrollerclient.UpdateOption) error { m.keepTrying(func() error { return m.E2EKubeClient.Update(context, obj, options...)