Skip to content

Restart declarative containers when their host environment configuration changes #62779

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

Merged
merged 2 commits into from
Jun 6, 2019

Conversation

grahamc
Copy link
Member

@grahamc grahamc commented Jun 6, 2019

Motivation for this change

Changing network interfaces or bind mounts on NixOS containers requires a full restart of the container. However, with the prior version, this relationship was not properly represented and only a reload would occur:

ogden.......> reloading the following units: container@buildkite-builder-grahamc-1.service, container@buildkite-builder-grahamc-10.service, container@buildkite-builder-grahamc-2.service, container@buildkite-builder-grahamc-3.service, container@buildkite-builder-grahamc-4.service, container@buildkite-builder-grahamc-5.service, container@buildkite-builder-grahamc-6.service, container@buildkite-builder-grahamc-7.service, container@buildkite-builder-grahamc-8.service, container@buildkite-builder-grahamc-9.service, dbus.service

This is not sufficient and doesn't completely update the container.

After this change, it properly starts and stops the container when the bind mounts change:

ogden.......> updating GRUB 2 menu...
ogden.......> stopping the following units: container@buildkite-builder-grahamc-1.service, container@buildkite-builder-grahamc-10.service, container@buildkite-builder-grahamc-2.service, container@buildkite-builder-grahamc-3.service, container@buildkite-builder-grahamc-4.service, container@buildkite-builder-grahamc-5.service, container@buildkite-builder-grahamc-6.service, container@buildkite-builder-grahamc-7.service, container@buildkite-builder-grahamc-8.service, container@buildkite-builder-grahamc-9.service
ogden.......> activating the configuration...
ogden.......> setting up /etc...
ogden.......> reloading user units for root...
ogden.......> reloading user units for grahamc...
ogden.......> setting up tmpfiles
ogden.......> starting the following units: container@buildkite-builder-grahamc-1.service, container@buildkite-builder-grahamc-10.service, container@buildkite-builder-grahamc-2.service, container@buildkite-builder-grahamc-3.service, container@buildkite-builder-grahamc-4.service, container@buildkite-builder-grahamc-5.service, container@buildkite-builder-grahamc-6.service, container@buildkite-builder-grahamc-7.service, container@buildkite-builder-grahamc-8.service, container@buildkite-builder-grahamc-9.service
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Test results:

$ nix-build ./nixos/tests/containers*; echo $?
/nix/store/rkjnxm7qkd8yx7drjprl5hc4bbipkqzp-vm-test-run-containers-bridge
/nix/store/y4q6ffsf21gi452wv90a713ac8khmfcf-vm-test-run-containers-bridge
/nix/store/3kf7f6574dk4d6ph2pzgv0i4090h0vjq-vm-test-run-containers-hosts
/nix/store/mcxwmk3na4mjw2a4a54f63jfkfxwh9dx-vm-test-run-containers-imperative
/nix/store/y738p0y84v98qm49l6pi90z8fj87i47z-vm-test-run-containers-ipv4
/nix/store/ishfl5njzdpxkql11dvs8ha904wlcz3f-vm-test-run-containers-ipv6
/nix/store/hfwdd79brbdp0w449lhy44ibxlh9brhz-vm-test-run-containers-macvlans
/nix/store/yigbf08mza360l668ambakmx6lndlnnk-vm-test-run-containers-physical_interfaces
/nix/store/fwy1mdh0sfkh0887pc2q3bh92f6k8n1b-vm-test-run-containers-portforward
/nix/store/aaiv2vzsiz6bpvrg1n53ngj4x224pz8d-vm-test-run-cotnainers-reloadable
/nix/store/ak44x378g17z6v19a8maph77qqwi9mqh-vm-test-run-containers-restart_networking
/nix/store/c8g5v6j335mkjiygch1f8i281wmqhxnh-vm-test-run-containers-tmpfs

Sorry, something went wrong.

grahamc added 2 commits June 6, 2019 11:57

Verified

This commit was signed with the committer’s verified signature. The key has expired.
LnL7 Daiderd Jordan
@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jun 6, 2019
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 6, 2019
@grahamc grahamc merged commit 9d11c30 into NixOS:master Jun 6, 2019
@grahamc grahamc deleted the containers-restart branch June 6, 2019 16:57
@flokli
Copy link
Contributor

flokli commented Mar 12, 2020

This probably should have had some release notes btw ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants