@@ -621,6 +621,11 @@ func apiServiceInstallStrategy(deploymentName string, cahash string, permissions
621
621
return strategy
622
622
}
623
623
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
+
624
629
func csv (
625
630
name , namespace , minKubeVersion , replaces string ,
626
631
installStrategy v1alpha1.NamedInstallStrategy ,
@@ -1151,7 +1156,7 @@ func TestTransitionCSV(t *testing.T) {
1151
1156
objs : []runtime.Object {
1152
1157
withLabels (
1153
1158
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 )),
1155
1160
),
1156
1161
},
1157
1162
},
@@ -1197,7 +1202,9 @@ func TestTransitionCSV(t *testing.T) {
1197
1202
deployment ("a1" , namespace , "sa" , addAnnotations (defaultTemplateAnnotations , map [string ]string {
1198
1203
OLMCAHashAnnotationKey : validCAHash ,
1199
1204
})),
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
+ }))),
1201
1208
),
1202
1209
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 {
1203
1210
OLMCAHashAnnotationKey : validCAHash ,
@@ -2221,7 +2228,7 @@ func TestTransitionCSV(t *testing.T) {
2221
2228
objs : []runtime.Object {
2222
2229
withLabels (
2223
2230
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 )),
2225
2232
),
2226
2233
deployment ("extra-dep" , namespace , "sa" , nil ),
2227
2234
},
@@ -2260,7 +2267,7 @@ func TestTransitionCSV(t *testing.T) {
2260
2267
ownerutil .OwnerKey : "csv1" ,
2261
2268
ownerutil .OwnerNamespaceKey : namespace ,
2262
2269
ownerutil .OwnerKind : "ClusterServiceVersion" ,
2263
- }, installStrategy ("csv1-dep1" , nil , nil )),
2270
+ }, withTemplateAnnotations ( installStrategy ("csv1-dep1" , nil , nil ), defaultTemplateAnnotations )),
2264
2271
),
2265
2272
deployment ("extra-dep" , namespace , "sa" , nil ),
2266
2273
},
@@ -2296,6 +2303,41 @@ func TestTransitionCSV(t *testing.T) {
2296
2303
},
2297
2304
},
2298
2305
},
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
+ },
2299
2341
{
2300
2342
name : "CSVSucceededToReplacing" ,
2301
2343
initial : initial {
@@ -2364,11 +2406,11 @@ func TestTransitionCSV(t *testing.T) {
2364
2406
objs : []runtime.Object {
2365
2407
withLabels (
2366
2408
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 )),
2368
2410
),
2369
2411
withLabels (
2370
2412
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 )),
2372
2414
),
2373
2415
},
2374
2416
},
@@ -2409,11 +2451,11 @@ func TestTransitionCSV(t *testing.T) {
2409
2451
objs : []runtime.Object {
2410
2452
withLabels (
2411
2453
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 )),
2413
2455
),
2414
2456
withLabels (
2415
2457
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 )),
2417
2459
),
2418
2460
},
2419
2461
},
@@ -2470,15 +2512,15 @@ func TestTransitionCSV(t *testing.T) {
2470
2512
objs : []runtime.Object {
2471
2513
withLabels (
2472
2514
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 )),
2474
2516
),
2475
2517
withLabels (
2476
2518
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 )),
2478
2520
),
2479
2521
withLabels (
2480
2522
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 )),
2482
2524
),
2483
2525
},
2484
2526
},
@@ -2529,15 +2571,15 @@ func TestTransitionCSV(t *testing.T) {
2529
2571
objs : []runtime.Object {
2530
2572
withLabels (
2531
2573
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 )),
2533
2575
),
2534
2576
withLabels (
2535
2577
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 )),
2537
2579
),
2538
2580
withLabels (
2539
2581
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 )),
2541
2583
),
2542
2584
},
2543
2585
},
@@ -2579,17 +2621,16 @@ func TestTransitionCSV(t *testing.T) {
2579
2621
objs : []runtime.Object {
2580
2622
withLabels (
2581
2623
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 )),
2583
2625
),
2584
2626
withLabels (
2585
2627
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 )),
2587
2629
),
2588
2630
},
2589
2631
},
2590
2632
expected : expected {
2591
2633
csvStates : map [string ]csvState {
2592
-
2593
2634
"csv1" : {exists : false , phase : v1alpha1 .CSVPhaseNone },
2594
2635
"csv2" : {exists : true , phase : v1alpha1 .CSVPhaseDeleting },
2595
2636
"csv3" : {exists : true , phase : v1alpha1 .CSVPhaseSucceeded },
@@ -2626,11 +2667,11 @@ func TestTransitionCSV(t *testing.T) {
2626
2667
objs : []runtime.Object {
2627
2668
withLabels (
2628
2669
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 )),
2630
2671
),
2631
2672
withLabels (
2632
2673
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 )),
2634
2675
),
2635
2676
},
2636
2677
},
@@ -2975,7 +3016,6 @@ func TestTransitionCSV(t *testing.T) {
2975
3016
csv , ok := outCSVMap [csvName ]
2976
3017
require .Equal (t , ok , csvState .exists , "%s existence should be %t" , csvName , csvState .exists )
2977
3018
if csvState .exists {
2978
- require .EqualValues (t , string (csvState .phase ), string (csv .Status .Phase ), "%s had incorrect phase" , csvName )
2979
3019
if csvState .reason != "" {
2980
3020
require .EqualValues (t , string (csvState .reason ), string (csv .Status .Reason ), "%s had incorrect condition reason" , csvName )
2981
3021
}
@@ -3423,8 +3463,9 @@ func TestSyncOperatorGroups(t *testing.T) {
3423
3463
3424
3464
ownedDeployment := deployment (deploymentName , operatorNamespace , serviceAccount .GetName (), nil )
3425
3465
ownerutil .AddNonBlockingOwner (ownedDeployment , operatorCSV )
3466
+ deploymentSpec := installStrategy (deploymentName , permissions , nil ).StrategySpec .DeploymentSpecs [0 ].Spec
3426
3467
ownedDeployment .SetLabels (map [string ]string {
3427
- install .DeploymentSpecHashLabelKey : install .HashDeploymentSpec (installStrategy ( deploymentName , permissions , nil ). StrategySpec . DeploymentSpecs [ 0 ]. Spec ),
3468
+ install .DeploymentSpecHashLabelKey : install .HashDeploymentSpec (deploymentSpec ),
3428
3469
})
3429
3470
3430
3471
annotatedDeployment := ownedDeployment .DeepCopy ()
@@ -3433,7 +3474,7 @@ func TestSyncOperatorGroups(t *testing.T) {
3433
3474
"olm.owner" : "csv1" ,
3434
3475
"olm.owner.namespace" : "operator-ns" ,
3435
3476
"olm.owner.kind" : "ClusterServiceVersion" ,
3436
- install .DeploymentSpecHashLabelKey : install .HashDeploymentSpec (installStrategy ( deploymentName , permissions , nil ). StrategySpec . DeploymentSpecs [ 0 ] .Spec ),
3477
+ install .DeploymentSpecHashLabelKey : install .HashDeploymentSpec (annotatedDeployment .Spec ),
3437
3478
})
3438
3479
3439
3480
annotatedGlobalDeployment := ownedDeployment .DeepCopy ()
@@ -3442,7 +3483,7 @@ func TestSyncOperatorGroups(t *testing.T) {
3442
3483
"olm.owner" : "csv1" ,
3443
3484
"olm.owner.namespace" : "operator-ns" ,
3444
3485
"olm.owner.kind" : "ClusterServiceVersion" ,
3445
- install .DeploymentSpecHashLabelKey : install .HashDeploymentSpec (installStrategy ( deploymentName , permissions , nil ). StrategySpec . DeploymentSpecs [ 0 ] .Spec ),
3486
+ install .DeploymentSpecHashLabelKey : install .HashDeploymentSpec (annotatedGlobalDeployment .Spec ),
3446
3487
})
3447
3488
3448
3489
role := & rbacv1.Role {
0 commit comments