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

Dropin daemon reload #237

Closed

Conversation

simondeziel
Copy link
Contributor

Fixes #234

Whenever a dropin snippet is added or removed, systemd needs
to be informed to assemble the full unit file. If for some odd
reason, someone manages both a unit (systemd::unit_file) and add
a dropin (systemd::dropin_file), `systemctl daemon-reload` will be
called twice. This is useless but also harmless. Ideally, one would
simply fold all settings into the base unit and forgo the dropin.

Fixes voxpupuli#234

Signed-off-by: Simon Deziel <simon@sdeziel.info>
Signed-off-by: Simon Deziel <simon@sdeziel.info>
@ekohl
Copy link
Member

ekohl commented Nov 8, 2021

I'm not sure this is correct. Puppet should already reload services that are managed. In #234 (comment) I asked for some more info.

@simondeziel
Copy link
Contributor Author

I'm not sure this is correct. Puppet should already reload services that are managed.

Which it does but the bug is for services that only dropin files are managed. I use those all the time to add a delta on top of what the distro/packager provided for example.

@@ -69,11 +69,20 @@
show_diff => $show_diff,
}

exec { "${name}-dropin-systemctl-daemon-reload":
command => 'systemctl daemon-reload',
refreshonly => true,
Copy link
Member

Choose a reason for hiding this comment

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

Rather than refreshonly I wonder if onlyif => 'systemctl show -p NeedDaemonReload | grep yes' would work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a good idea 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Needs the unit name in there of course.

onlyif => 'systemctl show -p NeedDaemonReload $unit | grep yes'

The downside is this being run potentially many times per unit per puppet run always but the simplicity wins for me.

systemd::unit_file would need the same code for an unmanned .service and .timer so would be nice to really only have one exec per unit. As mentioned else where - defined type and ensure_resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The onlyif incurs overhead for every run. Probably a personal preference, but refreshonly coupled with subscribe feels simple and self descriptive to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The onlyif => "systemctl show -p NeedDaemonReload $unit | grep yes" way makes sense if for some reason a user has both a systemd::unit_file and a systemd::dropin_file for the same service.

I consider this to be an edge case because if you deploy the unit, why bother with a dropin? However, if you do need this unusual setup, it will work but systemctl daemon-reload will be called twice. The overhead of that second extraneous call that happens only on changes is probably not too far off from the NeedDaemonReload test it's avoiding for every single runs.

@ekohl
Copy link
Member

ekohl commented Nov 9, 2021

In #234 (comment) I suggested to use a define to avoid multiple reloads for the same service, in case multiple drop ins are used.

@trevor-vaughan
Copy link
Contributor

I'm going to see if we can get this (or something very like it) through.

This is a use case that has prevented us from upgrading since the change was put in place originally:

  • GDM with hidepid=2 requires an updated to systemd-logind via a dropin file.
  • I do not wish to manage systemd-logind but GDM does have to put that file in place
  • systemctl daemon-reload must immediately be run due to this dropin that does not have a managed service in Puppet

@simondeziel
Copy link
Contributor Author

* GDM with `hidepid=2` requires an updated to `systemd-logind` via a dropin file.

Sorry if that's not related to the core issue but I've been wanting to go back to hidepid=2 for sometimes but didn't know how to make it work. What's the systemd-logind tweak that's needed, please? :)

@trevor-vaughan
Copy link
Contributor

@simondeziel See https://github.com/simp/pupmod-simp-gdm.

Also, are you up for getting this changed now or should I refactor into another PR? At a minimum, we need to get the exec into its own defined type.

@trevor-vaughan
Copy link
Contributor

@simondeziel I started down the path to getting everything fixed, will cross-link a new PR.

@trevor-vaughan
Copy link
Contributor

@simondeziel Can you try this? https://github.com/voxpupuli/puppet-systemd/tree/daemon-reload

It works for me, but I'm working on a section to fix all of the systems that got broken by the current 3.X branch (daemon-reload was never called)

@simondeziel
Copy link
Contributor Author

@trevor-vaughan the daemon-reload branch works for me as well, thanks!

@trevor-vaughan
Copy link
Contributor

Closing in favor of #277 per the conversation above

op-ct pushed a commit to op-ct/puppet-systemd that referenced this pull request Jun 17, 2022
@simondeziel simondeziel deleted the dropin-daemon-reload branch June 18, 2022 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

systemd::dropin_file doesn't cause a systemd daemon-reload
5 participants