mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #51533 from shyamjvs/master-creation-retry
Automatic merge from submit-queue Retry master instance creation in case of retriable error (with sleep) To help with our 5k-node CI tests failing to startup the cluster. And also towards the greater goal - https://github.com/kubernetes/kubernetes/issues/43140 cc @kubernetes/sig-scalability-misc @kubernetes/sig-cluster-lifecycle-misc
This commit is contained in:
commit
e3210c6ccf
@ -66,6 +66,7 @@ function replicate-master-instance() {
|
|||||||
|
|
||||||
function create-master-instance-internal() {
|
function create-master-instance-internal() {
|
||||||
local gcloud="gcloud"
|
local gcloud="gcloud"
|
||||||
|
local retries=5
|
||||||
if [[ "${ENABLE_IP_ALIASES:-}" == 'true' ]]; then
|
if [[ "${ENABLE_IP_ALIASES:-}" == 'true' ]]; then
|
||||||
gcloud="gcloud beta"
|
gcloud="gcloud beta"
|
||||||
fi
|
fi
|
||||||
@ -93,7 +94,8 @@ function create-master-instance-internal() {
|
|||||||
disk="${disk},boot=no"
|
disk="${disk},boot=no"
|
||||||
disk="${disk},auto-delete=no"
|
disk="${disk},auto-delete=no"
|
||||||
|
|
||||||
${gcloud} compute instances create "${master_name}" \
|
for attempt in $(seq 1 ${retries}); do
|
||||||
|
if result=$(${gcloud} compute instances create "${master_name}" \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--zone "${ZONE}" \
|
--zone "${ZONE}" \
|
||||||
--machine-type "${MASTER_SIZE}" \
|
--machine-type "${MASTER_SIZE}" \
|
||||||
@ -103,9 +105,23 @@ function create-master-instance-internal() {
|
|||||||
--scopes "storage-ro,compute-rw,monitoring,logging-write" \
|
--scopes "storage-ro,compute-rw,monitoring,logging-write" \
|
||||||
--metadata-from-file "${metadata}" \
|
--metadata-from-file "${metadata}" \
|
||||||
--disk "${disk}" \
|
--disk "${disk}" \
|
||||||
--boot-disk-size "${MASTER_ROOT_DISK_SIZE:-30}" \
|
--boot-disk-size "${MASTER_ROOT_DISK_SIZE}" \
|
||||||
${preemptible_master} \
|
${preemptible_master} \
|
||||||
${network}
|
${network} 2>&1); then
|
||||||
|
echo "${result}" >&2
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${result}" >&2
|
||||||
|
if [[ ! "${result}" =~ "try again later" ]]; then
|
||||||
|
echo "Failed to create master instance due to non-retryable error" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sleep 10
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Failed to create master instance despite ${retries} attempts" >&2
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-metadata() {
|
function get-metadata() {
|
||||||
|
@ -75,6 +75,7 @@ function replicate-master-instance() {
|
|||||||
|
|
||||||
function create-master-instance-internal() {
|
function create-master-instance-internal() {
|
||||||
local gcloud="gcloud"
|
local gcloud="gcloud"
|
||||||
|
local retries=5
|
||||||
if [[ "${ENABLE_IP_ALIASES:-}" == 'true' ]]; then
|
if [[ "${ENABLE_IP_ALIASES:-}" == 'true' ]]; then
|
||||||
gcloud="gcloud beta"
|
gcloud="gcloud beta"
|
||||||
fi
|
fi
|
||||||
@ -106,7 +107,8 @@ function create-master-instance-internal() {
|
|||||||
disk="${disk},boot=no"
|
disk="${disk},boot=no"
|
||||||
disk="${disk},auto-delete=no"
|
disk="${disk},auto-delete=no"
|
||||||
|
|
||||||
${gcloud} compute instances create "${master_name}" \
|
for attempt in $(seq 1 ${retries}); do
|
||||||
|
if result=$(${gcloud} compute instances create "${master_name}" \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--zone "${ZONE}" \
|
--zone "${ZONE}" \
|
||||||
--machine-type "${MASTER_SIZE}" \
|
--machine-type "${MASTER_SIZE}" \
|
||||||
@ -118,7 +120,21 @@ function create-master-instance-internal() {
|
|||||||
--disk "${disk}" \
|
--disk "${disk}" \
|
||||||
--boot-disk-size "${MASTER_ROOT_DISK_SIZE}" \
|
--boot-disk-size "${MASTER_ROOT_DISK_SIZE}" \
|
||||||
${preemptible_master} \
|
${preemptible_master} \
|
||||||
${network}
|
${network} 2>&1); then
|
||||||
|
echo "${result}" >&2
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${result}" >&2
|
||||||
|
if [[ ! "${result}" =~ "try again later" ]]; then
|
||||||
|
echo "Failed to create master instance due to non-retryable error" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sleep 10
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Failed to create master instance despite ${retries} attempts" >&2
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-metadata() {
|
function get-metadata() {
|
||||||
|
Loading…
Reference in New Issue
Block a user