Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
Allow deploying latest build again
Browse files Browse the repository at this point in the history
The current deployable check does not allow to redeploy the same
deployment once again. Meaning if your deployment gets corrupted
somehow you cannot delete it and deploy it again.

As an example, Airflow (jobflow) currently as a bug due to missing
support for certain kubernetes resources which can have it looses
track of some of the resources it created in k8s. The only work
around seem to delete and create again the deployment (_cf._
apache/airflow#21087).
  • Loading branch information
cansjt committed Mar 28, 2022
1 parent 5e84245 commit 4f27a6d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
48 changes: 48 additions & 0 deletions orbs/helm-runner/deployable
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env sh

set -eu

fatal() {
printf "$*\n" >/dev/stderr
exit 1
}

usage() {
cat <<EOF
usage: $0 OPTIONS <name>
OPTIONS
-h display help
-p tag pattern (default: $pattern)
EOF
}

pattern="*"

OPTIND=1
while getopts 'hp:' arg; do
case "$arg" in
h) usage; exit 0 ;;
p) pattern="$OPTARG" ;;
?) fatal "unknown option" ;;
esac
done
shift $((OPTIND - 1))

if [ ! -d ".git" ]; then
fatal "no git repository found"
fi

last_tag=$(git tag --sort version:refname --list "$pattern" | tail -1)
if [ -z "$last_tag" ]; then
exit 0
fi

deployed_sha1=$(git rev-parse "$last_tag")
current_sha1=$(git rev-parse HEAD)

if [ "${deployed_sha1}" != "${current_sha1}" ]
then
fatal "the current build is older than the deployed one"
fi
3 changes: 2 additions & 1 deletion orbs/helm/deployable
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fi
deployed_sha1=$(git rev-parse "$last_tag")
current_sha1=$(git rev-parse HEAD)

if [ "$(git rev-list $deployed_sha1 | grep $current_sha1)" ]; then
if [ "${deployed_sha1}" != "${current_sha1}" ]
then
fatal "the current build is older than the deployed one"
fi

0 comments on commit 4f27a6d

Please sign in to comment.