Skip to content

Commit

Permalink
Reintroduce missing events for helmChart reconciliation
Browse files Browse the repository at this point in the history
If implemented this PR reintroduce events for some failling action
during the reconciliation process, related to the helmChart retrieval
and loading of chart and values.

Signed-off-by: Soule BA <[email protected]>
  • Loading branch information
souleb committed Mar 6, 2024
1 parent 493dd66 commit e9e0915
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
18 changes: 4 additions & 14 deletions docs/api/v2beta2/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,6 @@ handle differences between the manifest in the Helm storage and the resources
currently existing in the cluster.</p>
<h3 id="helm.toolkit.fluxcd.io/v2beta2.Filter">Filter
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta2.Test">Test</a>)
</p>
<p>Filter holds the configuration for individual Helm test filters.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
Expand Down Expand Up @@ -2267,9 +2263,7 @@ Kubernetes meta/v1.Time
<td>
<code>testHooks</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta2.TestHookStatus">
TestHookStatus
</a>
map[string]*github.com/fluxcd/helm-controller/api/v2beta2.TestHookStatus
</em>
</td>
<td>
Expand All @@ -2283,7 +2277,7 @@ run by the controller.</p>
</div>
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta2.Snapshots">Snapshots
(<code>[]*./api/v2beta2.Snapshot</code> alias)</h3>
(<code>[]*github.com/fluxcd/helm-controller/api/v2beta2.Snapshot</code> alias)</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta2.HelmReleaseStatus">HelmReleaseStatus</a>)
Expand Down Expand Up @@ -2352,8 +2346,8 @@ actions in &lsquo;Install.IgnoreTestFailures&rsquo; and &lsquo;Upgrade.IgnoreTes
<td>
<code>filters</code><br>
<em>
<a href="#helm.toolkit.fluxcd.io/v2beta2.Filter">
Filter
<a href="#helm.toolkit.fluxcd.io/v2beta2.[]github.com/fluxcd/helm-controller/api/v2beta2.Filter">
[]github.com/fluxcd/helm-controller/api/v2beta2.Filter
</a>
</em>
</td>
Expand All @@ -2367,10 +2361,6 @@ Filter
</div>
<h3 id="helm.toolkit.fluxcd.io/v2beta2.TestHookStatus">TestHookStatus
</h3>
<p>
(<em>Appears on:</em>
<a href="#helm.toolkit.fluxcd.io/v2beta2.Snapshot">Snapshot</a>)
</p>
<p>TestHookStatus holds the status information for a test hook as observed
to be run by the controller.</p>
<div class="md-typeset__scrollwrap">
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/helmrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
conditions.MarkStalled(obj, aclv1.AccessDeniedReason, err.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, aclv1.AccessDeniedReason, err.Error())
conditions.Delete(obj, meta.ReconcilingCondition)
r.Eventf(obj, eventv1.EventSeverityError, aclv1.AccessDeniedReason, err.Error())

// Recovering from this is not possible without a restart of the
// controller or a change of spec, both triggering a new
Expand All @@ -268,6 +269,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe

msg := fmt.Sprintf("could not get HelmChart object: %s", err.Error())
conditions.MarkFalse(obj, meta.ReadyCondition, v2.ArtifactFailedReason, msg)
r.Eventf(obj, eventv1.EventSeverityError, v2.ArtifactFailedReason, msg)
return ctrl.Result{}, err
}
// Remove any stale corresponding Ready=False condition with Unknown.
Expand All @@ -293,6 +295,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
values, err := chartutil.ChartValuesFromReferences(ctx, r.Client, obj.Namespace, obj.GetValues(), obj.Spec.ValuesFrom...)
if err != nil {
conditions.MarkFalse(obj, meta.ReadyCondition, "ValuesError", err.Error())
r.Eventf(obj, eventv1.EventSeverityError, "ValuesError", err.Error())
return ctrl.Result{}, err
}
// Remove any stale corresponding Ready=False condition with Unknown.
Expand All @@ -311,6 +314,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
}

conditions.MarkFalse(obj, meta.ReadyCondition, v2.ArtifactFailedReason, fmt.Sprintf("Could not load chart: %s", err.Error()))
r.Eventf(obj, eventv1.EventSeverityError, v2.ArtifactFailedReason, err.Error())
return ctrl.Result{}, err
}
// Remove any stale corresponding Ready=False condition with Unknown.
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/helmrelease_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) {
WithStatusSubresource(&v2.HelmRelease{}).
WithObjects(obj).
Build(),
EventRecorder: record.NewFakeRecorder(32),
}

_, err := r.reconcileRelease(context.TODO(), patch.NewSerialPatcher(obj, r.Client), obj)
Expand Down Expand Up @@ -166,6 +167,7 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) {
WithStatusSubresource(&v2.HelmRelease{}).
WithObjects(obj).
Build(),
EventRecorder: record.NewFakeRecorder(32),
}

res, err := r.reconcileRelease(context.TODO(), patch.NewSerialPatcher(obj, r.Client), obj)
Expand Down Expand Up @@ -383,6 +385,7 @@ func TestHelmReleaseReconciler_reconcileRelease(t *testing.T) {
WithStatusSubresource(&v2.HelmRelease{}).
WithObjects(chart, obj).
Build(),
EventRecorder: record.NewFakeRecorder(32),
}

_, err := r.reconcileRelease(context.TODO(), patch.NewSerialPatcher(obj, r.Client), obj)
Expand Down

0 comments on commit e9e0915

Please sign in to comment.