Kubernetes pre-delete hook blocks helm delete if deployment fails

1/21/2019

In my helm chart, there's a pre-delete job that removes some extra resources when doing helm delete. If the deployment goes well, there's no problem with it.

However, when errors happen such as imagePullBackoff or pvc unbounded, the pre-delete job still try to execute and will go into error state as well so that the helm delete will time out.

I understand there's a helm delete --no-hook option, but i can't change the delete button in UI to make it happen as it's provided by third party.

Is there anything that I can do in my chart so that the helm delete automatically doesn't wait for pre-delete job if the job failed?

-- Clon15323
amazon-web-services
cloud
google-cloud-platform
kubernetes
kubernetes-helm

1 Answer

1/22/2019

You can try to write your pre-delete hook Job in a way that it will always reports success no matter what happened during the execution of main operation.

Example:

$ cat success.sh:

ls sdfsf || exit 0

$ cat success2.sh

set +e
ls 
ls sdfsf
exit 0

The scripts success.sh and success2.sh always return 0 (success), despite that ls sdfsf command inside the scripts returns 2 ("No such file or directory" error).

# following command also has exit code 0
$ ls sfsdf || echo -n ''
-- VAS
Source: StackOverflow