Skip to content

Commit f25d942

Browse files
committedJan 12, 2021
Merge branch 'bugfix/raise-certificate-renewal-wait-time' into q/2.7
2 parents c3f6be7 + 267a1ac commit f25d942

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed
 

‎eve/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,7 @@ stages:
21962196
ssh -F ssh_config bootstrap "sudo ./test-certificates-beacon.sh /var/tmp/metalk8s"
21972197
workdir: build/eve/workers/openstack-terraform/terraform/
21982198
haltOnFailure: true
2199+
- ShellCommand: *wait_pods_stable_ssh
21992200
- ShellCommand:
22002201
<<: *multi_node_fast_tests
22012202
name: Run fast tests on Bastion after certificates renewal

‎tests/test-certificates-beacon.sh

+32-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ARCHIVE_PRODUCT_INFO=$ARCHIVE_MOUNTPOINT/product.txt
1919
SALT_DEFAULTS=$ARCHIVE_MOUNTPOINT/salt/metalk8s/defaults.yaml
2020
OVERRIDE_ROOT_CONF=/etc/salt/master.d/90-metalk8s-root-override.conf
2121
OVERRIDE_PILLAR_DEST=/etc/salt/pillar-override
22-
WAIT_RENEWAL=${WAIT_RENEWAL:-240}
22+
WAIT_RENEWAL=${WAIT_RENEWAL:-120}
2323

2424
# shellcheck disable=SC1090
2525
. "$ARCHIVE_PRODUCT_INFO"
@@ -64,19 +64,10 @@ EOF
6464
--kubeconfig /etc/kubernetes/admin.conf
6565
}
6666

67-
apply_new_beacon_conf() {
67+
run_certificates_beacon_state() {
6868
local salt_container
6969
local -ri retries=5 sleep_time=10
70-
local -ra pillar=(
71-
"{"
72-
" 'certificates': {"
73-
" 'beacon': {"
74-
" 'notify_days': $BEACON_NOTIFY_DAYS,"
75-
" 'interval': $BEACON_INTERVAL"
76-
" }"
77-
" }"
78-
"}"
79-
)
70+
local -r pillar=${1:-}
8071

8172
readarray -t minions < <(get_salt_minion_ids)
8273
salt_container=$(get_salt_container)
@@ -89,9 +80,25 @@ apply_new_beacon_conf() {
8980
retry "$retries" "$sleep_time" \
9081
crictl exec -i "$salt_container" \
9182
salt "$minion" state.apply metalk8s.beacon.certificates \
92-
pillar="${pillar[*]}" \
83+
${pillar:+pillar="$pillar"} \
9384
|| exit 1
9485
done
86+
87+
}
88+
89+
apply_new_beacon_conf() {
90+
local -ra pillar=(
91+
"{"
92+
" 'certificates': {"
93+
" 'beacon': {"
94+
" 'notify_days': $BEACON_NOTIFY_DAYS,"
95+
" 'interval': $BEACON_INTERVAL"
96+
" }"
97+
" }"
98+
"}"
99+
)
100+
101+
run_certificates_beacon_state "${pillar[*]}"
95102
}
96103

97104
check_certificates_renewal() {
@@ -178,11 +185,20 @@ echo "Waiting ${SLEEP_TIME}s for certificates to be regenerated..."
178185
sleep $SLEEP_TIME
179186

180187
echo "Checking certificates renewal..."
181-
check_certificates_renewal
182-
183-
EXIT_CODE=$?
188+
for ((EXIT_CODE=1, max_try=3, try=1; try <= max_try; ++try)); do
189+
if check_certificates_renewal; then
190+
EXIT_CODE=0
191+
break
192+
elif [ "$try" -lt "$max_try" ]; then
193+
echo "All certificates are not renewed yet, retrying in" \
194+
"$SLEEP_TIME seconds..."
195+
sleep $SLEEP_TIME
196+
fi
197+
done
184198

185199
echo "Resetting pillar configuration..."
186200
reset_pillar_conf
201+
echo "Resetting beacon configuration..."
202+
run_certificates_beacon_state
187203

188204
exit $EXIT_CODE

0 commit comments

Comments
 (0)
Please sign in to comment.