Skip to content
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

Adapt to helm upgrade #47

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading