Skip to content

Commit

Permalink
tests/e2e: Wait for no restarts after deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Lukáš Doktor <[email protected]>
  • Loading branch information
ldoktor committed Dec 8, 2023
1 parent 002882b commit 6719bf4
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/e2e/operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,41 @@ uninstall_operator() {
fi
}


# Wait for no restarts in 3x20s (15s is the liveness probe)
#
wait_for_stabilization() {
declare -A restart_counts
iteration=0
count=0
while true; do
change=0
pod_info=$(kubectl get pods -n confidential-containers-system -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{range .status.containerStatuses[*]}{.name}{" "}{.restartCount}{"\n"}{end}{end}')

while read -r pod container restart_count; do
if [ "${restart_counts[$pod-$container]}" != "$restart_count" ]; then
echo "Pod: $pod, Container: $container, Restart count: $restart_count"
restart_counts["$pod-$container"]=$restart_count
change=1
fi
done <<< "$pod_info"

[ $change -eq 0 ] && ((iteration++))

if [ $iteration -gt 3 ]; then
echo "No new restarts in 3x20s, proceeding..."
break
elif [ $count -gt 20 ]; then
echo "ERROR: Pods are still restarting after 20x20s, bail out!"
exit 1
fi

((count++))
sleep 20
done
}


usage() {
cat <<-EOF
Utility to build/install/uninstall the operator.
Expand All @@ -281,6 +316,7 @@ main() {
install_operator
build_pre_install_img
install_ccruntime
wait_for_stabilization
else
case $1 in
-h|--help) usage && exit 0;;
Expand Down

0 comments on commit 6719bf4

Please sign in to comment.