Skip to content

Commit 9231442

Browse files
committed
bootstrap-in-place-post-reboot.sh improvments:
* Add few echo stating what the script is currently doing * Update sleep durations * Use [*] and not [0] in the jsonpath when checking the kube-apiserver-operator status because the pod may not exists yet * Remove /opt/openshift at the end of the installation, it was added during openshift#6649 and it should get cleaned up once the installation is complete * Check if api is available while waiting for kube-apiserver-operator ready status
1 parent 3f2855a commit 9231442

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

data/data/bootstrap/bootstrap-in-place/files/opt/openshift/bootstrap-in-place/bootstrap-in-place-post-reboot.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ function signal_bootstrap_complete {
2525
}
2626

2727
function restart_kubelet {
28-
echo "Restarting kubelet"
29-
until [ "$(oc get pod -n openshift-kube-apiserver-operator --selector='app=kube-apiserver-operator' -o jsonpath='{.items[0].status.conditions[?(@.type=="Ready")].status}' | grep -c "True")" -eq 1 ];
28+
echo "Waiting for kube-apiserver-operator"
29+
until [ "$(oc get pod -n openshift-kube-apiserver-operator --selector='app=kube-apiserver-operator' -o jsonpath='{.items[*].status.conditions[?(@.type=="Ready")].status}' | grep -c "True")" -eq 1 ];
3030
do
3131
echo "Waiting for kube-apiserver-operator ready condition to be True"
32+
oc get --raw='/readyz' &> /dev/null || echo "Api is not available"
3233
sleep 10
3334
done
35+
36+
echo "Restarting kubelet"
3437
# daemon-reload is required because /etc/systemd/system/kubelet.service.d/20-nodenet.conf is added after kubelet started
3538
systemctl daemon-reload
3639
systemctl restart kubelet
@@ -40,26 +43,31 @@ function restart_kubelet {
4043
echo "Waiting for kube-apiserver to apply the new static pod configuration"
4144
sleep 10
4245
done
46+
47+
echo "Restarting kubelet"
4348
systemctl restart kubelet
4449
}
4550

4651
function approve_csr {
47-
echo "Approving csrs ..."
52+
echo "Waiting for node to report ready status"
4853
# use [*] and not [0] in the jsonpath because the node resource may not have been created yet
4954
until [ "$(oc get nodes --selector='node-role.kubernetes.io/master' -o jsonpath='{.items[*].status.conditions[?(@.type=="Ready")].status}' | grep -c "True")" -eq 1 ];
5055
do
5156
echo "Approving csrs ..."
5257
oc get csr -o go-template='{{range .items}}{{if not .status}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}' | xargs --no-run-if-empty oc adm certificate approve &> /dev/null || true
53-
sleep 30
58+
sleep 10
5459
done
60+
echo "node is ready"
5561
}
5662

5763
function wait_for_cvo {
5864
echo "Waiting for cvo"
59-
until [ "$(oc get clusterversion -o jsonpath='{.items[0].status.conditions[?(@.type=="Available")].status}')" == "True" ];
65+
until [ "$(oc get clusterversion -o jsonpath='{.items[*].status.conditions[?(@.type=="Available")].status}')" == "True" ];
6066
do
6167
echo "Still waiting for cvo ..."
62-
sleep 30
68+
# print the not ready operators names and message
69+
oc get clusteroperator -o jsonpath='{range .items[*]}{@.metadata.name}: {range @.status.conditions[?(@.type=="Available")]}{@.type}={@.status} {@.message}{"\n"}{end}{end}' | grep -v "Available=True" || true
70+
sleep 20
6371
done
6472
}
6573

@@ -83,6 +91,7 @@ function clean {
8391
rm -rf /usr/local/bin/installer-gather.sh
8492
rm -rf /usr/local/bin/installer-masters-gather.sh
8593
rm -rf /var/log/log-bundle-bootstrap.tar.gz
94+
rm -rf /opt/openshift
8695

8796
systemctl disable bootkube.service
8897
}

0 commit comments

Comments
 (0)