@@ -404,6 +404,13 @@ var _ = Describe("Reconciler", func() {
404
404
}))
405
405
})
406
406
})
407
+ _ = Describe ("WithPauseReconcileAnnotation" , func () {
408
+ It ("should set the pauseReconcileAnnotation field to the annotation name" , func () {
409
+ a := "my.domain/pause-reconcile"
410
+ Expect (WithPauseReconcileAnnotation (a )(r )).To (Succeed ())
411
+ Expect (r .pauseReconcileAnnotation ).To (Equal (a ))
412
+ })
413
+ })
407
414
_ = Describe ("WithPreHook" , func () {
408
415
It ("should set a reconciler prehook" , func () {
409
416
called := false
@@ -545,6 +552,7 @@ var _ = Describe("Reconciler", func() {
545
552
WithInstallAnnotations (annotation.InstallDescription {}),
546
553
WithUpgradeAnnotations (annotation.UpgradeDescription {}),
547
554
WithUninstallAnnotations (annotation.UninstallDescription {}),
555
+ WithPauseReconcileAnnotation ("my.domain/pause-reconcile" ),
548
556
WithOverrideValues (map [string ]string {
549
557
"image.repository" : "custom-nginx" ,
550
558
}),
@@ -559,6 +567,7 @@ var _ = Describe("Reconciler", func() {
559
567
WithInstallAnnotations (annotation.InstallDescription {}),
560
568
WithUpgradeAnnotations (annotation.UpgradeDescription {}),
561
569
WithUninstallAnnotations (annotation.UninstallDescription {}),
570
+ WithPauseReconcileAnnotation ("my.domain/pause-reconcile" ),
562
571
WithOverrideValues (map [string ]string {
563
572
"image.repository" : "custom-nginx" ,
564
573
}),
@@ -1429,6 +1438,64 @@ var _ = Describe("Reconciler", func() {
1429
1438
verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1430
1439
})
1431
1440
1441
+ By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1442
+ err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1443
+ Expect (apierrors .IsNotFound (err )).To (BeTrue ())
1444
+ })
1445
+ })
1446
+ })
1447
+ When ("pause-reconcile annotation is present" , func () {
1448
+ It ("pauses reconciliation" , func () {
1449
+ By ("adding the pause-reconcile annotation to the CR" , func () {
1450
+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1451
+ obj .SetAnnotations (map [string ]string {"my.domain/pause-reconcile" : "true" })
1452
+ obj .Object ["spec" ] = map [string ]interface {}{"replicaCount" : "666" }
1453
+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1454
+ })
1455
+
1456
+ By ("deleting the CR" , func () {
1457
+ Expect (mgr .GetClient ().Delete (ctx , obj )).To (Succeed ())
1458
+ })
1459
+
1460
+ By ("successfully reconciling a request when paused" , func () {
1461
+ res , err := r .Reconcile (ctx , req )
1462
+ Expect (res ).To (Equal (reconcile.Result {}))
1463
+ Expect (err ).ToNot (HaveOccurred ())
1464
+ })
1465
+
1466
+ By ("getting the CR" , func () {
1467
+ Expect (mgr .GetAPIReader ().Get (ctx , objKey , obj )).To (Succeed ())
1468
+ })
1469
+
1470
+ By ("verifying the CR status is Paused" , func () {
1471
+ objStat := & objStatus {}
1472
+ Expect (runtime .DefaultUnstructuredConverter .FromUnstructured (obj .Object , objStat )).To (Succeed ())
1473
+ Expect (objStat .Status .Conditions .IsTrueFor (conditions .TypePaused )).To (BeTrue ())
1474
+ })
1475
+
1476
+ By ("verifying the release has not changed" , func () {
1477
+ rel , err := ac .Get (obj .GetName ())
1478
+ Expect (err ).ToNot (HaveOccurred ())
1479
+ Expect (rel ).NotTo (BeNil ())
1480
+ Expect (* rel ).To (Equal (* currentRelease ))
1481
+ })
1482
+
1483
+ By ("removing the pause-reconcile annotation from the CR" , func () {
1484
+ Expect (mgr .GetClient ().Get (ctx , objKey , obj )).To (Succeed ())
1485
+ obj .SetAnnotations (nil )
1486
+ Expect (mgr .GetClient ().Update (ctx , obj )).To (Succeed ())
1487
+ })
1488
+
1489
+ By ("successfully reconciling a request" , func () {
1490
+ res , err := r .Reconcile (ctx , req )
1491
+ Expect (res ).To (Equal (reconcile.Result {}))
1492
+ Expect (err ).ToNot (HaveOccurred ())
1493
+ })
1494
+
1495
+ By ("verifying the release is uninstalled" , func () {
1496
+ verifyNoRelease (ctx , mgr .GetClient (), obj .GetNamespace (), obj .GetName (), currentRelease )
1497
+ })
1498
+
1432
1499
By ("ensuring the finalizer is removed and the CR is deleted" , func () {
1433
1500
err := mgr .GetAPIReader ().Get (ctx , objKey , obj )
1434
1501
Expect (apierrors .IsNotFound (err )).To (BeTrue ())
0 commit comments