Skip to content

Commit

Permalink
modules/tectonic/resources: make tectonic scripts POSIX (coreos#1497)
Browse files Browse the repository at this point in the history
This commit makes the tectonic.sh script POSIX compliant. This is
necessary because the k8s base image for hyperkube will no longer have
bash installed once kubernetes/kubernetes#48365
lands, so bash-specific syntax will cause cluster bootstrapping to fail.
  • Loading branch information
squat authored and zbwright committed Jul 27, 2017
1 parent 2012722 commit 9218cb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion modules/tectonic/resources/tectonic-rkt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
${hyperkube_image} \
--net=host \
--dns=host \
--exec=/bin/bash -- /assets/tectonic.sh /assets/auth/kubeconfig /assets ${experimental}
--exec=/bin/sh -- /assets/tectonic.sh /assets/auth/kubeconfig /assets ${experimental}
23 changes: 12 additions & 11 deletions modules/tectonic/resources/tectonic.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -e

if [ "$#" -ne "3" ]; then
Expand All @@ -15,19 +15,20 @@ KUBECTL="/kubectl --kubeconfig=$KUBECONFIG"

# Setup helper functions

function kubectl() {
local i=0
kubectl() {
i=0

echo "Executing kubectl" "$@"
while true; do
(( i++ )) && (( i == 100 )) && echo "kubectl failed, giving up" && exit 1
i=$((i+1))
[ $i -eq 100 ] && echo "kubectl failed, giving up" && exit 1

set +e
out=$($KUBECTL "$@" 2>&1)
status=$?
set -e

if [[ "$out" == *"AlreadyExists"* ]]; then
if echo "$out" | grep -q "AlreadyExists"; then
echo "$out, skipping"
return
fi
Expand All @@ -42,20 +43,20 @@ function kubectl() {
done
}

function wait_for_tpr() {
wait_for_tpr() {
set +e
local i=0
i=0

echo "Waiting for TPR $2"
until $KUBECTL -n "$1" get thirdpartyresources "$2"; do
(( i++ ))
i=$((i+1))
echo "TPR $2 not available yet, retrying in 5 seconds ($i)"
sleep 5
done
set -e
}

function wait_for_pods() {
wait_for_pods() {
set +e
echo "Waiting for pods in namespace $1"
while true; do
Expand All @@ -78,7 +79,7 @@ function wait_for_pods() {
fi

stat=$(echo "$out"| tail -n +2 | grep -v '^Running')
if [[ "$stat" == "" ]]; then
if [ -z "$stat" ]; then
return
fi

Expand All @@ -96,7 +97,7 @@ set +e
i=0
echo "Waiting for Kubernetes API..."
until $KUBECTL cluster-info; do
(( i++ ))
i=$((i+1))
echo "Cluster not available yet, waiting for 5 seconds ($i)"
sleep 5
done
Expand Down

0 comments on commit 9218cb3

Please sign in to comment.