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/switch-to-configuration: Improve socket and timer handling, clean up, minor fixes, add test #141192

Merged
merged 14 commits into from
Oct 18, 2021

Conversation

dasJ
Copy link
Member

@dasJ dasJ commented Oct 10, 2021

Motivation for this change

This is the second attempt to restart sockets properly.
The last time people were not completely happy so I kind of went over the top here.

cc @alyssais to make sure I don't break cross again
cc @grahamc maybe you could take a look at the Perl if you find time

Fixes #74899
Closes #33661

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) → switch-test.nix
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Oct 10, 2021
@dasJ dasJ changed the title Feat/improved socket handling2 nixos/switch-to-configuration: Improve socket handling and add test Oct 10, 2021
@dasJ dasJ changed the title nixos/switch-to-configuration: Improve socket handling and add test nixos/switch-to-configuration: Improve socket handling, clean up, minor fixes, add test Oct 10, 2021
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Oct 10, 2021
@dasJ
Copy link
Member Author

dasJ commented Oct 10, 2021

@GrahamcOfBorg test switchTest

@domenkozar
Copy link
Member

Ohh, does this fix #74899

@dasJ
Copy link
Member Author

dasJ commented Oct 10, 2021

Umm presumably. I didn't know there was an issue for that 😄

@dasJ dasJ force-pushed the feat/improved-socket-handling2 branch 2 times, most recently from 9e5043b to bcea817 Compare October 13, 2021 17:44
@dasJ dasJ changed the title nixos/switch-to-configuration: Improve socket handling, clean up, minor fixes, add test nixos/switch-to-configuration: Improve socket and timer handling, clean up, minor fixes, add test Oct 13, 2021
Copy link
Member

@Mic92 Mic92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. I am doing some actual testing now.

@dasJ dasJ force-pushed the feat/improved-socket-handling2 branch from d48d0d1 to 776bccc Compare October 14, 2021 19:19
@dasJ
Copy link
Member Author

dasJ commented Oct 14, 2021

cc @stigtsp since your Perl is probably one of the best ;)

@dasJ dasJ force-pushed the feat/improved-socket-handling2 branch from ac96d67 to 4a41568 Compare October 14, 2021 20:25
@dasJ dasJ force-pushed the feat/improved-socket-handling2 branch from 4a41568 to 69b2614 Compare October 14, 2021 20:30
dasJ added 13 commits October 17, 2021 14:33
They are not managed by us and it might be weird to users to see units
they didn't expect to be started.
This commit changes a lot more that you'd expect but it also adds a lot
of new testing code so nothing breaks in the future. The main change is
that sockets are now restarted when they change. The main reason for
the large amount of changes is the ability of activation scripts to
restart/reload units. This also works for socket-activated units now,
and honors reloadIfChanged and restartIfChanged. The two changes don't
really work without each other so they are done in the one large commit.

The test should show what works now and ensure it will continue to do so
in the future.
The first FIXME is removed because it doesn't make sense to use
/proc/1/exe since that points to a directory that doesn't have all tools
the activation script needs (like systemd-escape).

The second one is removed because there is already no error handling
(compare with the restart logic where the return code is checked).
The previous logic failed to detect that units were socket-activated
when the socket was stopped before switch-to-configuration was run. This
commit fixes that and also starts the socket in question.
This makes the order of operations the same in dry-activate and a "true"
activate. Also fixes the indentation I messed up and drop a useless
unlink() call (we are already unlinking that file earlier).
@dasJ dasJ force-pushed the feat/improved-socket-handling2 branch from ae5c3ae to 4cdbb2d Compare October 17, 2021 12:40
@Mic92 Mic92 merged commit 57961d2 into NixOS:master Oct 18, 2021
@Mic92
Copy link
Member

Mic92 commented Oct 18, 2021

Tested on some machines. Works for me.

@dasJ dasJ deleted the feat/improved-socket-handling2 branch October 18, 2021 17:01
primeos added a commit to primeos/nixpkgs that referenced this pull request Nov 27, 2021
…proved-socket-handling2"

This reverts commit 57961d2, reversing
changes made to b04f913.
(I.e. this reverts PR NixOS#141192.)

While well-intended, this change does unfortunately introduce very
serious regressions that are especially disruptive/noticeable on desktop
systems (e.g. users of Sway will loose their graphical session when
running "nixos-rebuild switch").

Therefore, this change has to be reverted ASAP instead of trying to fix
it in "production".
Note: An updated version should be extensively discussed, reviewed, and
tested before re-landing this change as an earlier version also had to
be reverted for the exact same issues [0].

Fix: NixOS#146727

[0]: NixOS#73871 (comment)
@primeos
Copy link
Member

primeos commented Nov 27, 2021

Unfortunately this causes the exact same issues as before and I urge to revert it ASAP because it is very annoying (no offense): #147609

I'm a bit late to the party as I didn't update in a while as I lacked time to deal with such issues (and I was afraid when I saw this change).

@aanderse
Copy link
Member

ping @tomberek @nrdxp

nrdxp added a commit that referenced this pull request Nov 27, 2021
…ket-units

Revert "Merge pull request #141192 from helsinki-systems/feat/improve…
github-actions bot pushed a commit that referenced this pull request Nov 27, 2021
…d-socket-handling2"

This reverts commit 57961d2, reversing
changes made to b04f913.
(I.e. this reverts PR #141192.)

While well-intended, this change does unfortunately introduce very
serious regressions that are especially disruptive/noticeable on desktop
systems (e.g. users of Sway will loose their graphical session when
running "nixos-rebuild switch").

Therefore, this change has to be reverted ASAP instead of trying to fix
it in "production".
Note: An updated version should be extensively discussed, reviewed, and
tested before re-landing this change as an earlier version also had to
be reverted for the exact same issues [0].

Fix: #146727

[0]: #73871 (comment)

(cherry picked from commit 1cfecb6)
nrdxp added a commit that referenced this pull request Nov 27, 2021
[Backport release-21.11] Revert "Merge pull request #141192 from helsinki-systems/feat/improve…
mkg20001 pushed a commit to mkg20001/nixpkgs that referenced this pull request Nov 29, 2021
…proved-socket-handling2"

This reverts commit 57961d2, reversing
changes made to b04f913.
(I.e. this reverts PR NixOS#141192.)

While well-intended, this change does unfortunately introduce very
serious regressions that are especially disruptive/noticeable on desktop
systems (e.g. users of Sway will loose their graphical session when
running "nixos-rebuild switch").

Therefore, this change has to be reverted ASAP instead of trying to fix
it in "production".
Note: An updated version should be extensively discussed, reviewed, and
tested before re-landing this change as an earlier version also had to
be reverted for the exact same issues [0].

Fix: NixOS#146727

[0]: NixOS#73871 (comment)
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: changelog 8.has: documentation This PR adds or changes documentation 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: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

changes to socket units don't restart
6 participants