File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,8 +33,25 @@ helm_update() {
3333 exit
3434 fi
3535
36- # Upgrade only if the status is already deployed, or if a previous upgrade was interrupted
37- if [[ " ${STATUS} " =~ ^(deployed| pending-upgrade)$ ]]; then
36+ # If a previous helm_v3 operation was interrupted unexpectedly, set it to failed.
37+ if [[ " ${STATUS} " =~ ^(pending-install| pending-upgrade| pending-rollback)$ ]] && [[ " ${HELM} " == " helm_v3" ]]; then
38+ echo Previous helm job was interrupted, updating status from ${STATUS} to failed
39+ ${HELM} set-status ${NAME} failed --namespace ${TARGET_NAMESPACE}
40+
41+ # Upgrades can be retried; install and rollback will be handled as failure below.
42+ # If this upgrade also fails, retries of the job will handle that as failure due to the release state change.
43+ if [[ " ${STATUS} " == " pending-upgrade" ]]; then
44+ echo " Retrying upgrade of ${NAME} "
45+ shift 1
46+ ${HELM} upgrade " $@ " ${NAME} ${CHART} ${TIMEOUT_ARG} ${VALUES}
47+ exit
48+ else
49+ STATUS=failed
50+ fi
51+ fi
52+
53+ # Upgrade only if the chart is already deployed
54+ if [[ " ${STATUS} " == " deployed" ]]; then
3855 echo Already installed ${NAME} , upgrading
3956 shift 1
4057 ${HELM} upgrade " $@ " ${NAME} ${CHART} ${TIMEOUT_ARG} ${VALUES}
Original file line number Diff line number Diff line change @@ -6,9 +6,18 @@ RUN mv /usr/bin/helm /usr/bin/helm_v2
66RUN curl https://get.helm.sh/helm-v3.5.4-linux-${ARCH}.tar.gz | tar xvzf - --strip-components=1 -C /usr/bin
77RUN mv /usr/bin/helm /usr/bin/helm_v3
88
9+ FROM golang:1.16-alpine3.12 as plugins
10+ RUN apk add -U curl ca-certificates build-base binutils-gold
11+ ARG ARCH
12+ COPY --from=extract /usr/bin/helm_v3 /usr/bin/helm
13+ RUN mkdir -p /go/src/github.com/k3s-io/helm-set-status && \
14+ curl -L https://github.com/k3s-io/helm-set-status/archive/refs/tags/v0.1.1.tar.gz | tar xvzf - --strip-components=1 -C /go/src/github.com/k3s-io/helm-set-status && \
15+ make -C /go/src/github.com/k3s-io/helm-set-status install
16+
917FROM alpine:3.12
1018RUN apk add -U --no-cache ca-certificates jq bash git
1119COPY --from=extract /usr/bin/helm_v2 /usr/bin/helm_v3 /usr/bin/tiller /usr/bin/
20+ COPY --from=plugins /root/.local/share/helm/plugins/ /root/.local/share/helm/plugins/
1221COPY entry /usr/bin/
1322ENTRYPOINT ["entry" ]
1423ENV STABLE_REPO_URL=https://charts.helm.sh/stable/
You can’t perform that action at this time.
0 commit comments