apply scripts: fail quickly on any sylva-units error
The sylvactl binary has restricted conditions in which it will exit early ; we can't extend this list too much because it would apply to all Kustomization and HelmReleases, and would result in stopping sylvactl even in the case where the error is due to a temporary intermediate step.
However, for the sylvactl watch call done right when using apply.sh to reconcile the sylva-units HelmRelease itself, we know that we shouldn't have temporary errors, and we will benefit from having quicker failure.
Example environment values:
_internal:
test: '{{ include "does-not-exist" . }}'
Doing this results in:
status:
conditions:
...
- lastTransitionTime: "2024-07-04T13:12:18Z"
message: 'Helm upgrade failed for release sylva-system/sylva-units with chart
sylva-units@0.0.0-git+7b4c837f39fe.1: template: sylva-units/templates/units.yaml:6:31:
executing "sylva-units/templates/units.yaml" at <include "interpret-values-gotpl"
.>: error calling include: template: sylva-units/templates/_interpret-values.tpl:107:89:
executing "interpret-values-gotpl" at <include "interpret-inner-gotpl">: error
calling include: template: sylva-units/templates/_interpret-values.tpl:308:60:
executing "interpret-inner-gotpl" at <include "interpret-inner-gotpl">: error
calling include: template: sylva-units/templates/_interpret-values.tpl:277:28:
executing "interpret-inner-gotpl" at <tpl $data $envAll>: error calling tpl:
error during tpl function execution for "{{ include \"does-not-exist\" . }}":
template: sylva-units/templates/units.yaml:1:3: executing "sylva-units/templates/units.yaml"
at <include "does-not-exist" .>: error calling include: template: no template
"does-not-exist" associated with template "gotpl"'
observedGeneration: 11
reason: UpgradeFailed
status: "False"
type: Ready
With the change done in this MR, apply.sh will exit instantly with:
🎯 Trigger reconciliation of units
trigger reconciliation of sylva-units HelmRelease...
using forced reconciliation
helmrelease.helm.toolkit.fluxcd.io/sylva-units annotated
✓ GitRepository/sylva-core - Resource is ready
✓ GitRepository/sylva-core - Resource is ready
✓ HelmChart/sylva-system-sylva-units - Resource is ready
✗ Exit condition matched for unit HelmRelease/sylva-units with reason: UpgradeFailed
Following resources were not ready when exit condition matched:
* HelmRelease/sylva-units: UpgradeFailed - Helm upgrade failed for release sylva-system/sylva-units with chart sylva-units@0.0.0-git+1d79dafb69c7.1: template: sylva-units/templates/units.yaml:6:31: executing "sylva-units/templates/units.yaml" at <include "interpret-values-gotpl" .>: error calling include: template: sylva-units/templates/_interpret-values.tpl:107:89: executing "interpret-values-gotpl" at <include "interpret-inner-gotpl">: error calling include: template: sylva-units/templates/_interpret-values.tpl:308:60: executing "interpret-inner-gotpl" at <include "interpret-inner-gotpl">: error calling include: template: sylva-units/templates/_interpret-values.tpl:277:28: executing "interpret-inner-gotpl" at <tpl $data $envAll>: error calling tpl: error during tpl function execution for "{{ include \"does-not-exist\" . }}": template: sylva-units/templates/units.yaml:1:3: executing "sylva-units/templates/units.yaml" at <include "does-not-exist" .>: error calling include: template: no template "does-not-exist" associated with template "gotpl"
Edited by Thomas Morin