From 68544d1a12ff6fa59ef80d0b0176efb3951d6026 Mon Sep 17 00:00:00 2001 From: Sangeetha Madamanchi Date: Fri, 2 Feb 2024 11:49:52 -0600 Subject: [PATCH 1/4] fix: adapt to the major helm controller upgrade 0.37.2 --- .github/workflows/publish-latest.yaml | 2 +- controllers/application_controller.go | 9 +++++++-- controllers/application_controller_test.go | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-latest.yaml b/.github/workflows/publish-latest.yaml index 8555979..61bbe8c 100644 --- a/.github/workflows/publish-latest.yaml +++ b/.github/workflows/publish-latest.yaml @@ -5,7 +5,7 @@ on: branches: [master] types: [completed] env: - VERSION: v0.0.10 + VERSION: v0.0.11 jobs: deploy: runs-on: ubuntu-latest diff --git a/controllers/application_controller.go b/controllers/application_controller.go index 07db964..2e3af42 100644 --- a/controllers/application_controller.go +++ b/controllers/application_controller.go @@ -255,8 +255,13 @@ func (r *ApplicationReconciler) reconcileHelmReleaseStatus(ctx context.Context, } helmReadyStatusNotReconciled := true for _, condition := range hr.GetConditions() { - apimeta.SetStatusCondition(&application.Status.Conditions, condition) - if condition.Type == meta.ReadyCondition && condition.Reason == v2beta2.ReconciliationSucceededReason { + if condition.Reason == meta.ProgressingReason || condition.Status == metav1.ConditionUnknown { + v1.AppInProgressStatus(application) + break + } else { + apimeta.SetStatusCondition(&application.Status.Conditions, condition) + } + if condition.Type == meta.ReadyCondition && condition.Status == metav1.ConditionTrue { apimeta.RemoveStatusCondition(&application.Status.Conditions, v1.PodReady) helmReadyStatusNotReconciled = false } diff --git a/controllers/application_controller_test.go b/controllers/application_controller_test.go index 488f630..bea20ab 100644 --- a/controllers/application_controller_test.go +++ b/controllers/application_controller_test.go @@ -277,15 +277,15 @@ var _ = Describe("Application controller", func() { return k8sClient.Get(ctx, client.ObjectKey{Name: a.Name, Namespace: a.Namespace}, hr) } }(ctx, hr), 5*time.Second, 300*time.Millisecond).Should(BeNil()) - hr.Status.ObservedGeneration = 1 - hr.Generation = hr.Status.ObservedGeneration + hr.Status.LastAttemptedGeneration = 1 + hr.Generation = hr.Status.LastAttemptedGeneration conditions := []metav1.Condition{{ Type: meta.ReadyCondition, Status: metav1.ConditionStatus(v1.ConditionTrue), ObservedGeneration: 1, LastTransitionTime: metav1.NewTime(time.Now()), - Message: "Helm Release Reconciled", - Reason: meta.SucceededReason, + Message: "Helm Release Reconciliation in Progress", + Reason: meta.ProgressingReason, }} hr.SetConditions(conditions) Expect(k8sClient.Status().Update(ctx, hr)).Should(BeNil()) From 4b59f179da076157f1934a010263fad65db51461 Mon Sep 17 00:00:00 2001 From: Sangeetha Madamanchi Date: Thu, 8 Feb 2024 17:01:05 -0600 Subject: [PATCH 2/4] updated the status to reflect all the helm release statuses even when in progress --- api/v1beta1/application_types.go | 11 ++++++++ controllers/application_controller.go | 30 ++++++++++++---------- controllers/application_controller_test.go | 4 +-- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/api/v1beta1/application_types.go b/api/v1beta1/application_types.go index 5735fa4..6ac76af 100644 --- a/api/v1beta1/application_types.go +++ b/api/v1beta1/application_types.go @@ -134,6 +134,17 @@ func AppInProgressStatus(application *Application) { apimeta.SetStatusCondition(&application.Status.Conditions, condition) } +func AppUnknownStatus(application *Application, message string) { + application.Status.Conditions = []metav1.Condition{} + condition := metav1.Condition{ + Type: meta.ReadyCondition, + Status: metav1.ConditionUnknown, + Reason: meta.ProgressingReason, + Message: message, + } + apimeta.SetStatusCondition(&application.Status.Conditions, condition) +} + func AppErrorStatus(application *Application, error string) { condition := metav1.Condition{ Type: meta.ReadyCondition, diff --git a/controllers/application_controller.go b/controllers/application_controller.go index 2e3af42..391bac5 100644 --- a/controllers/application_controller.go +++ b/controllers/application_controller.go @@ -248,24 +248,26 @@ func (r *ApplicationReconciler) reconcileHelmReleaseStatus(ctx context.Context, } else { latestHRGeneration = hr.Status.LastAttemptedGeneration } - if latestHRGeneration != hr.Generation { - v1.AppErrorStatus(application, "updated Helm Release status not available") - apimeta.RemoveStatusCondition(&application.Status.Conditions, v1.PodReady) - return false, nil - } helmReadyStatusNotReconciled := true for _, condition := range hr.GetConditions() { - if condition.Reason == meta.ProgressingReason || condition.Status == metav1.ConditionUnknown { - v1.AppInProgressStatus(application) - break - } else { - apimeta.SetStatusCondition(&application.Status.Conditions, condition) - } - if condition.Type == meta.ReadyCondition && condition.Status == metav1.ConditionTrue { - apimeta.RemoveStatusCondition(&application.Status.Conditions, v1.PodReady) - helmReadyStatusNotReconciled = false + if condition.ObservedGeneration == hr.Generation { + latestHRGeneration = hr.Generation + if condition.Type == meta.ReconcilingCondition { + continue + } else { + apimeta.SetStatusCondition(&application.Status.Conditions, condition) + } + if condition.Type == meta.ReadyCondition && condition.Status == metav1.ConditionTrue { + apimeta.RemoveStatusCondition(&application.Status.Conditions, v1.PodReady) + helmReadyStatusNotReconciled = false + } } } + if latestHRGeneration != hr.Generation { + v1.AppUnknownStatus(application, "Updated Helm Release status not yet available") + apimeta.RemoveStatusCondition(&application.Status.Conditions, v1.PodReady) + return false, nil + } return helmReadyStatusNotReconciled, nil } diff --git a/controllers/application_controller_test.go b/controllers/application_controller_test.go index bea20ab..a6c8964 100644 --- a/controllers/application_controller_test.go +++ b/controllers/application_controller_test.go @@ -281,7 +281,7 @@ var _ = Describe("Application controller", func() { hr.Generation = hr.Status.LastAttemptedGeneration conditions := []metav1.Condition{{ Type: meta.ReadyCondition, - Status: metav1.ConditionStatus(v1.ConditionTrue), + Status: metav1.ConditionStatus(v1.ConditionUnknown), ObservedGeneration: 1, LastTransitionTime: metav1.NewTime(time.Now()), Message: "Helm Release Reconciliation in Progress", @@ -379,8 +379,8 @@ var _ = Describe("Application controller", func() { if err := k8sClient.Get(ctx, client.ObjectKey{Name: a.Name, Namespace: a.Namespace}, app); err != nil { return err } - fmt.Println(app.Status.Conditions) if len(app.Status.Conditions) != 2 { + fmt.Println(app.Status.Conditions[0].Message) return errors.New("waiting for Analysis condition") } if app.Status.Conditions[1].Message != `Pod appname-55f99cdb4b-eeeeeeee is unhealthy: [container 'application' is not ready and is in a waiting state due to reason 'ImagePullBackOff' with message 'Back-off pulling image "secret/secret:secret"']` { From de4b5b37383a3a06ee289e8d0601b68b6b55091a Mon Sep 17 00:00:00 2001 From: Sangeetha Madamanchi Date: Fri, 9 Feb 2024 09:25:21 -0600 Subject: [PATCH 3/4] removed the print line added for debugging --- controllers/application_controller_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/controllers/application_controller_test.go b/controllers/application_controller_test.go index a6c8964..51004b1 100644 --- a/controllers/application_controller_test.go +++ b/controllers/application_controller_test.go @@ -3,7 +3,6 @@ package controllers import ( "context" "errors" - "fmt" "github.com/ExpediaGroup/overwhelm/api/v1beta1" "time" @@ -380,7 +379,6 @@ var _ = Describe("Application controller", func() { return err } if len(app.Status.Conditions) != 2 { - fmt.Println(app.Status.Conditions[0].Message) return errors.New("waiting for Analysis condition") } if app.Status.Conditions[1].Message != `Pod appname-55f99cdb4b-eeeeeeee is unhealthy: [container 'application' is not ready and is in a waiting state due to reason 'ImagePullBackOff' with message 'Back-off pulling image "secret/secret:secret"']` { From 58b2281157a536a0d8f965cc1ece0c8082ee4741 Mon Sep 17 00:00:00 2001 From: Sangeetha Madamanchi Date: Fri, 9 Feb 2024 09:28:20 -0600 Subject: [PATCH 4/4] incremented the overwhelm image version --- .github/workflows/publish-latest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-latest.yaml b/.github/workflows/publish-latest.yaml index 61bbe8c..0bd504a 100644 --- a/.github/workflows/publish-latest.yaml +++ b/.github/workflows/publish-latest.yaml @@ -5,7 +5,7 @@ on: branches: [master] types: [completed] env: - VERSION: v0.0.11 + VERSION: v0.0.12 jobs: deploy: runs-on: ubuntu-latest