diff --git a/internal/controller/helmrelease_controller.go b/internal/controller/helmrelease_controller.go index ba7c0fe85..b02501a06 100644 --- a/internal/controller/helmrelease_controller.go +++ b/internal/controller/helmrelease_controller.go @@ -585,7 +585,7 @@ func (r *HelmReleaseReconciler) checkDependencies(ctx context.Context, obj *v2.H return fmt.Errorf("unable to get '%s' dependency: %w", ref, err) } - if dHr.Generation != dHr.Status.ObservedGeneration || !conditions.IsTrue(dHr, meta.ReadyCondition) { + if dHr.Generation != conditions.GetObservedGeneration(dHr, meta.ReadyCondition) || !conditions.IsTrue(dHr, meta.ReadyCondition) { return fmt.Errorf("dependency '%s' is not ready", ref) } } diff --git a/internal/controller/helmrelease_controller_test.go b/internal/controller/helmrelease_controller_test.go index 6cd56bc72..4a89263a5 100644 --- a/internal/controller/helmrelease_controller_test.go +++ b/internal/controller/helmrelease_controller_test.go @@ -2037,9 +2037,8 @@ func TestHelmReleaseReconciler_checkDependencies(t *testing.T) { Namespace: "some-namespace", }, Status: v2.HelmReleaseStatus{ - ObservedGeneration: 1, Conditions: []metav1.Condition{ - {Type: meta.ReadyCondition, Status: metav1.ConditionTrue}, + {Type: meta.ReadyCondition, Status: metav1.ConditionTrue, ObservedGeneration: 1}, }, }, }, @@ -2050,9 +2049,8 @@ func TestHelmReleaseReconciler_checkDependencies(t *testing.T) { Namespace: "some-other-namespace", }, Status: v2.HelmReleaseStatus{ - ObservedGeneration: 2, Conditions: []metav1.Condition{ - {Type: meta.ReadyCondition, Status: metav1.ConditionTrue}, + {Type: meta.ReadyCondition, Status: metav1.ConditionTrue, ObservedGeneration: 2}, }, }, }, @@ -2084,9 +2082,8 @@ func TestHelmReleaseReconciler_checkDependencies(t *testing.T) { Namespace: "some-namespace", }, Status: v2.HelmReleaseStatus{ - ObservedGeneration: 1, Conditions: []metav1.Condition{ - {Type: meta.ReadyCondition, Status: metav1.ConditionTrue}, + {Type: meta.ReadyCondition, Status: metav1.ConditionTrue, ObservedGeneration: 1}, }, }, }, @@ -2119,9 +2116,8 @@ func TestHelmReleaseReconciler_checkDependencies(t *testing.T) { Namespace: "some-namespace", }, Status: v2.HelmReleaseStatus{ - ObservedGeneration: 1, Conditions: []metav1.Condition{ - {Type: meta.ReadyCondition, Status: metav1.ConditionFalse}, + {Type: meta.ReadyCondition, Status: metav1.ConditionFalse, ObservedGeneration: 1}, }, }, }, @@ -2153,9 +2149,7 @@ func TestHelmReleaseReconciler_checkDependencies(t *testing.T) { Name: "dependency-1", Namespace: "some-namespace", }, - Status: v2.HelmReleaseStatus{ - ObservedGeneration: 1, - }, + Status: v2.HelmReleaseStatus{}, }, }, expect: func(g *WithT, err error) {