mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Merge pull request #22441 from thockin/flake-22244-gce-static-ip
Check static IP postcondition if op fails
This commit is contained in:
commit
73479d5209
@ -333,9 +333,20 @@ function create-static-ip {
|
|||||||
local attempt=0
|
local attempt=0
|
||||||
local REGION="$2"
|
local REGION="$2"
|
||||||
while true; do
|
while true; do
|
||||||
if ! gcloud compute addresses create "$1" \
|
if gcloud compute addresses create "$1" \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--region "${REGION}" -q > /dev/null; then
|
--region "${REGION}" -q > /dev/null; then
|
||||||
|
# successful operation
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
if cloud compute addresses describe "$1" \
|
||||||
|
--project "${PROJECT}" \
|
||||||
|
--region "${REGION}" >/dev/null 2>&1; then
|
||||||
|
# it exists - postcondition satisfied
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
if (( attempt > 4 )); then
|
if (( attempt > 4 )); then
|
||||||
echo -e "${color_red}Failed to create static ip $1 ${color_norm}" >&2
|
echo -e "${color_red}Failed to create static ip $1 ${color_norm}" >&2
|
||||||
exit 2
|
exit 2
|
||||||
@ -343,9 +354,6 @@ function create-static-ip {
|
|||||||
attempt=$(($attempt+1))
|
attempt=$(($attempt+1))
|
||||||
echo -e "${color_yellow}Attempt $attempt failed to create static ip $1. Retrying.${color_norm}" >&2
|
echo -e "${color_yellow}Attempt $attempt failed to create static ip $1. Retrying.${color_norm}" >&2
|
||||||
sleep $(($attempt * 5))
|
sleep $(($attempt * 5))
|
||||||
else
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user