Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package e2e

import (
"context"

"github.com/blang/semver/v4"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion staging/operator-lifecycle-manager/test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down