New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/containers: use machinectl poweroff #76719
Conversation
Previously, we were storing the leader pid in a runtime file and signalled SIGRTMIN+4 manually. In systemd 219, the `machinectl poweroff` command was introduced, which does that for us.
@GrahamcOfBorg build nixosTests.containers-bridge nixosTests.containers-ephemeral nixosTests.containers-extra_veth nixosTests.containers-hosts nixosTests.containers-imperative nixosTests.containers-ip nixosTests.containers-macvlans nixosTests.containers-physical_interfaces nixosTests.containers-physical_interfaces nixosTests.containers-portforward nixosTests.containers-restart_networking nixosTests.containers-tmpfs |
@GrahamcOfBorg test containers-bridge containers-ephemeral containers-extra_veth containers-hosts containers-ip containers-macvlans containers-physical_interfaces containers-portforward containers-restart_networking containers-tmpfs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
locally passes:
[nix-shell:~/.cache/nix-review/pr-76719]$ nix build -f ./nixpkgs/ nixosTests.containers-bridge nixosTests.containers-ephemeral nixosTests.containers-extra_veth nixosTests.containers-hosts nixosTests.containers-imperative nixosTests.containers-ip nixosTests.containers-macvlans nixosTests.containers-physical_interfaces nixosTests.containers-physical_interfaces nixosTests.containers-portforward nixosTests.containers-restart_networking nixosTests.containers-tmpfs
[754 built, 423 copied (1181.7 MiB), 237.6 MiB DL]
these passed locally, but failed on ofborg:
|
@GrahamcOfBorg test containers-hosts containers-macvlans |
It now succeeded on ofborg aswell, merging. |
I'm probably missing something, but why we wouldn't use the same configuration as in the upstream service file?
From my basic tests, the shutdown process seems the same. |
TBH, I'd like to see us moving to a state where we basically just use the upstream unit, and all the setup hackery became superfluous...
|
Fixes NixOS#43652 Fixes NixOS#16753 Alternative fix for NixOS#39717 The fix in NixOS#76719 was not enough `--keep-unit` ties systemd-nspawn container to systemd unit. When unit is restarted (ie atomic operation "restart", not two separate "stop" and "start") systemd assumes that unit didn't disappear. Hence machine won't disappear. If unit is stopped (or stopped due to failure), associated machine is also stopped, so service can start fresh. Resource slice isn't changed though - it is machine.slice by default for nspawn containers.
Fixes NixOS#43652 Fixes NixOS#16753 Alternative fix for NixOS#39717 The fix in NixOS#76719 was not enough `--keep-unit` ties systemd-nspawn container to systemd unit. When unit is restarted (ie atomic operation "restart", not two separate "stop" and "start") systemd assumes that unit didn't disappear. Hence machine won't disappear. If unit is stopped (or stopped due to failure), associated machine is also stopped, so service can start fresh. Resource slice isn't changed though - it is machine.slice by default for nspawn containers.
Fixes NixOS#43652 Fixes NixOS#16753 Alternative fix for NixOS#39717 The fix in NixOS#76719 was not enough `--keep-unit` ties systemd-nspawn container to systemd unit. When unit is restarted (ie atomic operation "restart", not two separate "stop" and "start") systemd assumes that unit didn't disappear. Hence machine won't disappear. If unit is stopped (or stopped due to failure), associated machine is also stopped, so service can start fresh. Resource slice isn't changed though - it is machine.slice by default for nspawn containers.
Fixes NixOS#43652 Fixes NixOS#16753 Alternative fix for NixOS#39717 The fix in NixOS#76719 was not enough `--keep-unit` ties systemd-nspawn container to systemd unit. When unit is restarted (ie atomic operation "restart", not two separate "stop" and "start") systemd assumes that unit didn't disappear. Hence machine won't disappear. If unit is stopped (or stopped due to failure), associated machine is also stopped, so service can start fresh. Resource slice isn't changed though - it is machine.slice by default for nspawn containers.
Fixes NixOS#43652 Fixes NixOS#16753 Alternative fix for NixOS#39717 The fix in NixOS#76719 was not enough `--keep-unit` ties systemd-nspawn container to systemd unit. When unit is restarted (ie atomic operation "restart", not two separate "stop" and "start") systemd assumes that unit didn't disappear. Hence machine won't disappear. If unit is stopped (or stopped due to failure), associated machine is also stopped, so service can start fresh. Resource slice isn't changed though - it is machine.slice by default for nspawn containers.
Previously, we were storing the leader pid in a runtime file and
signalled SIGRTMIN+4 manually.
In systemd 219, the
machinectl poweroff
command was introduced, whichdoes that for us.
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @arianvp