From c26a21c55a4ef9fa136fddc68ac748ba8de3840e Mon Sep 17 00:00:00 2001 From: Steeve Goveas Date: Tue, 27 Aug 2024 19:10:51 +0100 Subject: [PATCH] Avoid infinite loop for node power off (#79) Update block to retry 14 times every 30 seconds and then exit Related to: https://github.com/openshift/release/pull/55817 --- .../root/usr/bin/prepare_host_for_boot | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/images/fcos-bastion-image/root/usr/bin/prepare_host_for_boot b/images/fcos-bastion-image/root/usr/bin/prepare_host_for_boot index f92e061..8ab8ed7 100755 --- a/images/fcos-bastion-image/root/usr/bin/prepare_host_for_boot +++ b/images/fcos-bastion-image/root/usr/bin/prepare_host_for_boot @@ -35,10 +35,19 @@ function ipmi_cmd() { } log "Powering off the host..." -until ipmi_cmd power status | grep -i -q "Chassis Power is off"; do - log "Host is powered on: forcing power off..." - ipmi_cmd power off || true - sleep 30 +for i in {1..16}; do + if [ "${i}" -eq 16 ]; then + log "Exiting after $((i - 1)) retries" + exit 1 + fi + if ! ipmi_cmd power status | grep -i -q "Chassis Power is off"; then + log "Attemp ${i}: Host is powered on: forcing power off..." + ipmi_cmd power off || true + sleep 30 + else + log "Attemp ${i}: Host is powered off" + break + fi done if [[ "${ipxe_via_vmedia}" == "true" ]] && [[ "${BOOT_MODE}" == "pxe" ]]; then