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