salt -C 'cmp*' state.apply linux.system
salt -C 'cmp*' state.apply linux.network || true
salt -C 'kvm* or cmp*' system.reboot
-wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
- "tee /dev/stderr | grep -Fq 'Not connected'"
+wait_for 90.0 "salt -C 'kvm* or cmp*' test.ping"
salt -C 'kvm* or cmp*' state.apply linux,ntp
salt -C 'kvm* or cmp*' pkg.upgrade refresh=False
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
salt -I 'nova:compute' system.reboot
-wait_for 90 "! salt -I 'nova:compute' test.ping | " \
- "tee /dev/stderr | grep -Fq 'Not connected'"
+wait_for 90.0 "salt -I 'nova:compute' test.ping"
salt -I 'nova:compute' alternatives.set ovs-vswitchd /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk
salt -I 'nova:compute' service.restart openvswitch-switch
((attempt+=1))
done
-wait_for 10 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
+wait_for 10.0 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
fi
# KVM libvirt first, VCP deployment
-wait_for 5 "salt -C 'kvm*' state.sls libvirt"
+wait_for 5.0 "salt -C 'kvm*' state.sls libvirt"
salt -C 'kvm* or cmp*' state.apply salt
-wait_for 10 "! salt -C 'kvm*' state.sls salt.control | " \
- "tee /dev/stderr | grep -Fq 'Not connected'"
+wait_for 10.0 "salt -C 'kvm*' state.sls salt.control"
vcp_nodes=$(salt --out yaml 'kvm01*' pillar.get salt:control:cluster:internal:node | \
awk '/\s+\w+:$/ {gsub(/:$/, "*"); print $1}')
((attempt+=1))
done
-wait_for 10 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
+wait_for 10.0 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
# Propagate APT proxy config created by curtin on baremetal nodes to VCP VMs
APT_CONF_D_CURTIN='/etc/apt/apt.conf.d/90curtin-aptproxy'
wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply salt"
wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' service.force_reload salt-minion"
-wait_for 10 "! salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp | " \
- "tee /dev/stderr | grep -Eq '(Not connected|No response)'"
+wait_for 10.0 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp"
wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \
$(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")"
salt -C 'prx*' file.write /etc/dhcp/dhclient-enter-hooks.d/no-default-route \
args='unset new_routers'
salt -C 'prx*' system.reboot
-wait_for 30 "! salt -C 'prx*' test.ping | " \
- "tee /dev/stderr | grep -Fq 'Not connected'"
+wait_for 30.0 "salt -C 'prx*' test.ping"
salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' pkg.upgrade refresh=False
local total_attempts=$1; shift
local cmdstr=$*
local sleep_time=10
- echo "[NOTE] Waiting for cmd to return success: ${cmdstr}"
+ echo "[wait_for] Waiting for cmd to return success: ${cmdstr}"
# shellcheck disable=SC2034
for attempt in $(seq "${total_attempts}"); do
- # shellcheck disable=SC2015
- eval "${cmdstr}" && return 0 || true
+ echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
+ if [ "${total_attempts%.*}" = "${total_attempts}" ]; then
+ # shellcheck disable=SC2015
+ eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
+ else
+ ( eval "${cmdstr}" || echo __fuel_wf_failure__ ) |& tee /dev/stderr | \
+ grep -Eq '(Not connected|No response|__fuel_wf_failure__)' || \
+ echo "[wait_for] OK: ${cmdstr}" && return 0
+ fi
echo -n '.'; sleep "${sleep_time}"
done
+ echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"
return 1
)
}