Merge pull request 'machines: minor refactor of update' (#3301) from push-swpwpzmlspko into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3301
This commit is contained in:
Michael Hoang
2025-04-13 16:24:10 +00:00

View File

@@ -180,23 +180,16 @@ def deploy_machines(machines: list[Machine]) -> None:
if is_async_cancelled():
return
# if the machine is mobile, we retry to deploy with the mobile workaround method
# retry nixos-rebuild switch if the first attempt failed
if ret.returncode != 0:
is_mobile = machine.deployment.get("nixosMobileWorkaround", False)
if is_mobile and ret.returncode != 0:
# if the machine is mobile, we retry to deploy with the mobile workaround method
if is_mobile:
machine.info(
"Mobile machine detected, applying workaround deployment method"
)
ret = host.run(
test_cmd,
RunOpts(msg_color=MsgColor(stderr=AnsiColor.DEFAULT)),
extra_env=env,
become_root=True,
)
# retry nixos-rebuild switch if the first attempt failed
elif ret.returncode != 0:
ret = host.run(
switch_cmd,
test_cmd if is_mobile else switch_cmd,
RunOpts(msg_color=MsgColor(stderr=AnsiColor.DEFAULT)),
extra_env=env,
become_root=True,