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/networkd: reload instead of restarting #194811

Closed
wants to merge 1 commit into from

Conversation

ncfavier
Copy link
Member

@ncfavier ncfavier commented Oct 6, 2022

When its configuration files change, reload systemd-networkd (networkctl reload) instead of restarting it.

This fixes the following race condition during activation:

  • systemd-networkd.service is stopped
  • ⚠ someone calls networkctl, which immediately restarts networkd, which reconfigures itself using the old /etc
  • the new /etc is set up
  • systemd-networkd.service is started (doing nothing)

@ncfavier ncfavier requested a review from dasJ as a code owner October 6, 2022 21:44
@github-actions github-actions 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 Oct 6, 2022
When its configuration files change, reload systemd-networkd
(`networkctl reload`) instead of restarting it.

This fixes the following race condition with the current setup during
activation:
- systemd-networkd.service is stopped
- ⚠ someone calls `networkctl`, which immediately restarts networkd,
  which reconfigures itself using the *old* /etc
- the new /etc is set up
- systemd-networkd.service is started (doing nothing)
@ncfavier ncfavier changed the title nixos/network: reload instead of restarting nixos/networkd: reload instead of restarting Oct 6, 2022
@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 6, 2022
Copy link
Member

@ajs124 ajs124 left a comment

Choose a reason for hiding this comment

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

did not test, but LGTM

@ncfavier ncfavier requested a review from flokli October 30, 2022 14:30
@flokli
Copy link
Contributor

flokli commented Nov 2, 2022

I'm not sure if a reload properly reconfigures everything necessary.

Did you see systemd/systemd#13452 (comment) ?

@ncfavier
Copy link
Member Author

ncfavier commented Nov 2, 2022

Hmm, I did not. I wonder if reload; reconfigure would do it, but that would require changing ExecReload.

@ncfavier
Copy link
Member Author

ncfavier commented Nov 2, 2022

Seems like reload should be enough... well it's complicated, see systemd/systemd#6654 (comment)

@RaitoBezarius
Copy link
Member

Do we still want to proceed with this method of reloading? I would say removing existing netdevs is not a big deal compared to the advantages we got with this PR.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Sep 7, 2023
@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict This PR has merge conflicts with the target branch labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@fpletz
Copy link
Member

fpletz commented Nov 30, 2024

Closing since the network service has since been refactored to distinguish between units that need reload or restart respectively. Furthermore, #359724 should fix any remaining issues.

@fpletz fpletz closed this Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: systemd 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 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants