@@ -19,7 +19,7 @@ ARCHIVE_PRODUCT_INFO=$ARCHIVE_MOUNTPOINT/product.txt
19
19
SALT_DEFAULTS=$ARCHIVE_MOUNTPOINT /salt/metalk8s/defaults.yaml
20
20
OVERRIDE_ROOT_CONF=/etc/salt/master.d/90-metalk8s-root-override.conf
21
21
OVERRIDE_PILLAR_DEST=/etc/salt/pillar-override
22
- WAIT_RENEWAL=${WAIT_RENEWAL:- 240 }
22
+ WAIT_RENEWAL=${WAIT_RENEWAL:- 120 }
23
23
24
24
# shellcheck disable=SC1090
25
25
. " $ARCHIVE_PRODUCT_INFO "
64
64
--kubeconfig /etc/kubernetes/admin.conf
65
65
}
66
66
67
- apply_new_beacon_conf () {
67
+ run_certificates_beacon_state () {
68
68
local salt_container
69
69
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:- }
80
71
81
72
readarray -t minions < <( get_salt_minion_ids)
82
73
salt_container=$( get_salt_container)
@@ -89,9 +80,25 @@ apply_new_beacon_conf() {
89
80
retry " $retries " " $sleep_time " \
90
81
crictl exec -i " $salt_container " \
91
82
salt " $minion " state.apply metalk8s.beacon.certificates \
92
- pillar=" ${ pillar[*]} " \
83
+ ${ pillar: +pillar =" $pillar " } \
93
84
|| exit 1
94
85
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[*]} "
95
102
}
96
103
97
104
check_certificates_renewal () {
@@ -178,11 +185,20 @@ echo "Waiting ${SLEEP_TIME}s for certificates to be regenerated..."
178
185
sleep $SLEEP_TIME
179
186
180
187
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
184
198
185
199
echo " Resetting pillar configuration..."
186
200
reset_pillar_conf
201
+ echo " Resetting beacon configuration..."
202
+ run_certificates_beacon_state
187
203
188
204
exit $EXIT_CODE
0 commit comments