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

reload on service, checks and watch changes #152

Merged
merged 1 commit into from
Jul 17, 2015
Merged

reload on service, checks and watch changes #152

merged 1 commit into from
Jul 17, 2015

Conversation

aj-jester
Copy link

Certain config changes can trigger a reload by sending SIGHUP signal (which consul reload essentially does). I implemented reload for services, checks and watches although more are supported.

Also confirmed while adding, modifying and removing these resources consul PID remained unchanged throughout.

https://www.consul.io/docs/commands/reload.html
https://www.consul.io/docs/agent/options.html#reloadable-configuration

@solarkennedy
Copy link
Contributor

Obsoletes to #48

Looks good!

I'm a little worried about regressions on this feature.

Do you feel capable writing an acceptance test to ensure this doesn't break again?
I think it would look something like this:

context "When removing a service that has been added" do
new_service_pp = <<-EOF
  'consul::service { 'newservice':
... '
EOF
      # Run it twice and test for idempotency
  expect(apply_manifest(pp).exit_code).to_not eq(1)
  expect(apply_manifest(pp).exit_code).to eq(0)

  # Grab the pid
  consul_pid = process('consul').get_column('pid')

  # Remove the service
  remove_service_pp = <<-EOF
  'consul::service { 'newservice': ensure => absent }'
  EOF

  # Apply remove_service_pp
 new_consul_pid = process('consul').get_column('pid')
 it "should have the same pid after the removal (should reload)" do
   new_consul_pid.should == consul_pid
 end
end

I'm just kinda eyeballing that. This is not going to be required to pull in this PR, but it would give it a better chance of sticking. (it would be pretty easy for the behavior of reload/restart to change based on the notification of the whole folder or whatever)

Also can you rebase because I merged in your other PR first (I think)

@aj-jester
Copy link
Author

@solarkennedy sure thing, but looks like the acceptance tests are broken?

There seems to be a conflict between the rspec version in Gemfile (3.1.0) and what beaker (1.11.0) expects? I'm still digging, I'll update if I find anything.

https://github.com/solarkennedy/puppet-consul/blob/master/Gemfile#L5
https://github.com/puppetlabs/beaker/blob/beaker1.11.0/beaker.gemspec#L22
https://github.com/solarkennedy/puppet-consul/blob/master/Gemfile#L12

