Skip to content
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-container: support restarts #39717

Merged
merged 1 commit into from
May 2, 2018
Merged

Conversation

peterhoeg
Copy link
Member

Motivation for this change

I wanted to be able to restart a container.

Running the nixos/tests/container* tests doesn't complete as containers-restart_networking.nix fails but it also fails without this change.

Cc @globin @nh2

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Apr 30, 2018
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: nixos-container

Partial log (click to expand)

these derivations will be built:
  /nix/store/ycx9bqysf99vnmn9324almwc7jzxir16-nixos-container.drv
these paths will be fetched (0.02 MiB download, 0.08 MiB unpacked):
  /nix/store/33my3qwn5zjga3fqm39saf54g2sq1qz3-perl-File-Slurp-9999.19
  /nix/store/8i9gsrj67dj1w108lm77qxiy7pcks3n2-shadow-4.5-su
copying path '/nix/store/33my3qwn5zjga3fqm39saf54g2sq1qz3-perl-File-Slurp-9999.19' from 'https://cache.nixos.org'...
copying path '/nix/store/8i9gsrj67dj1w108lm77qxiy7pcks3n2-shadow-4.5-su' from 'https://cache.nixos.org'...
building '/nix/store/ycx9bqysf99vnmn9324almwc7jzxir16-nixos-container.drv'...
/nix/store/902ilix3n26vdw7740kg66q07vn9pl8c-nixos-container

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: nixos-container

Partial log (click to expand)

  /nix/store/hqkys198vq04dgsvbbshqk0lqs64i3w5-perl-File-Slurp-9999.19
  /nix/store/llq51xcbgkq4x27liim07dsrpcy5qqb8-util-linux-2.31.1-bin
  /nix/store/mn2zn6xwkr3zfvbdnqvh9h90cs5p3nc5-shadow-4.5
copying path '/nix/store/hqkys198vq04dgsvbbshqk0lqs64i3w5-perl-File-Slurp-9999.19' from 'https://cache.nixos.org'...
copying path '/nix/store/mn2zn6xwkr3zfvbdnqvh9h90cs5p3nc5-shadow-4.5' from 'https://cache.nixos.org'...
copying path '/nix/store/5p1gk02h3hw9kbmzhg489x8r2l42xqal-util-linux-2.31.1' from 'https://cache.nixos.org'...
copying path '/nix/store/g2kfnim2xpi3zxzmwqi2brlyiharb78a-shadow-4.5-su' from 'https://cache.nixos.org'...
copying path '/nix/store/llq51xcbgkq4x27liim07dsrpcy5qqb8-util-linux-2.31.1-bin' from 'https://cache.nixos.org'...
building '/nix/store/0gcjkb5s15q94xjml287dsp7v99x5zq4-nixos-container.drv'...
/nix/store/i41fi93jycjh5aypbydn48damrl88q6n-nixos-container

@xeji
Copy link
Contributor

xeji commented Apr 30, 2018

The containers-restart_networking.nix test has been failing for a while. I have yet to understand why...

@danbst
Copy link
Contributor

danbst commented May 1, 2018

Much thanks!
#16753

@peterhoeg
Copy link
Member Author

I don't foresee any issues with this, so I'll go ahead an merge it.

@peterhoeg peterhoeg merged commit 236a918 into NixOS:master May 2, 2018
@peterhoeg peterhoeg deleted the f/container branch May 2, 2018 07:33
danbst added a commit to danbst/nixpkgs that referenced this pull request Feb 15, 2020
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.
zhaofengli pushed a commit to zhaofengli/nixpkgs that referenced this pull request Mar 10, 2021
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.
zhaofengli pushed a commit to mars-research/nixpkgs that referenced this pull request Apr 14, 2021
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.
zhaofengli pushed a commit to zhaofengli/nixpkgs that referenced this pull request Apr 30, 2021
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.
donovanglover added a commit to donovanglover/nixpkgs that referenced this pull request Jul 20, 2023
The original pull request didn't add `restart` to the list of available
commands.

See: NixOS#39717
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 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants