diff options
author | paulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com> | 2020-06-17 15:10:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-17 15:10:45 +0200 |
commit | d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6 (patch) | |
tree | da182d67325ec1b8ce02a600e6c458229772eece /files | |
parent | 5816bb884149309b6cfcf438feab7265a14d4c0b (diff) | |
parent | b89d0540672614a5d93da43b317015c3ae8554be (diff) | |
download | ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.tar.gz ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.tar.zst ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.zip |
Merge pull request #63 from paulrbr-fl/upgrade-clever-cliv2.5
deploy: remove custom polling script now that the CLI does it for us
Diffstat (limited to 'files')
-rwxr-xr-x | files/clever-wait-deploy.sh | 96 |
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 | |||
3 | set -ueo pipefail | ||
4 | |||
5 | VERBOSE=${VERBOSE:-} | ||
6 | lastCleverActivity="" | ||
7 | timeout=2300 # 100 seconds less than the Ansible tasks' timeout | ||
8 | startTime=$(date +%s) | ||
9 | |||
10 | function cleverActivity { | ||
11 | lastCleverActivity=$(clever activity) | ||
12 | } | ||
13 | |||
14 | function 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 | |||
34 | function isNotTimeout { | ||
35 | [ $(($(date +%s) - startTime)) -lt $timeout ] | ||
36 | } | ||
37 | |||
38 | trap ensure EXIT ERR | ||
39 | |||
40 | function deploying { | ||
41 | checkStatus "$1" "IN PROGRESS" | ||
42 | } | ||
43 | |||
44 | function deployed { | ||
45 | checkStatus "$1" "OK" | ||
46 | } | ||
47 | |||
48 | function inactive { | ||
49 | checkStatus "$1" "" "-v" | ||
50 | } | ||
51 | |||
52 | function 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 | |||
60 | function verbose { | ||
61 | if [ -n "${VERBOSE}" ]; then | ||
62 | echo -e "\\nLast clever activity:" | ||
63 | echo -e "${lastCleverActivity}\\n" | ||
64 | fi | ||
65 | } | ||
66 | |||
67 | function 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 | |||
89 | function getHeadRev { | ||
90 | local chdir="$1/.git" | ||
91 | |||
92 | git --git-dir="$chdir" rev-parse HEAD | ||
93 | } | ||
94 | |||
95 | workdir="$(pwd)" | ||
96 | check "$(getHeadRev "${workdir}")" | ||