# bundle exec rake acceptance
/usr/local/bin/ruby -I/root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib:/root/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.1.2/lib /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/exe/rspec spec/acceptance
/usr/local/bin/ruby -I/root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib:/root/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.1.2/lib /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/exe/rspec spec/acceptance
/root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec/helpers/serverspec.rb:1:in `require': cannot load such file -- serverspec (LoadError)
    from /root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec/helpers/serverspec.rb:1:in `<top (required)>'
    from /root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec/spec_helper.rb:2:in `require'
    from /root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec/spec_helper.rb:2:in `<top (required)>'
    from /root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec.rb:5:in `require'
    from /root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec.rb:5:in `<module:BeakerRSpec>'
    from /root/vendor/bundle/ruby/2.0.0/gems/beaker-rspec-2.0.0/lib/beaker-rspec.rb:1:in `<top (required)>'
    from /root/consul/spec/spec_helper_acceptance.rb:1:in `require'
    from /root/consul/spec/spec_helper_acceptance.rb:1:in `<top (required)>'
    from /root/consul/spec/acceptance/standard_spec.rb:1:in `require'
    from /root/consul/spec/acceptance/standard_spec.rb:1:in `<top (required)>'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
    from /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<main>'
/usr/local/bin/ruby -I/root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/lib:/root/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.1.2/lib /root/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.1.7/exe/rspec spec/acceptance failed
# bundle update
Updating https://github.com/rodjek/rspec-puppet.git
Fetching gem metadata from http://rubygems.org/..........
Fetching version metadata from http://rubygems.org/..
Resolving dependencies............
Using rake 10.4.2
Using CFPropertyList 2.2.8
Using addressable 2.3.8
Using extlib 0.9.16
Using multi_json 1.11.2
Using autoparse 0.3.3
Using json 1.8.3
Using nokogiri 1.5.10
Using aws-sdk-v1 1.64.0
Using aws-sdk 1.64.0
Using builder 3.2.2
Using excon 0.45.4
Using formatador 0.2.5
Using mime-types 1.25.1
Using net-ssh 2.9.2
Using net-scp 1.2.1
Using ruby-hmac 0.4.0
Using fog 1.11.1
Using minitar 0.5.4
Using thor 0.19.1
Using blimpy 0.6.7
Using docker-api 1.21.4
Using fission 0.5.0
Using multipart-post 2.0.0
Using faraday 0.9.1
Using jwt 1.5.1
Using launchy 2.4.3
Using retriable 1.4.1
Using signet 0.6.1
Using uuidtools 2.1.5
Using google-api-client 0.7.1
Using inifile 2.0.2
Using trollop 2.1.2
Using rbvmomi 1.8.1
Using unf_ext 0.0.7.1
Using unf 0.1.4
Using beaker 1.11.2
Using rspec-support 3.1.2
Using rspec-core 3.1.7
Using diff-lcs 1.2.5
Using rspec-expectations 3.1.2
Using rspec-mocks 3.1.3
Using rspec 3.1.0
Using beaker-rspec 2.0.0
Using facter 2.4.4
Using json_pure 1.8.2
Using hiera 1.3.4
Using hiera-puppet-helper 1.0.1
Using metaclass 0.0.4
Using mocha 1.1.0
Using puppet 3.7.5
Using rest-client 1.6.9
Using puppet-blacksmith 2.3.1
Using puppet-lint 1.1.0
Using puppet-syntax 2.0.0
Using rspec-puppet 2.2.1.pre from https://github.com/rodjek/rspec-puppet.git (at master)
Using puppetlabs_spec_helper 0.10.3
Using bundler 1.10.5
Bundle updated!

@chrisboulton
Copy link
Contributor

Very much looking forward to these changes! ✨ Was literally about to start on them myself.

@solarkennedy
Copy link
Contributor

Er, hold on, let me try to use a gemfile I know works...

@solarkennedy
Copy link
Contributor

Uh... aparently we have not been testing against the version of puppet that travis has been injecting...

@solarkennedy
Copy link
Contributor

Can you merge master and try to run the acceptance tests again?

Again I wouldn't sink that much time into this unless you are very eager.

@aj-jester
Copy link
Author

@solarkennedy Yah, I've put almost my entire day into this so I want to make this work! 😄

If I don't by tomorrow evening or something lets merge this since a lot of people are looking forward to this, apparently 😛

I'll let you know what happens.

@aj-jester
Copy link
Author

@solarkennedy I'm still working on these acceptance tests, but if its ok with you I'd say we merge this and when I have the tests ready I will make a new PR.

Thoughts?

@solarkennedy
Copy link
Contributor

Yes. My only other concern here is: are there configuration options that do require a restart? Can this code change get people into a situation where they make some sort of config change and it does not take effect?

@aj-jester
Copy link
Author

@solarkennedy Thats a valid concern. I tested each individual param to ensure just reloading is sufficient. Unfortunately the docs don't mention any config that does require a restart, it just puts service/check/watch under the "reloadable items" umbrella.

I'm actively using this change on a lot of instances and so far everything seems to be ok.

solarkennedy added a commit that referenced this pull request Jul 17, 2015
reload on service, checks and watch changes
@solarkennedy solarkennedy merged commit 297bab6 into voxpupuli:master Jul 17, 2015
@solarkennedy
Copy link
Contributor

Thanks! You are also now a contributor if you didn't get a notification. No need to fork if you don't want to.

@aj-jester
Copy link
Author

sweet! thanks 😄

@chrisboulton
Copy link
Contributor

Yup, all of the configurable params for watches, services, and checks seem to be reloadable - at least I've not had any issues where the changes haven't applied after a reload.

Thanks a bunch for working on these changes & getting them merged in @aj-jester & @solarkennedy! 👍 👍 👍 👍

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.

3 participants