Skip to content

Commit

Permalink
Add retries to SDN's RBAC proxy
Browse files Browse the repository at this point in the history
Because kube-proxy may not be initialized by the time the RBAC proxy
starts it may crashloop for a while. Doesn't have any actual impact but
the restarts show in oc get pod and people may worry about that.
  • Loading branch information
Juan-Luis de Sousa-Valadas Castaño committed Sep 10, 2020
1 parent 7576007 commit 9b6c5df
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bindata/network/openshift-sdn/sdn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,20 @@ spec:
# As the secret mount is optional we must wait for the files to be present.
# The service is created in monitor.yaml and this is created in sdn.yaml.
# If it isn't created there is probably an issue so we want to crashloop.
TS=$(curl \
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
-H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
"https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/api/v1/namespaces/openshift-sdn/services/sdn" |
python -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["creationTimestamp"])'
)
retries=0
until [ "$retries" -ge 20 ]
do
TS=$(curl -s \
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
-H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
"https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/api/v1/namespaces/openshift-sdn/services/sdn" |
python -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["creationTimestamp"])' &&
break ||
echo "Failed to get sdn service from API"
)
retries=$(( retries + 1 ))
sleep 15
done
TS=$(date -d "${TS}" +%s)
WARN_TS=$(( ${TS} + $(( 20 * 60)) ))
Expand Down

0 comments on commit 9b6c5df

Please sign in to comment.