From ee7f05752237147b6e9e513a52a874b0692ab687 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Sun, 24 May 2020 19:46:22 -0700 Subject: [PATCH 1/2] deployment: add --boot flag to deploy subcommand This is similar to running `nixos-rebuild boot`, just as `nixops deploy --test` is similar to running `nixos-rebuild test`. The flag creates a new config and sets it as the default to boot into, but doesn't switch to it right away. --- nixops/__main__.py | 5 +++++ nixops/deployment.py | 6 +++++- nixops/script_defs.py | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nixops/__main__.py b/nixops/__main__.py index 7213525d4..905a8ac34 100755 --- a/nixops/__main__.py +++ b/nixops/__main__.py @@ -209,6 +209,11 @@ def hook(_type: Type[BaseException], value: BaseException, tb: TracebackType): action="store_true", help="build and activate the new configuration; do not enable it in the bootloader. Rebooting the system will roll back automatically.", ) +subparser.add_argument( + "--boot", + action="store_true", + help="build the new configuration and enable it in the bootloader; do not activate it. Upon reboot, the system will use the new configuration.", +) subparser.add_argument( "--repair", action="store_true", help="use --repair when calling nix-build (slow)" ) diff --git a/nixops/deployment.py b/nixops/deployment.py index 5bf28d1ea..075546bc2 100644 --- a/nixops/deployment.py +++ b/nixops/deployment.py @@ -860,6 +860,7 @@ def activate_configs( # noqa: C901 always_activate: bool, dry_activate: bool, test: bool, + boot: bool, max_concurrent_activate: int, ) -> None: """Activate the new configuration on a machine.""" @@ -902,7 +903,7 @@ def set_profile(): m.send_keys() - if force_reboot or m.state == m.RESCUE: + if boot or force_reboot or m.state == m.RESCUE: switch_method = "boot" elif dry_activate: switch_method = "dry-activate" @@ -1144,6 +1145,7 @@ def _deploy( # noqa: C901 self, dry_run: bool = False, test: bool = False, + boot: bool = False, plan_only: bool = False, build_only: bool = False, create_only: bool = False, @@ -1321,6 +1323,7 @@ def worker(r: nixops.resources.GenericResourceState): always_activate=always_activate, dry_activate=dry_activate, test=test, + boot=boot, max_concurrent_activate=max_concurrent_activate, ) @@ -1449,6 +1452,7 @@ def _rollback( always_activate=True, dry_activate=False, test=False, + boot=False, max_concurrent_activate=max_concurrent_activate, ) diff --git a/nixops/script_defs.py b/nixops/script_defs.py index d87a7b109..e0e60de72 100644 --- a/nixops/script_defs.py +++ b/nixops/script_defs.py @@ -588,6 +588,7 @@ def op_deploy(args): depl.deploy( dry_run=args.dry_run, test=args.test, + boot=args.boot, build_only=args.build_only, plan_only=args.plan_only, create_only=args.create_only, From 9ec1efc39f897a9cd93d6fdfc76fa2b7f7b623d6 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Sun, 24 May 2020 19:51:10 -0700 Subject: [PATCH 2/2] mypy-ratchet.sh: use printf instead of echo `%s` has no special meaning to echo. --- ci/mypy-ratchet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/mypy-ratchet.sh b/ci/mypy-ratchet.sh index 1e7f16491..0d6c00d50 100755 --- a/ci/mypy-ratchet.sh +++ b/ci/mypy-ratchet.sh @@ -17,7 +17,7 @@ base=origin/${GITHUB_BASE_REF:-master} git fetch origin -echo "Checking base branch at %s, then PR at %s...\n" "$base" "$head" +printf "Checking base branch at %s, then PR at %s...\n" "$base" "$head" git checkout "$base" nix-shell shell.nix --run "$scratch/run-ratchet.sh $scratch base"