Repository navigation
fix: Process all hook deletions on failure - #30673
Conversation
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Laszlo Uveges <[email protected]>
Signed-off-by: Gerard Nguyen <[email protected]>
|
@nvanthao thanks for picking back up on this when you ran into this issue. Note to other maintainers if you get to this one first — from #11334 (comment) that we should squash commit and add this Co-authored-by line:
|
There was a problem hiding this comment.
This looks good—looking forward to finally getting this in.
Also manually tested:
-
create example chart:
$ d=`mktemp -d` $ name=pr-30673 $ mkdir -p $d/$name/templates $ cat > $d/$name/Chart.yaml <<EOF apiVersion: 0.1.0 name: $name version: 0.1.0 EOF $ cat > $d/$name/templates/job.yaml <<EOF apiVersion: batch/v1 kind: Job metadata: name: "{{ .Release.Name }}-successful-job" labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" annotations: "helm.sh/hook": pre-install "helm.sh/hook-weight": "1" "helm.sh/hook-delete-policy": "hook-succeeded,hook-failed" spec: template: metadata: name: successful-job labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: restartPolicy: Never containers: - name: bash command: - bash - -c - exit 0 image: bash:latest --- apiVersion: batch/v1 kind: Job metadata: name: "{{ .Release.Name }}-failed-job" labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion }} helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" annotations: "helm.sh/hook": pre-install "helm.sh/hook-weight": "2" "helm.sh/hook-delete-policy": "hook-failed,hook-succeeded" spec: backoffLimit: 0 template: metadata: name: failed-job labels: app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" spec: restartPolicy: Never containers: - name: bash command: - bash - -c - exit 1 image: bash:latest EOF
-
test without PR fix:
$ helm install without-fix $d/$name Error: INSTALLATION FAILED: failed pre-install: 1 error occurred: * job pr-30673-failed-job failed: BackoffLimitExceeded $ kubectl get job NAME STATUS COMPLETIONS DURATION AGE without-fix-successful-job Complete 1/1 3s 4m3s
The successful job with
hook-succeededpolicy was not deleted.Cleanup:
$ helm uninstall without-fix $ kubectl delete job without-fix-successful-job
-
test with PR fix:
$ cd /PATH/TO/HELM/REPO $ make $ ./bin/helm install with-fix $d/$name Error: INSTALLATION FAILED: failed pre-install: 1 error occurred: * job with-fix-failed-job failed: BackoffLimitExceeded $ kubectl get job NAME STATUS COMPLETIONS DURATION AGE
The job was deleted successfully.
Signed-off-by: Gerard Nguyen <[email protected]>
helm#30673 merge break main because of changes on wait strategy. This PR try to fix linting and tests. Signed-off-by: Benoit Tigeot <[email protected]>
What this PR does / why we need it:
fixes #10279
closes #11334
Special notes for your reviewer:
If applicable:
docs neededlabel should be applied if so)