-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
Add service_restart option to prevent automatic service reload #728
Conversation
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.
See one comment. I think the basic idea is right from a quick once-over, but we’ll need spec tests to be added for the case where it’s disabled, and any failing tests should also be updated
manifests/config.pp
Outdated
if ($service_restart) { | ||
$service_to_restart = Class['rabbitmq::service'], | ||
} else { | ||
$service_to_rstart = undef |
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.
Should be restart here
I've fixed the failing tests. I'm not able to get a valid test to check this. Any help appreciated not working
|
@spuder You could try on IRC or in the #testing channel on Puppet Slack. I haven't been working with Puppet or rspec that much recently. I'm not sure that's the best way to test this... but if I invert your test, it passes:
--- a/spec/classes/rabbitmq_spec.rb
+++ b/spec/classes/rabbitmq_spec.rb
@@ -1455,6 +1455,15 @@ describe 'rabbitmq' do
it { is_expected.not_to contain_service('rabbitmq-server') }
end
+
+ describe 'service with service_restart equal to false' do
+ let :params do
+ { service_restart: false }
+ end
+
+ it { is_expected.to contain_file('rabbitmq.config').that_notifies('Class[rabbitmq::service]') }
+ end
+
end
end
end
So I think that because there's a class level notify (via the squiggly arrow), you need to make this logic happen at that level, and the -> Class['rabbitmq::config']
~> Class['rabbitmq::service'] I think you can handle the logic here, and then it will also be easier to test the class relationships directly. As a plus, we'll remove some cruft from the codebase too. |
@spuder I PRed your PR - let me know if that works. I changed what the test is as well. There might be a more elegant way, but I think it works. if ($service_restart) {
Class['rabbitmq::config'] ~> Class['rabbitmq::service']
}
Class['rabbitmq::install']
-> Class['rabbitmq::config']
-> Class['rabbitmq::service']
-> Class['rabbitmq::management'] If that looks good, can you merge my PR, then squash those commits down your branch, and I'll get one other person to review? It's fine to either squash my commit in and leave it separate; either way, squash down the other commits if you know how. (should be something like |
Thanks for the help. Tests are passing and everything looks correct. I squashed the commits (inadvertently including your commit). If the travis tests pass I believe this would be good to merge. |
@bastelfreak @ekohl: I know you're both busy, but if either of you has a chance to review, would appreciate it. |
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 good with this, but I also suggested some of the changes, let's get one more +1 on here too.
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 know https://github.com/puppetlabs/puppetlabs-postgresql has a mechanism to reload. Would that that work here?
manifests/init.pp
Outdated
@@ -146,6 +146,7 @@ | |||
# @param service_ensure The state of the service. | |||
# @param service_manage Determines if the service is managed. | |||
# @param service_name The name of the service to manage. | |||
# @param $service_restart. Default defined in param.pp. This option will prevent config changes from restarting rabbitmq |
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 this could be phrased a bit clearer. How about:
Whether to restart the service on config change.
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.
Fixed
It's been a little, but I think not. From a quick look, at least, it would seem that reload and restart both will restart the service. |
Thanks for the contribution (and patience) |
Pull Request (PR) description
Make the restart optional since it is dangerous to do an uncontrolled rolling restart. We lost many messages this way.
It has been many years since I have written any puppet code so I don't have high confidence that I did this entirely correct. It is based off of how the kafka module prevents rolling restarts https://github.com/voxpupuli/puppet-kafka/search?q=service_restart&unscoped_q=service_restart
This Pull Request (PR) fixes the following issues
Fixes #727