helm: Pre-install hook error message.

I am trying to develop a Helm chart for an application to ease release management and deployment of the application to kubernetes. In order to do so, i have written a pre-install hook in the Helm chart.

    apiVersion: batch/v1
kind: Job
metadata:
  name: px-etcd-preinstall-hook
  labels:
    heritage: {{.Release.Service | quote }}
    release: {{.Release.Name | quote }}
    chart: "{{.Chart.Name}}-{{.Chart.Version}}"
  annotations:
    "helm.sh/hook": pre-install
    "helm.sh/hook-weight": "-5"
    "helm.sh/hook-delete-policy": hook-succeeded, hook-failed
spec:
  backoffLimit: 2
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: pre-install-job
        imagePullPolicy: Always
        image: "hrishi/px-etcd-preinstall-hook:v1"
        command: ['/bin/sh']
        args: ['/usr/bin/etcdStatus.sh',"{{ .Values.etcdEndPoint }}"]

This docker container just checks if an ETCD endpoint is accessible or not. Waits for a few seconds and a few tries and then exits here is the shell script which runs as part of this container.

set -x
echo "Initializing..."
svcname=$1
echo $svcname
etcdURL=$(echo "$svcname" | awk -F: '{ st = index($0,":");print substr($0,st+1)}')
echo $etcdURL

response=$(curl --write-out %{http_code} --silent --output /dev/null "$etcdURL/version")
echo $response

if [[ "$response" != 200 ]]
then
    echo "Provided etcd url is not reachable. Exiting.."
    exit 1
fi 

All is well and fine if the ETCD url is accessible, but if the etcd url is inaccessible then I get an error stating Error: Job failed: BackoffLimitExceeded”

I want to check if there is a way of setting a user friendly error message stating that the url isnt accessible or something like that. Seems there isnt a way to do it right now, not that i know of. I tried this to just be a Pod instead of a Job and that doesnt work either.

Looked up at the docs for Helm but couldnt seem to find any information regarding this.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 23 (7 by maintainers)

Most upvoted comments

This feature request has been open for 2 years, and I have not seen any movement from the community to implement this feature. Closing as inactive.

I have the same suggestion. If a pre-installation fails with a generic error like: Error: timed out waiting for the condition this has no value to a user. We should be able to return an error message from the pre-install hook The release is failing based on the pre-install hook so it is logical that there should be some way to transmit an error message from the pre-install hook to the user instead of a timeout error because the pre-install hook never succeeds.

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten /remove-lifecycle stale

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale