-
Notifications
You must be signed in to change notification settings - Fork 614
(bug) fix systemd daemon-reload order when updating service files #1230
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
Conversation
postgresql::server::config is a classthat may have no external impact to Forge modules. This module is declared in 71 of 576 indexed public
|
f64b6ae
to
5d3dc8b
Compare
This doesn't establish ordering, the following should be added in the manifest and then it's good as it is now
|
Thanks alot @vchepkov |
5d3dc8b
to
c843185
Compare
Codecov Report
@@ Coverage Diff @@
## main #1230 +/- ##
==========================================
+ Coverage 65.81% 66.18% +0.37%
==========================================
Files 14 14
Lines 351 349 -2
==========================================
Hits 231 231
+ Misses 120 118 -2
Continue to review full report at Codecov.
|
Hmm, this doesn't look like a valid syntax to me, I am surprised it works |
Thank you @vchepkov you are right. Doing some test locally before pushing the new changes . |
c843185
to
9394cc9
Compare
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.
LGTM 👍
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.
Btw, my understanding is that on Puppet 6 the daemon-reload isn't needed. So wouldn't the following work:
if (versioncmp($facts['puppetversion'], '6.1.0') < 0) {
exec { 'restart-systemd':
command => 'systemctl daemon-reload',
refreshonly => true,
path => '/bin:/usr/bin:/usr/local/bin',
require => File['old-systemd-override'],
before => Class['postgresql::server::service'],
}
}
ef0e3f0
to
8ad3458
Compare
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 is odd that on Puppet 5 it will reload systemd and perhaps trigger a service restart (depending on if other resources will trigger it), on Puppet 6+ it will always trigger a service restart. That feels odd.
f62ffff
to
b519b59
Compare
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.
Code wise I love how minimal the final version is. I just hope I didn't miss anything in the review and that this is somehow insufficient. I trust that you'll properly test it to confirm.
On a side note: perhaps it should be squashed into a single commit. |
Sure, I will be squashing to single commit before the merge. Just kept there to make sure the comments are addressed. |
very true @ekohl |
b519b59
to
4a06537
Compare
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, everyone for chipping in!
The module still breaks postgresql service when switching from 6.8.0 to 6.10.0. Here is the output: I don't see call to refresh restart-systemd anywhere :
I also don't see it in resource list:
This reproducible 100% |
v6.10.1 fixed the issue. thank you |
Bug Details
Problem reported on Puppet version 6.20, OS Centos 8
Proposed solution
Issue systemctl daemon-reload first, after the deletion of old unit file followed by the restart newly configured service.
Create separate file resource for deleting old unit file and specifying the ordering to make sure it deletes the files first, then daemon- reload followed by service start
Puppet agent 5 Results
Notice: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]/ensure: removed Info: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: Scheduling refresh of Exec[restart-systemd] Debug: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: The container Class[Postgresql::Server::Config] will propagate my refresh event Info: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: Scheduling refresh of Class[Postgresql::Server::Service] Debug: /Stage[main]/Postgresql::Server::Config/Exec[restart-systemd]: 'systemctl daemon-reload' won't be executed because of failed check 'refreshonly' Debug: Exec[restart-systemd](provider=posix): Executing 'systemctl daemon-reload' Debug: Executing: 'systemctl daemon-reload' Notice: /Stage[main]/Postgresql::Server::Config/Exec[restart-systemd]: Triggered 'refresh' from 1 event Debug: /Stage[main]/Postgresql::Server::Config/Exec[restart-systemd]: The container Class[Postgresql::Server::Config] will propagate my refresh event Debug: Prefetching parsed resources for postgresql_conf Debug: Class[Postgresql::Server::Config]: The container Stage[main] will propagate my refresh event Debug: Class[Postgresql::Server::Config]: The container Class[Postgresql::Server] will propagate my refresh event Info: Class[Postgresql::Server::Service]: Scheduling refresh of Anchor[postgresql::server::service::begin] Info: Class[Postgresql::Server::Service]: Scheduling refresh of Service[postgresqld] Info: Class[Postgresql::Server::Service]: Scheduling refresh of Anchor[postgresql::server::service::end] Notice: /Stage[main]/Postgresql::Server::Service/Anchor[postgresql::server::service::begin]: Triggered 'refresh' from 1 event Debug: /Stage[main]/Postgresql::Server::Service/Anchor[postgresql::server::service::begin]: The container Class[Postgresql::Server::Service] will propagate my refresh event Debug: Executing: 'systemctl status postgresql' Debug: Executing: '/usr/bin/systemctl is-enabled -- postgresql' Debug: Executing: 'systemctl status postgresql' Debug: Executing: '/usr/bin/systemctl restart -- postgresql' Notice: /Stage[main]/Postgresql::Server::Service/Service[postgresqld]: Triggered 'refresh' from 1 event Debug: /Stage[main]/Postgresql::Server::Service/Service[postgresqld]: The container Class[Postgresql::Server::Service] will propagate my refresh event Debug: PostgresqlValidator.attempt_connection: Attempting connection to postgres Debug: PostgresqlValidator.attempt_connection: /usr/bin/psql --tuples-only --quiet --no-psqlrc --port 5432 --dbname postgres --command 'SELECT 1' Debug: Executing with uid=postgres: ' /usr/bin/psql --tuples-only --quiet --no-psqlrc --port 5432 --dbname postgres --command 'SELECT 1' ' Debug: PostgresqlValidator.attempt_connection: Connection to postgres successful!
puppet agent 6 Results
Debug: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: Removing existing file for replacement with absent Notice: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]/ensure: removed Debug: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: The container Class[Postgresql::Server::Config] will propagate my refresh event Info: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: Scheduling refresh of Class[Postgresql::Server::Service] Debug: Prefetching parsed resources for postgresql_conf Debug: Class[Postgresql::Server::Config]: The container Stage[main] will propagate my refresh event Debug: Class[Postgresql::Server::Config]: The container Class[Postgresql::Server] will propagate my refresh event Info: Class[Postgresql::Server::Service]: Scheduling refresh of Anchor[postgresql::server::service::begin] Info: Class[Postgresql::Server::Service]: Scheduling refresh of Service[postgresqld] Info: Class[Postgresql::Server::Service]: Scheduling refresh of Anchor[postgresql::server::service::end] Notice: /Stage[main]/Postgresql::Server::Service/Anchor[postgresql::server::service::begin]: Triggered 'refresh' from 1 event Debug: /Stage[main]/Postgresql::Server::Service/Anchor[postgresql::server::service::begin]: The container Class[Postgresql::Server::Service] will propagate my refresh event Debug: Executing: 'systemctl status postgresql' Debug: Executing: '/usr/bin/systemctl is-enabled -- postgresql' Debug: Executing: 'systemctl status postgresql' Debug: Executing: '/usr/bin/systemctl show --property=NeedDaemonReload -- postgresql' Debug: Executing: '/usr/bin/systemctl restart -- postgresql' Notice: /Service[postgresqld]: Triggered 'refresh' from 1 event Debug: /Service[postgresqld]: The container Class[Postgresql::Server::Service] will propagate my refresh event Debug: PostgresqlValidator.attempt_connection: Attempting connection to postgres Debug: PostgresqlValidator.attempt_connection: /usr/bin/psql --tuples-only --quiet --no-psqlrc --port 5432 --dbname postgres --command 'SELECT 1' Debug: Executing with uid=postgres: ' /usr/bin/psql --tuples-only --quiet --no-psqlrc --port 5432 --dbname postgres --command 'SELECT 1' ' Debug: PostgresqlValidator.attempt_connection: Connection to postgres successful!