From 415a44c8da4fee25d224ded12ce6f5807c9c4b8c Mon Sep 17 00:00:00 2001 From: sangeer <86688098+sangdammad@users.noreply.github.com> Date: Fri, 9 Feb 2024 09:38:58 -0600 Subject: [PATCH] Adapt to helm upgrade (#47) * fix: adapt to the major helm controller upgrade 0.37.2 * updated the status to reflect all the helm release statuses even when in progress * removed the print line added for debugging * incremented the overwhelm image version --------- Co-authored-by: Sangeetha Madamanchi --- .github/workflows/publish-latest.yaml | 2 +- api/v1beta1/application_types.go | 11 ++++++++ controllers/application_controller.go | 30 ++++++++++++---------- controllers/application_controller_test.go | 4 +-- 4 files changed, 29 insertions(+), 18 deletions(-) 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 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..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" @@ -281,7 +280,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,7 +378,6 @@ 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 { return errors.New("waiting for Analysis condition") }