Prevent multiple vault-manager pods from acting

This commit adds new check in the main loop of vault manager
for multiple instances of vault manager. Only one vault manager is
needed, so it will be put on sleep or be
terminated until only one is left

Story: 2010930
Task: 49199

Test Plan:
PASS Bashate
PASS Vault sanity test

Change-Id: I0fd881aa4078528ba3f804087db87069dae58f7e
Signed-off-by: Tae Park <tae.park@windriver.com>
This commit is contained in:
Tae Park 2023-12-08 16:15:36 -05:00 committed by Tae Park
parent be0e85ec77
commit 65b38b925d
1 changed files with 10 additions and 0 deletions

View File

@ -3282,6 +3282,16 @@ data:
sleep "$STATUS_RATE"
exit_on_trap 20
pickK8sVersion # check if the k8s server version is changed
count=$( kubectl get pods -n "${VAULT_NS}" \
-o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' \
| grep "^${VAULT_FN}-manager" | wc -w )
if [ "$count" -gt 1 ]; then
log $ERROR "Multiple instances of vault manager detected. Waiting until one left"
exit_on_trap 21
continue
fi
rm $WORKDIR/pods.txt
echo "" > "$PODREC_TMP_F"
exit_on_trap 11