mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #6200 from ArtfulCoder/retry_addon_creation
Retry kube-addons creation if kube-addons creation fails.
This commit is contained in:
commit
a68f4fa19c
@ -26,14 +26,32 @@ KUBECTL=/usr/local/bin/kubectl
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# $1 addon to start.
|
||||
# $2 count of tries to start the addon.
|
||||
# $3 delay in seconds between two consecutive tries
|
||||
function start_addon() {
|
||||
addon=$1;
|
||||
tries=$2;
|
||||
delay=$3;
|
||||
while [ ${tries} -gt 0 ]; do
|
||||
${KUBECTL} create -f ${addon} && \
|
||||
echo "== Successfully started ${addon} at $(date -Is)" && \
|
||||
return 0;
|
||||
let tries=tries-1;
|
||||
echo "== Failed to start ${addon} at $(date -Is). ${tries} tries remaining. =="
|
||||
sleep ${delay};
|
||||
done
|
||||
return 1;
|
||||
}
|
||||
|
||||
function addon_manager_async() {
|
||||
# The business logic for whether a given object should be created
|
||||
# was already enforced by salt, and /etc/kubernetes/addons is the
|
||||
# managed result is of that. Start everything below that directory.
|
||||
echo "== Kubernetes addon manager started at $(date -Is) =="
|
||||
for obj in $(find /etc/kubernetes/addons -name \*.yaml); do
|
||||
${KUBECTL} create -f ${obj} &
|
||||
echo "++ addon ${obj} started in pid $! ++"
|
||||
start_addon ${obj} 100 10 &
|
||||
echo "++ addon ${obj} starting in pid $! ++"
|
||||
done
|
||||
noerrors="true"
|
||||
for pid in $(jobs -p); do
|
||||
@ -52,6 +70,7 @@ function addon_manager_async() {
|
||||
sleep infinity
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user