Skip to content

Commit

Permalink
Adapt to helm upgrade (#47)
Browse files Browse the repository at this point in the history
* 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 <smadamanchi@expediagroup.com>
  • Loading branch information
sangdammad and Sangeetha Madamanchi authored Feb 9, 2024
1 parent b294cce commit 415a44c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [master]
types: [completed]
env:
VERSION: v0.0.11
VERSION: v0.0.12
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions api/v1beta1/application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
30 changes: 16 additions & 14 deletions controllers/application_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 1 addition & 3 deletions controllers/application_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controllers
import (
"context"
"errors"
"fmt"
"github.com/ExpediaGroup/overwhelm/api/v1beta1"
"time"

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 415a44c

Please sign in to comment.