@@ -382,6 +382,13 @@ var _ = Describe("Reconciler", func() {
382
382
}))
383
383
})
384
384
})
385
+ var _ = Describe ("WithPauseReconcileAnnotation" , func () {
386
+ It ("should set the pauseReconcileAnnotation field to the annotation name" , func () {
387
+ a := "my.domain/pause-reconcile"
388
+ Expect (WithPauseReconcileAnnotation (a )(r )).To (Succeed ())
389
+ Expect (r .pauseReconcileAnnotation ).To (Equal (a ))
390
+ })
391
+ })
385
392
var _ = Describe ("WithPreHook" , func () {
386
393
It ("should set a reconciler prehook" , func () {
387
394
called := false
@@ -524,6 +531,7 @@ var _ = Describe("Reconciler", func() {
524
531
WithInstallAnnotations (annotation.InstallDescription {}),
525
532
WithUpgradeAnnotations (annotation.UpgradeDescription {}),
526
533
WithUninstallAnnotations (annotation.UninstallDescription {}),
534
+ WithPauseReconcileAnnotation ("my.domain/pause-reconcile" ),
527
535
WithOverrideValues (map [string ]string {
528
536
"image.repository" : "custom-nginx" ,
529
537
}),
@@ -538,6 +546,7 @@ var _ = Describe("Reconciler", func() {
538
546
WithInstallAnnotations (annotation.InstallDescription {}),
539
547
WithUpgradeAnnotations (annotation.UpgradeDescription {}),
540
548
WithUninstallAnnotations (annotation.UninstallDescription {}),
549
+ WithPauseReconcileAnnotation ("my.domain/pause-reconcile" ),
541
550
WithOverrideValues (map [string ]string {
542
551
"image.repository" : "custom-nginx" ,
543
552
}),
@@ -1316,6 +1325,64 @@ var _ = Describe("Reconciler", func() {
1316
1325
verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1317
1326
})
1318
1327
1328
+ By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1329
+ err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1330
+ Expect (apierrors .IsNotFound (err )).To (BeTrue ())
1331
+ })
1332
+ })
1333
+ })
1334
+ When ("pause-reconcile annotation is present" , func () {
1335
+ It ("pauses reconciliation" , func () {
1336
+ By ("adding the pause-reconcile annotation to the CR" , func () {
1337
+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1338
+ obj .SetAnnotations (map [string ]string {"my.domain/pause-reconcile" : "true" })
1339
+ obj .Object ["spec" ] = map [string ]interface {}{"replicaCount" : "666" }
1340
+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1341
+ })
1342
+
1343
+ By ("deleting the CR" , func () {
1344
+ Expect (mgr .GetClient ().Delete (ctx , obj )).To (Succeed ())
1345
+ })
1346
+
1347
+ By ("successfully reconciling a request when paused" , func () {
1348
+ res , err := r .Reconcile (ctx , req )
1349
+ Expect (res ).To (Equal (reconcile.Result {}))
1350
+ Expect (err ).To (BeNil ())
1351
+ })
1352
+
1353
+ By ("getting the CR" , func () {
1354
+ Expect (mgr .GetAPIReader ().Get (ctx , objKey , obj )).To (Succeed ())
1355
+ })
1356
+
1357
+ By ("verifying the CR status is Paused" , func () {
1358
+ objStat := & objStatus {}
1359
+ Expect (runtime .DefaultUnstructuredConverter .FromUnstructured (obj .Object , objStat )).To (Succeed ())
1360
+ Expect (objStat .Status .Conditions .IsTrueFor (conditions .TypePaused )).To (BeTrue ())
1361
+ })
1362
+
1363
+ By ("verifying the release has not changed" , func () {
1364
+ rel , err := ac .Get (obj .GetName ())
1365
+ Expect (err ).To (BeNil ())
1366
+ Expect (rel ).NotTo (BeNil ())
1367
+ Expect (* rel ).To (Equal (* currentRelease ))
1368
+ })
1369
+
1370
+ By ("removing the pause-reconcile annotation from the CR" , func () {
1371
+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1372
+ obj .SetAnnotations (nil )
1373
+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1374
+ })
1375
+
1376
+ By ("successfully reconciling a request" , func () {
1377
+ res , err := r .Reconcile (ctx , req )
1378
+ Expect (res ).To (Equal (reconcile.Result {}))
1379
+ Expect (err ).To (BeNil ())
1380
+ })
1381
+
1382
+ By ("verifying the release is uninstalled" , func () {
1383
+ verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1384
+ })
1385
+
1319
1386
By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1320
1387
err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1321
1388
Expect (apierrors .IsNotFound (err )).To (BeTrue ())
0 commit comments