Skip to content

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

Merged
merged 5 commits into from
Dec 7, 2020
Merged

Change - Use systemd drop-in directory for unit overrides #1201

merged 5 commits into from
Dec 7, 2020

Conversation

blackknight36
Copy link

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.

systemd[1]: /etc/systemd/system/postgresql-9.6.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.

@blackknight36 blackknight36 requested a review from a team as a code owner October 27, 2020 16:11
@puppet-community-rangefinder
Copy link

postgresql::server::config is a class

that may have no external impact to Forge modules.

This module is declared in 71 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@daianamezdrea
Copy link
Contributor

Hi @blackknight36, thank you for submitting this PR, can you have a look at Travis failures which are coming from this?

manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 211
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 212
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 213
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 214
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 17, but found it in column 16) on line 219 

@david22swan david22swan changed the base branch from master to main November 2, 2020 12:24
@blackknight36
Copy link
Author

Hi @blackknight36, thank you for submitting this PR, can you have a look at Travis failures which are coming from this?

manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 211
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 212
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 213
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 16, but found it in column 17) on line 214
manifests/server/config.pp - WARNING: indentation of => is not properly aligned (expected in column 17, but found it in column 16) on line 219 

Yes, I should be able to fix it tomorrow.

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'],
Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Collaborator

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') }

Copy link
Author

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.

Comment on lines 3 to 5
<%- 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' -%>
Copy link
Collaborator

@ekohl ekohl Nov 4, 2020

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.

Suggested change
<%- 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.

Copy link
Author

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.

Copy link
Collaborator

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

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.

Copy link
Collaborator

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.

@puppet-community-rangefinder
Copy link

postgresql::server::config is a class

that may have no external impact to Forge modules.

This module is declared in 71 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@maage
Copy link

maage commented Nov 11, 2020

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.

$ rpm -q systemd
systemd-239-31.el8_2.2.x86_64
$ facter os
{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "CentOS",
  release => {
    full => "8.2.2004",
    major => "8",
    minor => "2"
  },
  selinux => {
    config_mode => "enforcing",
    config_policy => "targeted",
    current_mode => "enforcing",
    enabled => true,
    enforced => true,
    policy_version => "31"
  }
}

@blackknight36
Copy link
Author

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.

$ rpm -q systemd
systemd-239-31.el8_2.2.x86_64

I can update this PR to include CentOS 8 as well.

@blackknight36
Copy link
Author

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?

@maage
Copy link

maage commented Nov 11, 2020

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.

@sheenaajay sheenaajay self-assigned this Nov 16, 2020
@sheenaajay
Copy link
Contributor

Thanks alot @blackknight36 for the changes. Could you please fix the travis failures.
Thank you @ekohl and @maage for the valuable comments.

@codecov-io
Copy link

codecov-io commented Nov 16, 2020

Codecov Report

Merging #1201 (4f976e6) into main (08e3a51) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 711a729...4f976e6. Read the comment docs.

@blackknight36
Copy link
Author

Thanks alot @blackknight36 for the changes. Could you please fix the travis failures.
Thank you @ekohl and @maage for the valuable comments.

The Travis failures have been fixed. Please let me know if you need any other changes.

Copy link
Collaborator

@ekohl ekohl left a 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.

@blackknight36 blackknight36 changed the title Change - Use systemd conf dirs for overrides Change - Use systemd drop-in directory for unit overrides Nov 26, 2020
Michael Watters and others added 5 commits November 30, 2020 11:01
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>
@sheenaajay
Copy link
Contributor

Thank you @blackknight36 @ekohl for your contribution.

@sheenaajay sheenaajay merged commit efdd359 into puppetlabs:main Dec 7, 2020
@blackknight36 blackknight36 deleted the use_systemd_conf_dir branch December 21, 2020 15:47
@vchepkov
Copy link

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

@blackknight36
Copy link
Author

blackknight36 commented Jan 27, 2021

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.

@vchepkov
Copy link

I would if issues were enabled on the repository.
I see that a fix is in progress #1230

cegeka-jenkins pushed a commit to cegeka/puppet-postgresql that referenced this pull request Feb 3, 2022
…f_dir

Change - Use systemd drop-in directory for unit overrides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants