-
Notifications
You must be signed in to change notification settings - Fork 2
ROX-12219: Add support for pause-reconcile annotation #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -382,6 +382,13 @@ var _ = Describe("Reconciler", func() { | |||||
| })) | ||||||
| }) | ||||||
| }) | ||||||
| var _ = Describe("WithPauseReconcileAnnotation", func() { | ||||||
| It("should set the pauseReconcileAnnotation field to the annotation name", func() { | ||||||
| a := "my.domain/pause-reconcile" | ||||||
| Expect(WithPauseReconcileAnnotation(a)(r)).To(Succeed()) | ||||||
| Expect(r.pauseReconcileAnnotation).To(Equal(a)) | ||||||
| }) | ||||||
| }) | ||||||
| var _ = Describe("WithPreHook", func() { | ||||||
| It("should set a reconciler prehook", func() { | ||||||
| called := false | ||||||
|
|
@@ -524,6 +531,7 @@ var _ = Describe("Reconciler", func() { | |||||
| WithInstallAnnotations(annotation.InstallDescription{}), | ||||||
| WithUpgradeAnnotations(annotation.UpgradeDescription{}), | ||||||
| WithUninstallAnnotations(annotation.UninstallDescription{}), | ||||||
| WithPauseReconcileAnnotation("my.domain/pause-reconcile"), | ||||||
| WithOverrideValues(map[string]string{ | ||||||
| "image.repository": "custom-nginx", | ||||||
| }), | ||||||
|
|
@@ -538,6 +546,7 @@ var _ = Describe("Reconciler", func() { | |||||
| WithInstallAnnotations(annotation.InstallDescription{}), | ||||||
| WithUpgradeAnnotations(annotation.UpgradeDescription{}), | ||||||
| WithUninstallAnnotations(annotation.UninstallDescription{}), | ||||||
| WithPauseReconcileAnnotation("my.domain/pause-reconcile"), | ||||||
| WithOverrideValues(map[string]string{ | ||||||
| "image.repository": "custom-nginx", | ||||||
| }), | ||||||
|
|
@@ -1316,6 +1325,64 @@ var _ = Describe("Reconciler", func() { | |||||
| verifyNoRelease(ctx, mgr.GetClient(), obj.GetNamespace(), obj.GetName(), currentRelease) | ||||||
| }) | ||||||
|
|
||||||
| By("ensuring the finalizer is removed and the CR is deleted", func() { | ||||||
| err := mgr.GetAPIReader().Get(ctx, objKey, obj) | ||||||
| Expect(apierrors.IsNotFound(err)).To(BeTrue()) | ||||||
| }) | ||||||
| }) | ||||||
| }) | ||||||
| When("pause-reconcile annotation is present", func() { | ||||||
| It("pauses reconciliation", func() { | ||||||
| By("adding the pause-reconcile annotation to the CR", func() { | ||||||
| Expect(mgr.GetClient().Get(ctx, objKey, obj)).To(Succeed()) | ||||||
| obj.SetAnnotations(map[string]string{"my.domain/pause-reconcile": "true"}) | ||||||
| obj.Object["spec"] = map[string]interface{}{"replicaCount": "666"} | ||||||
| Expect(mgr.GetClient().Update(ctx, obj)).To(Succeed()) | ||||||
| }) | ||||||
|
|
||||||
| By("deleting the CR", func() { | ||||||
| Expect(mgr.GetClient().Delete(ctx, obj)).To(Succeed()) | ||||||
| }) | ||||||
|
|
||||||
| By("successfully reconciling a request when paused", func() { | ||||||
| res, err := r.Reconcile(ctx, req) | ||||||
| Expect(res).To(Equal(reconcile.Result{})) | ||||||
| Expect(err).To(BeNil()) | ||||||
| }) | ||||||
|
|
||||||
| By("getting the CR", func() { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I cannot parse your suggestion. |
||||||
| Expect(mgr.GetAPIReader().Get(ctx, objKey, obj)).To(Succeed()) | ||||||
| }) | ||||||
|
|
||||||
| By("verifying the CR status is Paused", func() { | ||||||
| objStat := &objStatus{} | ||||||
| Expect(runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, objStat)).To(Succeed()) | ||||||
| Expect(objStat.Status.Conditions.IsTrueFor(conditions.TypePaused)).To(BeTrue()) | ||||||
| }) | ||||||
|
|
||||||
| By("verifying the release has not changed", func() { | ||||||
| rel, err := ac.Get(obj.GetName()) | ||||||
| Expect(err).To(BeNil()) | ||||||
| Expect(rel).NotTo(BeNil()) | ||||||
| Expect(*rel).To(Equal(*currentRelease)) | ||||||
| }) | ||||||
|
|
||||||
| By("removing the pause-reconcile annotation from the CR", func() { | ||||||
| Expect(mgr.GetClient().Get(ctx, objKey, obj)).To(Succeed()) | ||||||
| obj.SetAnnotations(nil) | ||||||
| Expect(mgr.GetClient().Update(ctx, obj)).To(Succeed()) | ||||||
| }) | ||||||
|
|
||||||
| By("successfully reconciling a request", func() { | ||||||
| res, err := r.Reconcile(ctx, req) | ||||||
| Expect(res).To(Equal(reconcile.Result{})) | ||||||
| Expect(err).To(BeNil()) | ||||||
| }) | ||||||
|
|
||||||
| By("verifying the release is uninstalled", func() { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, we don't actually check the status here, so I'd leave this as is... |
||||||
| verifyNoRelease(ctx, mgr.GetClient(), obj.GetNamespace(), obj.GetName(), currentRelease) | ||||||
| }) | ||||||
|
|
||||||
| By("ensuring the finalizer is removed and the CR is deleted", func() { | ||||||
| err := mgr.GetAPIReader().Get(ctx, objKey, obj) | ||||||
| Expect(apierrors.IsNotFound(err)).To(BeTrue()) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.