You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Search for maintainers and people that previously touched the related code and @ mention them in a comment.
IIRC the problem with restarting socket units was that the corresponding services will be restarted as well and options like systemd.services.<name>.stopIfChanged won't be respected (edit: not quite sure anymore if that's true, I'd need to re-check)
Possible solutions/workarounds
Propagate stopIfChanged, etc. from services to the socket units (but probably too difficult to get right)
Try to analyze Nixpkgs and apply the same settings to the socket units (likely too much work)
So this is the new approach that I came up with and that was discussed with @ajs124, @lovesegfault, @roberth, and @flokli to improve it even further. I really hope this solves all issues we had and that it provides a proper way to handle all edge cases.
So first off, there's a really easy case where the socket did not activate the service yet and something changed. We can restart just restart the socket if it changed and ignore all changes to the service file because it wasn't activated anyway. I don't think there's going to be any discussion about this detail of the implementation.
The hard part comes around when the service was already activated at the point of the switch. We have 3 cases we need to handle which is "service modified", "socket modified", and "both modified".
We can start with the easiest part that is just a plain modification of the service. If it has reloadIfChanged we can issue a reload of the service and we should be done. If it doesn't have reloadIfChanged we can stop it it has restartIfChanged set (this is where my old implementation lacked). We can ignore stopIfChanged in this case because it doesn't make sense.
When the socket is changed but the service is not we have to take a look at restartIfChanged of the service and do nothing because people don't expect the service to be stopped at all which we would have to do. If the service is allowed to be restarted (restartIfChanged=true) we can take a look at stopIfChanged because that's what we are going to do now. Since this is true by default it should just give you the new behaviour by default which is to stop the socket, stop the service, and start the socket afterwards. There is no other way to prevent races between the service being stopped and the socket being restarted. If people want to opt out of this downtime-introducing feature they can do that by setting stopIfChanged=false.
The last case is where both are changed. This is pretty similar to the "socket changed" case. If the service has restartIfChanged=false, do nothing yet again. Depending on stopIfChanged we can now decide what exactly to do next. If it is set to true (default), we can yet again stop the socket, stop the service, start the socket. If it is set to false however, we just stop (or reload if possible) the service and not do anything to the socket at all. This way the settings won't get applied to the socket but that might be preferrable in this case.
I hope this all makes sense (I was about to draw a diagram but I couldn't find a proper way) and I'm happy to receive feedback on whether this is the best way to go. Assuming I can implement this without any bugs this should finally give us the requested behaviour.
Oh one thing to add is that if we stop the service, we can't do that in the regular "stopping the following services:" block but we would rather have to do it in a second stopping round that happens after the activation. If we don't do that, we get an annoying race where it's possible for the service to be activated and to load the old configuration before the activation is actually activated and /etc is rewritten. This should hopefully solve the problem @Ma27 was having with networkd and nixos containers
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Activity
griff commentedon Jan 6, 2020
My PR #33661 explicitly ignored sockets where the unit had
reloadIfChanged = truestale commentedon Jul 4, 2020
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
primeos commentedon Nov 28, 2021
Some quick notes:
systemd.services.<name>.stopIfChangedwon't be respected (edit: not quite sure anymore if that's true, I'd need to re-check)stopIfChanged, etc. from services to the socket units (but probably too difficult to get right)nixos-rebuild switchnormally depends on the last system state in that regarddasJ commentedon Dec 10, 2021
So this is the new approach that I came up with and that was discussed with @ajs124, @lovesegfault, @roberth, and @flokli to improve it even further. I really hope this solves all issues we had and that it provides a proper way to handle all edge cases.
So first off, there's a really easy case where the socket did not activate the service yet and something changed. We can restart just restart the socket if it changed and ignore all changes to the service file because it wasn't activated anyway. I don't think there's going to be any discussion about this detail of the implementation.
The hard part comes around when the service was already activated at the point of the switch. We have 3 cases we need to handle which is "service modified", "socket modified", and "both modified".
We can start with the easiest part that is just a plain modification of the service. If it has
reloadIfChangedwe can issue a reload of the service and we should be done. If it doesn't havereloadIfChangedwe can stop it it hasrestartIfChangedset (this is where my old implementation lacked). We can ignorestopIfChangedin this case because it doesn't make sense.When the socket is changed but the service is not we have to take a look at
restartIfChangedof the service and do nothing because people don't expect the service to be stopped at all which we would have to do. If the service is allowed to be restarted (restartIfChanged=true) we can take a look atstopIfChangedbecause that's what we are going to do now. Since this is true by default it should just give you the new behaviour by default which is to stop the socket, stop the service, and start the socket afterwards. There is no other way to prevent races between the service being stopped and the socket being restarted. If people want to opt out of this downtime-introducing feature they can do that by settingstopIfChanged=false.The last case is where both are changed. This is pretty similar to the "socket changed" case. If the service has
restartIfChanged=false, do nothing yet again. Depending onstopIfChangedwe can now decide what exactly to do next. If it is set totrue(default), we can yet again stop the socket, stop the service, start the socket. If it is set tofalsehowever, we just stop (or reload if possible) the service and not do anything to the socket at all. This way the settings won't get applied to the socket but that might be preferrable in this case.I hope this all makes sense (I was about to draw a diagram but I couldn't find a proper way) and I'm happy to receive feedback on whether this is the best way to go. Assuming I can implement this without any bugs this should finally give us the requested behaviour.
dasJ commentedon Dec 10, 2021
Oh one thing to add is that if we stop the service, we can't do that in the regular "stopping the following services:" block but we would rather have to do it in a second stopping round that happens after the activation. If we don't do that, we get an annoying race where it's possible for the service to be activated and to load the old configuration before the activation is actually activated and /etc is rewritten. This should hopefully solve the problem @Ma27 was having with networkd and nixos containers