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

notifying influxes service after config change #140

Merged
merged 4 commits into from
Mar 6, 2017

Conversation

nilroy
Copy link
Contributor

@nilroy nilroy commented Feb 20, 2017

Restarting influxdb service in case of config change

Copy link
Owner

@bdangit bdangit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Please see comments.

end

service 'influxdb' do
action [:enable, :start]
supports :restart => true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got a syntax error.

RuboCop failed!
Running RuboCop...
Inspecting 27 files
...............C...........

Offenses:

recipes/default.rb:26:12: C: Use the new Ruby 1.9 hash syntax.
  supports :restart => true
           ^^^^^^^^^^^

I think this would work:

  supports { restart: true }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Ruby will interpret that as a block. But you can use supports(restart: true)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @alex-tan, you are right. supports(restart: true) compiles correctly.

Copy link
Contributor Author

@nilroy nilroy Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why rubocop is complaining it. Because in chef documentation they followed the same syntax in examples https://docs.chef.io/resource_service.html.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nilroy because Rubocop enforces a certain style of Ruby. restart: true and :restart => true are equivalent in the interpreter's eyes but some people like the style of the former better.

end

service 'influxdb' do
action [:enable, :start]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is making kitchen tests fail.

       Recipe: influxdb-test::default
         * influxdb_database[test_database] action createE, [2017-02-22T01:02:14.764101 #268] ERROR -- InfluxDB: Failed to contact host localhost: #<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 8086> - retrying in 0.01s.
       E, [2017-02-22T01:02:14.775251 #268] ERROR -- InfluxDB: Failed to contact host localhost: #<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 8086> - retrying in 0.02s.
       E, [2017-02-22T01:02:14.795949 #268] ERROR -- InfluxDB: Failed to contact host localhost: #<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 8086> - retrying in 0.04s.
       E, [2017-02-22T01:02:14.837212 #268] ERROR -- InfluxDB: Failed to contact host localhost: #<Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 8086> - retrying in 0.08s.
       E, [2017-02-22T01:02:14.919112 #268] ERROR -- InfluxDB: Failed to contact host 

Was there a reason why you removed it?

FYI, on initial setup of the cookbook, we require influxdb to be running so we can do some initialization of the database. ref: https://github.com/bdangit/chef-influxdb/blob/master/test/fixtures/cookbooks/influxdb-test/recipes/default.rb#L5-L8

This is at least assuming the user needs to setup the db right after the service has been installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when we change the influxdb config or create it for first time it should start the service. So I removed that.

Copy link
Contributor Author

@nilroy nilroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdangit I changed the recipe so it should start influxdb

end

service 'influxdb' do
action [:enable, :start]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when we change the influxdb config or create it for first time it should start the service. So I removed that.

end

service 'influxdb' do
action [:enable, :start]
supports(restart: true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if influxdb config change is not starting influxdb then I think the rubocop fixes are not good for chef.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @nilroy, the changes rubocop makes is all syntax reasons. Function should be unaffected.

If the desire is to restart the service when there is a new influxdb_config change, then what you have will work.

Copy link
Owner

@bdangit bdangit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are good and I verified them through kitchen verify. I am ready to merge; however, with your recent comments it sounds like there is still questions on this PR. Lets get them addressed before moving forward.

end

service 'influxdb' do
action [:enable, :start]
supports(restart: true)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @nilroy, the changes rubocop makes is all syntax reasons. Function should be unaffected.

If the desire is to restart the service when there is a new influxdb_config change, then what you have will work.

@nilroy
Copy link
Contributor Author

nilroy commented Mar 6, 2017

@bdangit Sorry for the confusion. I have nothing more to say about the PR and my last commit is having everything that we discussed. Please feel free to merge

@bdangit bdangit merged commit da113a8 into bdangit:master Mar 6, 2017
@bdangit
Copy link
Owner

bdangit commented Mar 6, 2017

thanks @nilroy!

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