Skip to content

Commit 3b3b18a

Browse files
committed
fix(deployment): remove separate operatorgroup annotation updater
this allows the deployment installer to fully calculate the target hash and reduces complexity
1 parent 92ac562 commit 3b3b18a

File tree

4 files changed

+77
-106
lines changed

4 files changed

+77
-106
lines changed

pkg/controller/install/deployment.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package install
33
import (
44
"fmt"
55
"hash/fnv"
6-
"k8s.io/apimachinery/pkg/util/rand"
76

87
log "github.com/sirupsen/logrus"
98
appsv1 "k8s.io/api/apps/v1"
109
k8serrors "k8s.io/apimachinery/pkg/api/errors"
10+
"k8s.io/apimachinery/pkg/util/rand"
1111
hashutil "k8s.io/kubernetes/pkg/util/hash"
1212

13-
v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1"
1413
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
1514
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/wrappers"
1615
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
@@ -271,22 +270,6 @@ func (i *StrategyDeploymentInstaller) cleanupOrphanedDeployments(deploymentSpecs
271270
// HashDeploymentSpec calculates a hash given a copy of the deployment spec from a CSV, stripping any
272271
// operatorgroup annotations.
273272
func HashDeploymentSpec(spec appsv1.DeploymentSpec) string {
274-
// TODO: the deployment installer should know about operatorgroups and ca hashes so that it can calculate these
275-
276-
// Remove operatorgroup annotations for deployment hashing - this simplifies calculation of the deployment hash
277-
// because we don't need to worry about the current state of the operatorgroup
278-
annotations := spec.Template.GetAnnotations()
279-
if annotations != nil {
280-
delete(annotations, v1.OperatorGroupAnnotationKey)
281-
delete(annotations, v1.OperatorGroupNamespaceAnnotationKey)
282-
delete(annotations, v1.OperatorGroupTargetsAnnotationKey)
283-
}
284-
285-
if len(annotations) == 0 {
286-
annotations = nil
287-
}
288-
spec.Template.SetAnnotations(annotations)
289-
290273
hasher := fnv.New32a()
291274
hashutil.DeepHashObject(hasher, &spec)
292275
return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))

pkg/controller/operators/olm/operator.go

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,10 +1198,6 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
11981198
return
11991199
}
12001200

1201-
if err := a.ensureDeploymentAnnotations(logger, out); err != nil {
1202-
return nil, err
1203-
}
1204-
12051201
modeSet, err := v1alpha1.NewInstallModeSet(out.Spec.InstallModes)
12061202
if err != nil {
12071203
syncError = err
@@ -1391,7 +1387,8 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
13911387
logger.WithField("strategy", out.Spec.InstallStrategy.StrategyName).Infof("install strategy successful")
13921388
} else {
13931389
// Set phase to failed if it's been a long time since the last transition (5 minutes)
1394-
if out.Status.LastTransitionTime != nil && metav1.Now().Sub(out.Status.LastTransitionTime.Time) >= 5*time.Minute {
1390+
if out.Status.LastTransitionTime != nil && a.now().Sub(out.Status.LastTransitionTime.Time) >= 5*time.Minute {
1391+
logger.Warn("install timed out")
13951392
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonInstallCheckFailed, fmt.Sprintf("install timeout"), now, a.recorder)
13961393
}
13971394
}
@@ -1658,7 +1655,7 @@ func (a *Operator) parseStrategiesAndUpdateStatus(csv *v1alpha1.ClusterServiceVe
16581655
}
16591656

16601657
strName := strategy.GetStrategyName()
1661-
installer := a.resolver.InstallerForStrategy(strName, kubeclient, a.lister, csv, csv.Annotations, previousStrategy)
1658+
installer := a.resolver.InstallerForStrategy(strName, kubeclient, a.lister, csv, csv.GetAnnotations(), previousStrategy)
16621659
return installer, strategy
16631660
}
16641661

@@ -1874,60 +1871,6 @@ func (a *Operator) cleanupCSVDeployments(logger *logrus.Entry, csv *v1alpha1.Clu
18741871
}
18751872
}
18761873

