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

Implement Job LWRP #22

Merged
merged 9 commits into from
Mar 22, 2015
Merged

Conversation

ewr
Copy link
Contributor

@ewr ewr commented Mar 13, 2015

As promised in #20, here's a first-pass at a job LWRP. It uses chef-accumulator to gather the job resources and write them into the config template.

Generation of the config template is moved into the default recipe, although currently there's still also a config template resource in the source recipe. It seemed like at least runit would fail if I took it out, since it tries to start up the service before we've gotten to the end of the run. This duplication seems to work, but I don't like it.

I moved prometheus.source.user, prometheus.source.group and prometheus.source.use_existing_user under just the prometheus namespace, since I think it's important to be able to access those in places other than just the source recipe.

I'm sure there are job attributes I haven't accounted for, and I'm glad to add more before this gets merged. I just wanted to get it up earlier to make sure it was headed in the right direction.

ewr added 2 commits March 13, 2015 10:38
* Adds a `job` LWRP and an accumulator to write jobs into the prometheus
  config file.
* Move `prometheus.source.user` and `prometheus.source.group` to
  `prometheus.user` and `prometheus.group` so that we can use them in
  other recipes
* FIXME: `source` and `default` both define `template`s for the config file
* FIXME: Are there other attributes that the `job` resource needs to accept?
@@ -0,0 +1,7 @@
action :create do

Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra empty line detected at block body beginning.

@rayrod2030
Copy link

Looks like a great start. I don't like that our rubocop config enforces single space between method and first argument for cookbook/resources so feel free to add this block to .rubocop.yml:

Style/SingleSpaceBeforeFirstArg:
  Enabled: false

@rayrod2030 rayrod2030 mentioned this pull request Mar 13, 2015
@rayrod2030
Copy link

Hey @ewr I'd be happy to commit this PR if you can add that rubocop stanza which should remove some of these warnings and we can clean up the line endings. Otherwise I think it looks good and would make the cookbook way more usable for job configuration.


accumulator node['prometheus']['flags']['config.file'] do
filter { |res| res.is_a? Chef::Resource::PrometheusJob }
target :template => node['prometheus']['flags']['config.file']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

@ewr
Copy link
Contributor Author

ewr commented Mar 18, 2015

Thanks for the reminder... I had totally missed that the ball was in my court.

I added the Rubocop stanza, fixed an issue in how I was creating the target for the default self-scrape target, and went ahead and merged in master while I was in there. I only tested against default-ubuntu-1404, but I'm sure travis will let us know if I missed anything.

@rayrod2030
Copy link

Travis is probably failing based on some weird rubocop issues. I'll get it sorted after a merge. Thanks a bunch for this contribution @ewr!

@rayrod2030
Copy link

Hmm actually this actually needs a rebase or merge from master due to some previous PR's being merged. Care to fix this PR up before we can merge @ewr? Thanks.

ewr added 2 commits March 22, 2015 14:42
The fix for elijah#21 that was committed in 4188c51 had since gotten reverted in
the move to having a service recipe.
@ewr
Copy link
Contributor Author

ewr commented Mar 22, 2015

No problem. I merged instead of rebasing, but it should be clean now. It was just a non-conflict conflict in different dependencies getting added to metadata.rb.

I also snuck in de66789 to re-fix #21.

@ewr
Copy link
Contributor Author

ewr commented Mar 22, 2015

I think that travis rspec failure is related to the way chef-accumulator works, and rspec not seeing the template block write out its expected config. You can see in test-kitchen runs that the template does indeed get written, so I'm not sure whether you want to just pull that rspec test or whether it can be refactored.

@rayrod2030
Copy link

I'll try to pull it first then see a better way to verify that the accumulator is doing the right thing. Thanks for catching that regression on #21. I need to add a suite for chef 11.x to make sure it doesn't happen again. Merging!

rayrod2030 pushed a commit that referenced this pull request Mar 22, 2015
@rayrod2030 rayrod2030 merged commit a3b90a6 into elijah:master Mar 22, 2015
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