Skip to content

Commit

Permalink
Retry object creation with --validate in kube-addons
Browse files Browse the repository at this point in the history
The better solution is some fence with Salt, but the actual logs
provided in the bug don't support any race condition here, plus the
ordering in the Salt configuration seems correct.

We haven't seen this again in a while, but given the results of the
situation (a borked cluster), I'm proposing a relatively simple
workaround.

Fixes kubernetes#4357 (dubiously)
  • Loading branch information
zmerlynn committed Mar 11, 2015
1 parent 1231e65 commit 018b11b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cluster/saltbase/salt/kube-addons/kube-addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@
# 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) =="
KUBECTL=/usr/local/bin/kubectl

function create-object() {
obj=$1

for tries in {1..5}; do
if ${KUBECTL} --server="127.0.0.1:8080" create --validate=true -f ${obj}; then
return
fi
echo "++ ${obj} failed, attempt ${try} (sleeping 5) ++"
sleep 5
done
}

echo "== Kubernetes addon manager started at $(date -Is) =="
for obj in $(find /etc/kubernetes/addons -name \*.yaml); do
${KUBECTL} --server="127.0.0.1:8080" create -f ${obj} &
create-object ${obj} &
echo "++ addon ${obj} started in pid $! ++"
done
noerrors="true"
Expand Down

0 comments on commit 018b11b

Please sign in to comment.