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

nebula: Add restartTrigger for config file #253491

Closed
wants to merge 1 commit into from

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Sep 5, 2023

Description of changes

Upstreaming this from my production setup.

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, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.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.

CC nebula package maintainers @Br1ght0ne @numinit

@nh2 nh2 self-assigned this Sep 5, 2023
@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 Sep 5, 2023
@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 Sep 5, 2023
# Restart nebula when the config file changes.
# Without this, we may get "Current command vanished from the unit file"
# when the file changes and systemd will _not_ restart it.
restartTriggers = [ configFile ];
Copy link
Contributor

@jian-lin jian-lin Sep 6, 2023

Choose a reason for hiding this comment

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

I am not sure what "Current command vanished from the unit file" means and how it affects service restarting.

However, I do not think adding restartTriggers makes any difference. All restartTriggers does is adding X-Restart-Triggers = your-triggers to the service file.

  • Since this directive starts with X-, systemd ignores it.
  • Also, the logic of restarting services in switch-to-configuration.pl does not do anything special for it. And configFile has already been used in ExecStart. So there is no difference after adding restartTriggers from the perspective of switch-to-configuration.pl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure what "Current command vanished from the unit file" means and how it affects service restarting.

It is an error/issue with systemd, see e.g. #49415. Sometimes, when a systemd service's unit file changes (e.g. when the command line changes as part of a NixOS configuration switch), there is a race where systemd notices that change, and then seems to run some "somebody changed my file under me, I'll do nothing about it" logic. Unfortunately it isn't documented in systemd, thus my vague explanation.

The effect of that is that sometimes on NixOS configuration switches, services aren't restarted (#49415), and in this case for Nebula, I noticed that when I change the Nebula config file via configuration.nix, Nebula was not restarted (thus not observing the config change).

  • the logic of restarting services in switch-to-configuration.pl does not do anything special for it. And configFile has already been used in ExecStart. So there is no difference after adding restartTriggers from the perspective of switch-to-configuration.pl.

Hm, this is correct. From b606165 the only thing X-Restart-Triggers does is to be present in the unit file, so that the unit file changes. So you're right that should already tbe the case due to ExecStart = "${netCfg.package}/bin/nebula -config ${configFile}";.

I am wondering now whether I was just lucky regarding the race and this change indeed had no additional effect on my systems, or whether the fact that a string in the unit file changes that's outside the ExecStart line ("current command ...") helps systemd avoid the problem somehow.

I'm inclined to close this PR, until we have some proof that the change actually does something.

@nh2
Copy link
Contributor Author

nh2 commented Oct 10, 2023

From my comment:

I'm inclined to close this PR, until we have some proof that the change actually does something.

@nh2 nh2 closed this Oct 10, 2023
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: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants