@@ -402,6 +402,13 @@ var _ = Describe("Reconciler", func() {
402
402
}))
403
403
})
404
404
})
405
+ _ = Describe ("WithPauseReconcileAnnotation" , func () {
406
+ It ("should set the pauseReconcileAnnotation field to the annotation name" , func () {
407
+ a := "my.domain/pause-reconcile"
408
+ Expect (WithPauseReconcileAnnotation (a )(r )).To (Succeed ())
409
+ Expect (r .pauseReconcileAnnotation ).To (Equal (a ))
410
+ })
411
+ })
405
412
_ = Describe ("WithPreHook" , func () {
406
413
It ("should set a reconciler prehook" , func () {
407
414
called := false
@@ -543,6 +550,7 @@ var _ = Describe("Reconciler", func() {
543
550
WithInstallAnnotations (annotation.InstallDescription {}),
544
551
WithUpgradeAnnotations (annotation.UpgradeDescription {}),
545
552
WithUninstallAnnotations (annotation.UninstallDescription {}),
553
+ WithPauseReconcileAnnotation ("my.domain/pause-reconcile" ),
546
554
WithOverrideValues (map [string ]string {
547
555
"image.repository" : "custom-nginx" ,
548
556
}),
@@ -557,6 +565,7 @@ var _ = Describe("Reconciler", func() {
557
565
WithInstallAnnotations (annotation.InstallDescription {}),
558
566
WithUpgradeAnnotations (annotation.UpgradeDescription {}),
559
567
WithUninstallAnnotations (annotation.UninstallDescription {}),
568
+ WithPauseReconcileAnnotation ("my.domain/pause-reconcile" ),
560
569
WithOverrideValues (map [string ]string {
561
570
"image.repository" : "custom-nginx" ,
562
571
}),
@@ -1382,6 +1391,64 @@ var _ = Describe("Reconciler", func() {
1382
1391
verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1383
1392
})
1384
1393
1394
+ By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1395
+ err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1396
+ Expect (apierrors .IsNotFound (err )).To (BeTrue ())
1397
+ })
1398
+ })
1399
+ })
1400
+ When ("pause-reconcile annotation is present" , func () {
1401
+ It ("pauses reconciliation" , func () {
1402
+ By ("adding the pause-reconcile annotation to the CR" , func () {
1403
+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1404
+ obj .SetAnnotations (map [string ]string {"my.domain/pause-reconcile" : "true" })
1405
+ obj .Object ["spec" ] = map [string ]interface {}{"replicaCount" : "666" }
1406
+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1407
+ })
1408
+
1409
+ By ("deleting the CR" , func () {
1410
+ Expect (mgr .GetClient ().Delete (ctx , obj )).To (Succeed ())
1411
+ })
1412
+
1413
+ By ("successfully reconciling a request when paused" , func () {
1414
+ res , err := r .Reconcile (ctx , req )
1415
+ Expect (res ).To (Equal (reconcile.Result {}))
1416
+ Expect (err ).To (BeNil ())
1417
+ })
1418
+
1419
+ By ("getting the CR" , func () {
1420
+ Expect (mgr .GetAPIReader ().Get (ctx , objKey , obj )).To (Succeed ())
1421
+ })
1422
+
1423
+ By ("verifying the CR status is Paused" , func () {
1424
+ objStat := & objStatus {}
1425
+ Expect (runtime .DefaultUnstructuredConverter .FromUnstructured (obj .Object , objStat )).To (Succeed ())
1426
+ Expect (objStat .Status .Conditions .IsTrueFor (conditions .TypePaused )).To (BeTrue ())
1427
+ })
1428
+
1429
+ By ("verifying the release has not changed" , func () {
1430
+ rel , err := ac .Get (obj .GetName ())
1431
+ Expect (err ).To (BeNil ())
1432
+ Expect (rel ).NotTo (BeNil ())
1433
+ Expect (* rel ).To (Equal (* currentRelease ))
1434
+ })
1435
+
1436
+ By ("removing the pause-reconcile annotation from the CR" , func () {
1437
+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1438
+ obj .SetAnnotations (nil )
1439
+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1440
+ })
1441
+
1442
+ By ("successfully reconciling a request" , func () {
1443
+ res , err := r .Reconcile (ctx , req )
1444
+ Expect (res ).To (Equal (reconcile.Result {}))
1445
+ Expect (err ).To (BeNil ())
1446
+ })
1447
+
1448
+ By ("verifying the release is uninstalled" , func () {
1449
+ verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1450
+ })
1451
+
1385
1452
By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1386
1453
err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1387
1454
Expect (apierrors .IsNotFound (err )).To (BeTrue ())
0 commit comments