Skip to content

Commit

Permalink
data/bootstrap: retry when reporting progress
Browse files Browse the repository at this point in the history
Previously, report-progress.sh relied on systemd to perform its retry
logic. Unfortunately, this causes the logs to fill up with entries like
the following:

    systemd[1]: progress.service holdoff time over, scheduling restart.
    systemd[1]: Stopped Report the completion of the cluster bootstrap
                process.
    systemd[1]: Starting Report the completion of the cluster bootstrap
                process...
    systemd[1]: Stopped Report the completion of the cluster bootstrap
    systemd[1]: progress.service: control process exited, code=exited
                status=1
    systemd[1]: Failed to start Report the completion of the cluster
                bootstrap process.
    systemd[1]: Unit progress.service entered failed state.
    systemd[1]: progress.service failed.

By adding the retry logic to report-progress.sh, these verbose logs are
avoided.
  • Loading branch information
crawford committed Jan 18, 2019
1 parent 4016f5f commit 3aae55e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
48 changes: 30 additions & 18 deletions data/data/bootstrap/files/usr/local/bin/report-progress.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
#!/usr/bin/env bash
set -e

KUBECONFIG="${1}"
NAME="${2}"
MESSAGE="${3}"
TIMESTAMP="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

echo "Reporting install progress..."
wait_for_existance() {
while [ ! -e "${1}" ]
do
sleep 5
done
}

echo "Waiting for bootstrap to complete..."
wait_for_existance /opt/openshift/.bootkube.done
wait_for_existance /opt/openshift/.openshift.done

oc --config="$KUBECONFIG" create -f - <<EOF
apiVersion: v1
kind: Event
metadata:
name: "${NAME}"
namespace: kube-system
involvedObject:
namespace: kube-system
message: "${MESSAGE}"
firstTimestamp: "${TIMESTAMP}"
lastTimestamp: "${TIMESTAMP}"
count: 1
source:
component: cluster
host: $(hostname)
echo "Reporting install progress..."
timestamp="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
while ! oc --config="$KUBECONFIG" create -f - <<-EOF
apiVersion: v1
kind: Event
metadata:
name: "${NAME}"
namespace: kube-system
involvedObject:
namespace: kube-system
message: "${MESSAGE}"
firstTimestamp: "${timestamp}"
lastTimestamp: "${timestamp}"
count: 1
source:
component: cluster
host: $(hostname)
EOF
do
sleep 5
done
3 changes: 0 additions & 3 deletions data/data/bootstrap/systemd/units/progress.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Wants=bootkube.service openshift.service
After=bootkube.service openshift.service

[Service]
# Workaround for https://github.com/systemd/systemd/issues/1312 and https://github.com/opencontainers/runc/pull/1807
ExecStartPre=/usr/bin/test -f /opt/openshift/.bootkube.done
ExecStartPre=/usr/bin/test -f /opt/openshift/.openshift.done
ExecStart=/usr/local/bin/report-progress.sh /opt/openshift/auth/kubeconfig bootstrap-complete "cluster bootstrapping has completed"

Restart=on-failure
Expand Down

0 comments on commit 3aae55e

Please sign in to comment.