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 3 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
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: 2 additions & 2 deletions controllers/application_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed now?

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"']` {
Expand Down
Loading