Skip to content

Commit a0e9d75

Browse files
committed
Refactor upgrade options
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent f533c3c commit a0e9d75

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

talos-bootstrap

+16-9
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,22 @@ talosctl gen config "${cluster_name}" "${k8s_endpoint}" --with-secrets=secrets.y
416416
# Screen: Select upgrade option
417417
if [ "$OP" = upgrade ]; then
418418
upgrade_option=$(dialog --keep-tite --title talos-bootstrap --menu "Select upgrade option" 0 0 0 \
419-
1 "apply config and perform upgrade" \
420-
2 "apply config and perform upgrade (with preserve option)" \
421-
3 "apply config on live and skip upgrade" 3>&1 1>&2 2>&3) || exit 0
419+
1 "apply config on live and skip upgrade" \
420+
2 "apply config and perform upgrade (mode: default)" \
421+
3 "apply config and perform upgrade (mode: powercycle)" \
422+
4 "apply config and perform upgrade with force (mode: default)" \
423+
5 "apply config and perform upgrade with force (mode: powercycle)" \
424+
6 "apply config and schedule upgrade to perform it after a reboot" 3>&1 1>&2 2>&3) || exit 0
422425
423426
should_upgrade=1
427+
upgrade_opt=""
424428
case ${upgrade_option} in
425-
1) preserve_opt="--preserve" ;;
426-
2) preserve_opt="" ;;
427-
3) should_upgrade="0" ;;
429+
1) should_upgrade=0 ;;
430+
3) upgrade_opt="--reboot-mode default" ;;
431+
3) upgrade_opt="--reboot-mode powercycle" ;;
432+
4) upgrade_opt="--force --reboot-mode default" ;;
433+
4) upgrade_opt="--force --reboot-mode powercycle" ;;
434+
6) upgrade_opt="--stage" ;;
428435
esac
429436
fi
430437
@@ -443,7 +450,7 @@ talosctl apply -e "${bootstrap_ip}" -n "${bootstrap_ip}" -f "${role}.yaml" ${OPT
443450
if [ "$OP" = upgrade ] && [ "${should_upgrade}" = 1 ]; then
444451
image=$(talosctl -e "${node}" -n "${node}" get machineconfig -o jsonpath="{.spec.machine.install.image}" ${OPTS})
445452
printf "%s\nXXX\n%s\n%s\nXXX\n" "10" "Scheduling upgrade..." "(image: $image)"
446-
talosctl -e "${node}" -n "${node}" upgrade ${preserve_opt} -i "${image}" --wait=false ${OPTS} || exit $?
453+
talosctl -e "${node}" -n "${node}" upgrade ${upgrade_opt} -i "${image}" --wait=false ${OPTS} || exit $?
447454
fi
448455
449456
if [ "$OP" = upgrade ]; then
@@ -460,7 +467,7 @@ talosctl apply -e "${bootstrap_ip}" -n "${bootstrap_ip}" -f "${role}.yaml" ${OPT
460467
sleep 0.2
461468
if [ "${new_is_pingable}" = 0 ]; then
462469
if [ "${old_is_up}" = 1 ]; then
463-
status=$(timeout 1 talosctl --talosconfig=talosconfig -e "${node}" -n "${node}" get machinestatus ${OPTS} -o jsonpath={.spec.stage}) 2>&1
470+
status=$(timeout 3 talosctl --talosconfig=talosconfig -e "${node}" -n "${node}" get machinestatus ${OPTS} -o jsonpath={.spec.stage} 2>/dev/null)
464471
if [ $? = 124 ]; then
465472
old_is_up=0
466473
fi
@@ -482,7 +489,7 @@ talosctl apply -e "${bootstrap_ip}" -n "${bootstrap_ip}" -f "${role}.yaml" ${OPT
482489
fi
483490
fi
484491
485-
if timeout 1 talosctl --talosconfig=talosconfig -e "${node}" -n "${node}" get machinestatus >/dev/null 2>&1; then
492+
if timeout 3 talosctl --talosconfig=talosconfig -e "${node}" -n "${node}" get machinestatus >/dev/null 2>&1; then
486493
new_is_up=1
487494
fi
488495

0 commit comments

Comments
 (0)