Skip to content

Commit 3c86d2a

Browse files
committed
Adding waitForRollout()
* Changing most components over to use new function ref: FORGEOPS-6768
1 parent 9b0dc70 commit 3c86d2a

2 files changed

Lines changed: 28 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ unmaintained Nginx ingress. However, some users are installing Traefik manually
6767
and running into issues with sticky sessions not working. The traefik specific
6868
annotations for sticky sessions has been added.
6969

70+
### `forgops wait` reports success prematurely
71+
72+
When using `forgeops wait` after doing a `kubectl rollout restart` on a DS
73+
statefulset, the wait command would show success prematurely. This was due to
74+
the logic looking at pods starting at 0 when rollout starts with the last pod
75+
in the set. The logic has been changed to use `kubectl rollout status` to check
76+
for readiness.
77+
7078
## How-tos
7179

7280
The `custom-secrets.md` how-to has been modified to remove references to

bin/commands/wait

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ waitResourceExists() {
9292
local start_time=$(date +%s)
9393
local now=$(date +%s)
9494

95+
if [ "$DRYRUN" = true ] ; then
96+
return
97+
fi
98+
9599
while [ $(($now - $start_time)) -le $TIMEOUT ] ; do
96100
if kubeExists $resource ; then
97101
return 0
@@ -127,16 +131,12 @@ getLatestAmsterJob() {
127131
timeoutExit
128132
}
129133

130-
waitForDS() {
131-
local ds=$1
132-
133-
waitResourceExists "sts/${ds}"
134-
local rep=$($K_CMD $NAMESPACE_OPT get sts $ds -o=jsonpath='{.spec.replicas}')
135-
((rep--))
136-
message "rep=${rep}" "debug"
137-
for i in $(seq 0 $rep) ; do
138-
waitForResource ready "pod/${ds}-${i}"
139-
done
134+
waitForRollout() {
135+
local resource=$1
136+
echo "Waiting for ${resource} rollout to complete."
137+
if waitResourceExists "$resource" ; then
138+
kube rollout status --watch "${resource}" --timeout="${TIMEOUT}s"
139+
fi
140140
}
141141

142142
# Setup valid components now so they get presented in the usage
@@ -177,11 +177,11 @@ for c in ${COMPONENTS[@]} ; do
177177
message "c=$c" "debug"
178178
case $c in
179179
admin-ui)
180-
waitForResource ready "pod -l app=admin-ui"
180+
waitForRollout "deployment/admin-ui"
181181
;;
182182

183183
am)
184-
waitForResource ready "pod -l app=am"
184+
waitForRollout "deployment/am"
185185
;;
186186

187187
amster)
@@ -190,34 +190,34 @@ for c in ${COMPONENTS[@]} ; do
190190
;;
191191

192192
apps)
193-
waitForResource ready "pod -l app=am"
194193
amster_job=$(getLatestAmsterJob)
194+
waitForRollout "deployment/am"
195195
waitForResource 'complete' "job/${amster_job}"
196-
waitForResource ready "pod -l app=idm"
196+
waitForRollout "deployment/idm"
197197
;;
198198

199199
ds-cts)
200-
waitForDS ds-cts
200+
waitForRollout "statefulset/ds-cts"
201201
;;
202202

203203
ds-idrepo)
204-
waitForDS ds-idrepo
204+
waitForRollout "statefulset/ds-idrepo"
205205
;;
206206

207207
end-user-ui)
208-
waitForResource ready "pod -l app=end-user-ui"
208+
waitForRollout "deployment/end-user-ui"
209209
;;
210210

211211
idm)
212-
waitForResource ready "pod -l app=idm"
212+
waitForRollout "deployment/idm"
213213
;;
214214

215215
ig)
216-
waitForResource ready "pod -l app=ig"
216+
waitForRollout "deployment/ig"
217217
;;
218218

219219
login-ui)
220-
waitForResource ready "pod -l app=login-ui"
220+
waitForRollout "deployment/login-ui"
221221
;;
222222

223223
secrets)

0 commit comments

Comments
 (0)