-
Notifications
You must be signed in to change notification settings - Fork 614
Change - Use systemd drop-in directory for unit overrides #1201
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
Change - Use systemd drop-in directory for unit overrides #1201
Conversation
postgresql::server::config is a classthat may have no external impact to Forge modules. This module is declared in 71 of 575 indexed public
|
Hi @blackknight36, thank you for submitting this PR, can you have a look at Travis failures which are coming from this?
|
Yes, I should be able to fix it tomorrow. |
manifests/server/config.pp
Outdated
owner => root, | ||
group => root, | ||
content => template('postgresql/systemd-override.erb'), | ||
notify => [Exec['restart-systemd'], Class['postgresql::server::service']], | ||
before => Class['postgresql::server::reload'], | ||
require => File['systemd-conf-dir'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this autorequired since Puppet 2.7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain about that. I've had issues in the past with puppet trying to create files in a directory that doesn't exist which is why I added the requirement here. If you want to leave it off that's fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In spec tests you can verify it:
it { is_expected.to contain_file('/etc/systemd/postgresql-server.d/override.conf').that_requires('/etc/systemd/postgresql-server.d') }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a quick test and it appears that there is no autorequire for the parent directory. The unit test fails after adding a test similar to above.
templates/systemd-override.erb
Outdated
<%- elsif scope.lookupvar('::operatingsystem') == 'Fedora' and scope.lookupvar('::operatingsystem') <= '31' -%> | ||
.include /lib/systemd/system/<%= @service_name %>.service | ||
<%- elsif scope.lookupvar('::operatingsystem') == 'Fedora' and scope.lookupvar('::operatingsystem') >= '32' -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think drop ins should work on all supported variants of the Red Hat OS family.
<%- elsif scope.lookupvar('::operatingsystem') == 'Fedora' and scope.lookupvar('::operatingsystem') <= '31' -%> | |
.include /lib/systemd/system/<%= @service_name %>.service | |
<%- elsif scope.lookupvar('::operatingsystem') == 'Fedora' and scope.lookupvar('::operatingsystem') >= '32' -%> | |
<%- elsif @facts['os']['family'] == 'RedHat' -%> |
In fact, I'm not sure if there's any systemd version that doesn't support this but then you need to modify the other conditionals in config.pp as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to break servers running older Fedora releases and anything older than F32 is EOL now which is why I limited this change to more modern releases. I can run some tests on our Fedora 20 nodes to see if drop-in directories are supported but I didn't see anything in the documentation mentioning that feature.
Another way to handle this would be to create a "systemd_version" fact which may work better than limiting options to just the RedHat OS family.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supported on EL 7 which is based on Fedora 18ish IIRC. I wouldn't be surprised if it worked on even the ancient Fedora 17 that's listed in globals.pp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The oldest Fedora server I have available right now is running Fedora 20. The man page for systemd.unit makes no mention of support for drop-in directories. The man page on CentOS 7 does mention them which makes sense since EL7 runs systemd version 219 vs. 208 on Fedora 20.
Knowing this I should be able to make these changes work with Fedora 20 and up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blackknight36 we have to include conditions for Redhat 8 since the deprecated warnings are coming there too.Will run the tests on all OSes and see if its break anything. Thanks alot for your contribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I forgot to add that. I'll fix the template and push again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally the include statement should be removed on all OSes, not just Redhat. I'm sure that Gentoo also includes a newer version of systemd which would be affected in the future as well. I don't have a Gentoo server to test on however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think worries about drop ins are really not needed. This is literally the only reason I know that includes are a thing. On my Gentoo boxes I use drop ins regularly. I think that on all distros you can rely on them.
postgresql::server::config is a classthat may have no external impact to Forge modules. This module is declared in 71 of 575 indexed public
|
I see this issue at CentOS 8 too: Wed 2020-11-11 11:50:46 UTC hostname systemd[1]: /etc/systemd/system/postgresql-13.service:1: .include directives are deprecated, and support for them will be removed in a future version of systemd. Please use drop-in files instead.
|
I can update this PR to include CentOS 8 as well. |
Another thing I noticed is that the postgresql::server::config class does not appear to address RHEL 5 or 6 although these releases are supported according to the metadata file. Should there be checks set up for these releases as well? |
RHEL/CentOS 5/6 does not use systemd, they use old upstart, service - command and /etc/init.d -directory setup. Regarding to upstream supports: https://access.redhat.com/support/policy/updates/errata#Life_Cycle_Dates RH extended support is going to end at the end of 2020-11. And RHEL6 maintenance support is going to end also 2020-11, but extended support is still possible until 2024-06. metadata.json also does not mention Fedora (currently 31, 32, 33). I guess any supported OS version should be supported with testing and no testing is necessary for unsupported OS combos. |
Thanks alot @blackknight36 for the changes. Could you please fix the travis failures. |
Codecov Report
@@ Coverage Diff @@
## main #1201 +/- ##
=======================================
Coverage 65.81% 65.81%
=======================================
Files 14 14
Lines 351 351
=======================================
Hits 231 231
Misses 120 120 Continue to review full report at Codecov.
|
The Travis failures have been fixed. Please let me know if you need any other changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a module maintainer, but I'd strongly urge you to drop the old include behavior.
The .include directive has been deprecated and support for it may be removed in a future systemd release. Drop-in directories are supported on all current RedHat, Fedora, and Gentoo releases. This branch contains changes to support this feature and disables the old behavior of using Include directives on RedHat based nodes.
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Thank you @blackknight36 @ekohl for your contribution. |
This change breaks existing postgres instance (pre 6.9.0). One need to issue systemctl daemon-reload first, after old unit file was deleted and only after that restart the newly configured service, otherwise service fails |
Thanks for the report. I will see if there is a way to avoid this. It would be best to create an issue as the PR has already been merged. |
I would if |
…f_dir Change - Use systemd drop-in directory for unit overrides
The .include directive has been deprecated and support for it may be removed in a future systemd release. This fixes warnings issued by systemd which are shown as follows.