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

Improve version handling to avoid multiple puppet runs for some situa… #305

Closed

Conversation

bdellegrazie
Copy link
Contributor

…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):

  • collectd_version (i.e. the fact)
  • version (the semver matched part of it only)
  • minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references #162

@blkperl
Copy link
Member

blkperl commented Aug 6, 2015

PIng @txaj for review

@blkperl
Copy link
Member

blkperl commented Aug 6, 2015

Is it possible to write a spec test to test the new behavior?

@bdellegrazie bdellegrazie force-pushed the fix-multiple-puppet-runs branch 2 times, most recently from 193a792 to 89ed12e Compare August 6, 2015 18:24
@bdellegrazie
Copy link
Contributor Author

Hi @blkperl, I'd like to add tests for the new functionality but I'm very new to puppet-rspec and I'm not sure how. Specifically I'm having difficulty accessing the $_collectd_version created in init.pp as its essentially being used as a module-wide variable in the templates.
Do you have any suggestions?

@bdellegrazie
Copy link
Contributor Author

ping @blkperl and @txaj - any update or further comments?

###Puppet needs two runs to correctly write my conf, why?

Some plugins will need two runs of Puppet to fully generate the configuration for collectd. See [this issue](https://github.com/pdxcat/puppet-module-collectd/issues/162).
This can be avoided by specifying an explicit version (`$version`) or a minimum version (`$minimum_version`) to the collectd class
Copy link

Choose a reason for hiding this comment

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

Could you be more explicit about how this parameter works ? like "setting this parameter to 9.99 will makes this module assume at the first run (when the fact responsible to provide the collectd version is not yet avaibable) that your systems are running collectd 9.99, and generate the configuration accordingly"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will do

@txaj
Copy link

txaj commented Aug 16, 2015

@bdellegrazie for testing I only see one way : take a module that generates a different configuration depending on the collectd version, and test the output when you set the fact to undef/value1/value2 and the default to undef/value1/value2 and check that it makes sense

@bdellegrazie bdellegrazie force-pushed the fix-multiple-puppet-runs branch from 89ed12e to c95caea Compare August 20, 2015 21:37
@bdellegrazie bdellegrazie force-pushed the fix-multiple-puppet-runs branch 3 times, most recently from 69b4a8c to 43399b9 Compare September 15, 2015 06:32
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_real_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
@bdellegrazie bdellegrazie force-pushed the fix-multiple-puppet-runs branch from 43399b9 to 8c5e8ba Compare September 15, 2015 06:35
@bdellegrazie
Copy link
Contributor Author

@txaj, @blkperl: I've updated the PR to do the following:

  • renamed collectd_version fact to collectd_real_version
  • corrected an error with the regexp which selects the version for the templates.

I had to use a test module in the fixtures dir to be able to create the tests around the collect_version but they do work.

@igalic igalic closed this in e9dadff Sep 28, 2015
@igalic
Copy link
Contributor

igalic commented Sep 28, 2015

thanks @bdellegrazie and @txaj! i've merged this manually.

@igalic
Copy link
Contributor

igalic commented Sep 28, 2015

since merging this, we now have a failing test

@bdellegrazie do i understand it correctly, that we should be checking for collectd_real_version here (as well as in the code)?

@bdellegrazie
Copy link
Contributor Author

yes the fact should be collectd_real_version - I thought it was on my
branch?

On 28 September 2015 at 16:15, Igor Galić notifications@github.com wrote:

since merging this, we now have a failing test
https://github.com/puppet-community/puppet-collectd/blob/master/spec/classes/collectd_init_spec.rb#L73-L77

@bdellegrazie https://github.com/bdellegrazie do i understand it
correctly, that we should be checking for collectd_real_version here (as
well as in the code)?


Reply to this email directly or view it on GitHub
#305 (comment)
.

Kind regards,

Brett Delle Grazie

@bdellegrazie
Copy link
Contributor Author

Okay, I realise someone has added more tests (great!) but when merging the
fact needs to be collectd_real_version - then the internal
'collectd_version' variable that is used by the templates will resolve
correctly.

On 28 September 2015 at 16:41, Brett Delle Grazie <
brett.dellegrazie@gmail.com> wrote:

yes the fact should be collectd_real_version - I thought it was on my
branch?

On 28 September 2015 at 16:15, Igor Galić notifications@github.com
wrote:

since merging this, we now have a failing test
https://github.com/puppet-community/puppet-collectd/blob/master/spec/classes/collectd_init_spec.rb#L73-L77

@bdellegrazie https://github.com/bdellegrazie do i understand it
correctly, that we should be checking for collectd_real_version here (as
well as in the code)?


Reply to this email directly or view it on GitHub
#305 (comment)
.

Kind regards,

Brett Delle Grazie

Kind regards,

Brett Delle Grazie

@bdellegrazie bdellegrazie deleted the fix-multiple-puppet-runs branch September 28, 2015 20:02
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this pull request Sep 28, 2015
* When PR voxpupuli#305 was merged to master, it was based on an older master branch
A couple of tests had been added to the init class that were not updated with the merge.

This commit fixes those two tests
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this pull request Sep 28, 2015
* When PR voxpupuli#305 was merged to master, it was based on an older master branch
A couple of tests had been added to the init class that were not updated with the merge.

This commit fixes those two tests
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this pull request Sep 28, 2015
* When PR voxpupuli#305 was merged to master, it was based on an older master branch
A couple of tests had been added to the init class that were not updated with the merge.

This commit fixes those two tests
@igalic
Copy link
Contributor

igalic commented Sep 28, 2015

@bdellegrazie did i do a poor job of rebasing / merging your branch?

@bdellegrazie
Copy link
Contributor Author

@igalic I'd hardly count two functions as a poor merge :)
No, there is however something 'broken' with Puppet 4.0 according to Travis output from PR #343.
I don't know how to fix this one however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants