aboutsummaryrefslogtreecommitdiffhomepage
path: root/files/clever-wait-deploy.sh
diff options
context:
space:
mode:
authorPaul Bonaud <paul.bonaud@fretlink.com>2020-06-17 11:06:08 +0200
committerPaul Bonaud <paul.bonaud@fretlink.com>2020-06-17 12:43:56 +0200
commit7ceb5d83f04daeb81fb07814a48dd61aca41430f (patch)
tree2b838e43037a85f90d9db176db8f31e7841ecfca /files/clever-wait-deploy.sh
parentac9ad8d780ae4c8f31b69b986b4c295e11cbfa13 (diff)
downloadansible-clever-upgrade-clever-cli.tar.gz
ansible-clever-upgrade-clever-cli.tar.zst
ansible-clever-upgrade-clever-cli.zip
deploy: remove custom polling script now that the CLI does it for usupgrade-clever-cli
See recent changes (https://github.com/CleverCloud/clever-tools/pull/415) introduced in 2.5.0+ version of the clever cli tools
Diffstat (limited to 'files/clever-wait-deploy.sh')
-rwxr-xr-xfiles/clever-wait-deploy.sh96
1 files changed, 0 insertions, 96 deletions
diff --git a/files/clever-wait-deploy.sh b/files/clever-wait-deploy.sh
deleted file mode 100755
index a95c96f..0000000
--- a/files/clever-wait-deploy.sh
+++ /dev/null
@@ -1,96 +0,0 @@
1#!/usr/bin/env bash
2
3set -ueo pipefail
4
5VERBOSE=${VERBOSE:-}
6lastCleverActivity=""
7timeout=2300 # 100 seconds less than the Ansible tasks' timeout
8startTime=$(date +%s)
9
10function cleverActivity {
11 lastCleverActivity=$(clever activity)
12}
13
14function ensure {
15 local lastReturnCode="$?"
16
17 VERBOSE=true
18 verbose
19
20 if isNotTimeout
21 then
22 if [ "$lastReturnCode" == "0" ]
23 then
24 echo "✓ Deployment done."
25 else
26 echo "✗ Deployment failed!"
27 fi
28 else
29 echo "⁈ Deployment timeout... Please check clever logs"
30 exit 1
31 fi
32}
33
34function isNotTimeout {
35 [ $(($(date +%s) - startTime)) -lt $timeout ]
36}
37
38trap ensure EXIT ERR
39
40function deploying {
41 checkStatus "$1" "IN PROGRESS"
42}
43
44function deployed {
45 checkStatus "$1" "OK"
46}
47
48function inactive {
49 checkStatus "$1" "" "-v"
50}
51
52function checkStatus {
53 local commit="$1"
54 local status="$2"
55
56 cleverActivity
57 echo "${lastCleverActivity}" | tail -n1 | grep ${3:+ "${3}"} -q -E "${status}.*DEPLOY.*${commit}"
58}
59
60function verbose {
61 if [ -n "${VERBOSE}" ]; then
62 echo -e "\\nLast clever activity:"
63 echo -e "${lastCleverActivity}\\n"
64 fi
65}
66
67function check {
68 local commit="$1"
69 local samplingTime=5
70
71 echo "️▫ Waiting for deployment to start..."
72 while inactive "$commit" && isNotTimeout
73 do
74 verbose
75 sleep $samplingTime
76 done
77
78 # Wait for completion
79 echo "▪ Deployment in progress..."
80 while deploying "$commit" && isNotTimeout
81 do
82 verbose
83 sleep $samplingTime
84 done
85
86 deployed "$commit"
87}
88
89function getHeadRev {
90 local chdir="$1/.git"
91
92 git --git-dir="$chdir" rev-parse HEAD
93}
94
95workdir="$(pwd)"
96check "$(getHeadRev "${workdir}")"