1877-
func (a *Operator) ensureDeploymentAnnotations(logger *logrus.Entry, csv *v1alpha1.ClusterServiceVersion) error {
1878-
if !csv.IsSafeToUpdateOperatorGroupAnnotations() {
1879-
return nil
1880-
}
1881-
1882-
// Get csv operatorgroup annotations
1883-
annotations := a.copyOperatorGroupAnnotations(&csv.ObjectMeta)
1884-
1885-
// Extract the InstallStrategy for the deployment
1886-
strategy, err := a.resolver.UnmarshalStrategy(csv.Spec.InstallStrategy)
1887-
if err != nil {
1888-
logger.Warn("could not parse install strategy while cleaning up CSV deployment")
1889-
return nil
1890-
}
1891-
1892-
// Assume the strategy is for a deployment
1893-
strategyDetailsDeployment, ok := strategy.(*v1alpha1.StrategyDetailsDeployment)
1894-
if !ok {
1895-
logger.Warnf("could not cast install strategy as type %T", strategyDetailsDeployment)
1896-
return nil
1897-
}
1898-
1899-
existingDeployments, err := a.lister.AppsV1().DeploymentLister().Deployments(csv.GetNamespace()).List(ownerutil.CSVOwnerSelector(csv))
1900-
if err != nil {
1901-
return err
1902-
}
1903-
1904-
// compare deployments to see if any need to be created/updated
1905-
updateErrs := []error{}
1906-
for _, dep := range existingDeployments {
1907-
if dep.Spec.Template.Annotations == nil {
1908-
dep.Spec.Template.Annotations = map[string]string{}
1909-
}
1910-
1911-
changed := false
1912-
for key, value := range annotations {
1913-
if v, ok := dep.Spec.Template.Annotations[key]; !ok || v != value {
1914-
dep.Spec.Template.Annotations[key] = value
1915-
changed = true
1916-
}
1917-
}
1918-
1919-
if changed {
1920-
if _, _, err := a.opClient.UpdateDeployment(dep); err != nil {
1921-
logger.Info("annotations updated!")
1922-
updateErrs = append(updateErrs, err)
1923-
}
1924-
}
1925-
}
1926-
logger.Info("updated annotations to match current operatorgroup")
1927-
1928-
return utilerrors.NewAggregate(updateErrs)
1929-
}
1930-
19311874
// ensureLabels merges a label set with a CSV's labels and attempts to update the CSV if the merged set differs from the CSV's original labels.
19321875
func (a *Operator) ensureLabels(in *v1alpha1.ClusterServiceVersion, labelSets ...labels.Set) (*v1alpha1.ClusterServiceVersion, error) {
19331876
csvLabelSet := labels.Set(in.GetLabels())

pkg/controller/operators/olm/operator_test.go

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ func apiServiceInstallStrategy(deploymentName string, cahash string, permissions
621621
return strategy
622622
}
623623

624+
func withTemplateAnnotations(strategy v1alpha1.NamedInstallStrategy, annotations map[string]string) v1alpha1.NamedInstallStrategy {
625+
strategy.StrategySpec.DeploymentSpecs[0].Spec.Template.Annotations = annotations
626+
return strategy
627+
}
628+
624629
func csv(
625630
name, namespace, minKubeVersion, replaces string,
626631
installStrategy v1alpha1.NamedInstallStrategy,
@@ -1151,7 +1156,7 @@ func TestTransitionCSV(t *testing.T) {
11511156
objs: []runtime.Object{
11521157
withLabels(
11531158
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
1154-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), installStrategy("csv1-dep1", nil, nil)),
1159+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
11551160
),
11561161
},
11571162
},
@@ -1197,7 +1202,9 @@ func TestTransitionCSV(t *testing.T) {
11971202
deployment("a1", namespace, "sa", addAnnotations(defaultTemplateAnnotations, map[string]string{
11981203
OLMCAHashAnnotationKey: validCAHash,
11991204
})),
1200-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), apiServiceInstallStrategy("a1", validCAHash, nil, nil)),
1205+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(apiServiceInstallStrategy("a1", validCAHash, nil, nil), addAnnotations(defaultTemplateAnnotations, map[string]string{
1206+
OLMCAHashAnnotationKey: validCAHash,
1207+
}))),
12011208
),
12021209
withAnnotations(keyPairToTLSSecret("v1.a1-cert", namespace, signedServingPair(time.Now().Add(24*time.Hour), validCA, []string{"v1-a1.ns", "v1-a1.ns.svc"})), map[string]string{
12031210
OLMCAHashAnnotationKey: validCAHash,
@@ -2221,7 +2228,7 @@ func TestTransitionCSV(t *testing.T) {
22212228
objs: []runtime.Object{
22222229
withLabels(
22232230
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2224-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), installStrategy("csv1-dep1", nil, nil)),
2231+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
22252232
),
22262233
deployment("extra-dep", namespace, "sa", nil),
22272234
},
@@ -2260,7 +2267,7 @@ func TestTransitionCSV(t *testing.T) {
22602267
ownerutil.OwnerKey: "csv1",
22612268
ownerutil.OwnerNamespaceKey: namespace,
22622269
ownerutil.OwnerKind: "ClusterServiceVersion",
2263-
}, installStrategy("csv1-dep1", nil, nil)),
2270+
}, withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
22642271
),
22652272
deployment("extra-dep", namespace, "sa", nil),
22662273
},
@@ -2296,6 +2303,41 @@ func TestTransitionCSV(t *testing.T) {
22962303
},
22972304
},
22982305
},
2306+
{
2307+
name: "SingleCSVSucceededToPending/DeploymentSpecChanged",
2308+
initial: initial{
2309+
csvs: []runtime.Object{
2310+
withConditionReason(csvWithAnnotations(csv("csv1",
2311+
namespace,
2312+
"0.0.0",
2313+
"",
2314+
installStrategy("csv1-dep1", nil, nil),
2315+
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1", "g1")},
2316+
[]*v1beta1.CustomResourceDefinition{},
2317+
v1alpha1.CSVPhaseSucceeded,
2318+
), addAnnotations(defaultTemplateAnnotations, map[string]string{"new": "annotation"})), v1alpha1.CSVReasonInstallSuccessful),
2319+
},
2320+
clientObjs: []runtime.Object{defaultOperatorGroup},
2321+
crds: []runtime.Object{
2322+
crd("c1", "v1", "g1"),
2323+
},
2324+
objs: []runtime.Object{
2325+
withLabels(
2326+
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2327+
addDepSpecHashLabel(map[string]string{
2328+
ownerutil.OwnerKey: "csv1",
2329+
ownerutil.OwnerNamespaceKey: namespace,
2330+
ownerutil.OwnerKind: "ClusterServiceVersion",
2331+
}, withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
2332+
),
2333+
},
2334+
},
2335+
expected: expected{
2336+
csvStates: map[string]csvState{
2337+
"csv1": {exists: true, phase: v1alpha1.CSVPhasePending},
2338+
},
2339+
},
2340+
},
22992341
{
23002342
name: "CSVSucceededToReplacing",
23012343
initial: initial{
@@ -2364,11 +2406,11 @@ func TestTransitionCSV(t *testing.T) {
23642406
objs: []runtime.Object{
23652407
withLabels(
23662408
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2367-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), installStrategy("csv1-dep1", nil, nil)),
2409+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
23682410
),
23692411
withLabels(
23702412
deployment("csv2-dep1", namespace, "sa", defaultTemplateAnnotations),
2371-
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), installStrategy("csv2-dep1", nil, nil)),
2413+
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), withTemplateAnnotations(installStrategy("csv2-dep1", nil, nil), defaultTemplateAnnotations)),
23722414
),
23732415
},
23742416
},
@@ -2409,11 +2451,11 @@ func TestTransitionCSV(t *testing.T) {
24092451
objs: []runtime.Object{
24102452
withLabels(
24112453
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2412-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), installStrategy("csv1-dep1", nil, nil)),
2454+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
24132455
),
24142456
withLabels(
24152457
deployment("csv2-dep1", namespace, "sa", defaultTemplateAnnotations),
2416-
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), installStrategy("csv2-dep1", nil, nil)),
2458+
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), withTemplateAnnotations(installStrategy("csv2-dep1", nil, nil), defaultTemplateAnnotations)),
24172459
),
24182460
},
24192461
},
@@ -2470,15 +2512,15 @@ func TestTransitionCSV(t *testing.T) {
24702512
objs: []runtime.Object{
24712513
withLabels(
24722514
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2473-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), installStrategy("csv1-dep1", nil, nil)),
2515+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
24742516
),
24752517
withLabels(
24762518
deployment("csv2-dep1", namespace, "sa", defaultTemplateAnnotations),
2477-
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), installStrategy("csv2-dep1", nil, nil)),
2519+
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), withTemplateAnnotations(installStrategy("csv2-dep1", nil, nil), defaultTemplateAnnotations)),
24782520
),
24792521
withLabels(
24802522
deployment("csv3-dep1", namespace, "sa", defaultTemplateAnnotations),
2481-
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), installStrategy("csv3-dep1", nil, nil)),
2523+
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), withTemplateAnnotations(installStrategy("csv3-dep1", nil, nil), defaultTemplateAnnotations)),
24822524
),
24832525
},
24842526
},
@@ -2529,15 +2571,15 @@ func TestTransitionCSV(t *testing.T) {
25292571
objs: []runtime.Object{
25302572
withLabels(
25312573
deployment("csv1-dep1", namespace, "sa", defaultTemplateAnnotations),
2532-
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), installStrategy("csv1-dep1", nil, nil)),
2574+
addDepSpecHashLabel(ownerLabelFromCSV("csv1", namespace), withTemplateAnnotations(installStrategy("csv1-dep1", nil, nil), defaultTemplateAnnotations)),
25332575
),
25342576
withLabels(
25352577
deployment("csv2-dep1", namespace, "sa", defaultTemplateAnnotations),
2536-
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), installStrategy("csv2-dep1", nil, nil)),
2578+
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), withTemplateAnnotations(installStrategy("csv2-dep1", nil, nil), defaultTemplateAnnotations)),
25372579
),
25382580
withLabels(
25392581
deployment("csv3-dep1", namespace, "sa", defaultTemplateAnnotations),
2540-
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), installStrategy("csv3-dep1", nil, nil)),
2582+
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), withTemplateAnnotations(installStrategy("csv3-dep1", nil, nil), defaultTemplateAnnotations)),
25412583
),
25422584
},
25432585
},
@@ -2579,17 +2621,16 @@ func TestTransitionCSV(t *testing.T) {
25792621
objs: []runtime.Object{
25802622
withLabels(
25812623
deployment("csv2-dep1", namespace, "sa", defaultTemplateAnnotations),
2582-
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), installStrategy("csv2-dep1", nil, nil)),
2624+
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), withTemplateAnnotations(installStrategy("csv2-dep1", nil, nil), defaultTemplateAnnotations)),
25832625
),
25842626
withLabels(
25852627
deployment("csv3-dep1", namespace, "sa", defaultTemplateAnnotations),
2586-
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), installStrategy("csv3-dep1", nil, nil)),
2628+
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), withTemplateAnnotations(installStrategy("csv3-dep1", nil, nil), defaultTemplateAnnotations)),
25872629
),
25882630
},
25892631
},
25902632
expected: expected{
25912633
csvStates: map[string]csvState{
2592-
25932634
"csv1": {exists: false, phase: v1alpha1.CSVPhaseNone},
25942635
"csv2": {exists: true, phase: v1alpha1.CSVPhaseDeleting},
25952636
"csv3": {exists: true, phase: v1alpha1.CSVPhaseSucceeded},
@@ -2626,11 +2667,11 @@ func TestTransitionCSV(t *testing.T) {
26262667
objs: []runtime.Object{
26272668
withLabels(
26282669
deployment("csv2-dep1", namespace, "sa", defaultTemplateAnnotations),
2629-
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), installStrategy("csv2-dep1", nil, nil)),
2670+
addDepSpecHashLabel(ownerLabelFromCSV("csv2", namespace), withTemplateAnnotations(installStrategy("csv2-dep1", nil, nil), defaultTemplateAnnotations)),
26302671
),
26312672
withLabels(
26322673
deployment("csv3-dep1", namespace, "sa", defaultTemplateAnnotations),
2633-
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), installStrategy("csv3-dep1", nil, nil)),
2674+
addDepSpecHashLabel(ownerLabelFromCSV("csv3", namespace), withTemplateAnnotations(installStrategy("csv3-dep1", nil, nil), defaultTemplateAnnotations)),
26342675
),
26352676
},
26362677
},
@@ -2975,7 +3016,6 @@ func TestTransitionCSV(t *testing.T) {
29753016
csv, ok := outCSVMap[csvName]
29763017
require.Equal(t, ok, csvState.exists, "%s existence should be %t", csvName, csvState.exists)
29773018
if csvState.exists {
2978-
require.EqualValues(t, string(csvState.phase), string(csv.Status.Phase), "%s had incorrect phase", csvName)
29793019
if csvState.reason != "" {
29803020
require.EqualValues(t, string(csvState.reason), string(csv.Status.Reason), "%s had incorrect condition reason", csvName)
29813021
}
@@ -3423,8 +3463,9 @@ func TestSyncOperatorGroups(t *testing.T) {
34233463

34243464
ownedDeployment := deployment(deploymentName, operatorNamespace, serviceAccount.GetName(), nil)
34253465
ownerutil.AddNonBlockingOwner(ownedDeployment, operatorCSV)
3466+
deploymentSpec := installStrategy(deploymentName, permissions, nil).StrategySpec.DeploymentSpecs[0].Spec
34263467
ownedDeployment.SetLabels(map[string]string{
3427-
install.DeploymentSpecHashLabelKey: install.HashDeploymentSpec(installStrategy(deploymentName, permissions, nil).StrategySpec.DeploymentSpecs[0].Spec),
3468+
install.DeploymentSpecHashLabelKey: install.HashDeploymentSpec(deploymentSpec),
34283469
})
34293470

34303471
annotatedDeployment := ownedDeployment.DeepCopy()
@@ -3433,7 +3474,7 @@ func TestSyncOperatorGroups(t *testing.T) {
34333474
"olm.owner": "csv1",
34343475
"olm.owner.namespace": "operator-ns",
34353476
"olm.owner.kind": "ClusterServiceVersion",
3436-
install.DeploymentSpecHashLabelKey: install.HashDeploymentSpec(installStrategy(deploymentName, permissions, nil).StrategySpec.DeploymentSpecs[0].Spec),
3477+
install.DeploymentSpecHashLabelKey: install.HashDeploymentSpec(annotatedDeployment.Spec),
34373478
})
34383479

34393480
annotatedGlobalDeployment := ownedDeployment.DeepCopy()
@@ -3442,7 +3483,7 @@ func TestSyncOperatorGroups(t *testing.T) {
34423483
"olm.owner": "csv1",
34433484
"olm.owner.namespace": "operator-ns",
34443485
"olm.owner.kind": "ClusterServiceVersion",
3445-
install.DeploymentSpecHashLabelKey: install.HashDeploymentSpec(installStrategy(deploymentName, permissions, nil).StrategySpec.DeploymentSpecs[0].Spec),
3486+
install.DeploymentSpecHashLabelKey: install.HashDeploymentSpec(annotatedGlobalDeployment.Spec),
34463487
})
34473488

34483489
role := &rbacv1.Role{

test/e2e/operator_groups_e2e_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"k8s.io/apimachinery/pkg/util/wait"
1919
"k8s.io/client-go/informers"
2020
"k8s.io/client-go/tools/cache"
21+
"k8s.io/client-go/util/retry"
2122

2223
v1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1"
2324
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
@@ -2099,11 +2100,14 @@ func TestCleanupCsvsWithBadOwnerOperatorGroups(t *testing.T) {
20992100
require.NoError(t, err)
21002101

21012102
// Give copied CSV a bad operatorgroup annotation
2102-
fetchedCSV, err := crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Get(csvName, metav1.GetOptions{})
2103-
require.NoError(t, err)
2104-
fetchedCSV.Annotations[v1.OperatorGroupNamespaceAnnotationKey] = fetchedCSV.GetNamespace()
2105-
_, err = crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Update(fetchedCSV)
2106-
require.NoError(t, err)
2103+
updateCSV := func() error {
2104+
fetchedCSV, err := crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Get(csvName, metav1.GetOptions{})
2105+
require.NoError(t, err)
2106+
fetchedCSV.Annotations[v1.OperatorGroupNamespaceAnnotationKey] = fetchedCSV.GetNamespace()
2107+
_, err = crc.OperatorsV1alpha1().ClusterServiceVersions(otherNamespaceName).Update(fetchedCSV)
2108+
return err
2109+
}
2110+
require.NoError(t, retry.RetryOnConflict(retry.DefaultBackoff, updateCSV))
21072111

21082112
// wait for CSV to be gc'd
21092113
err = wait.Poll(pollInterval, 2*pollDuration, func() (bool, error) {

0 commit comments

Comments
 (0)