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

Sup-346 update to include puppetserver metrics for versions < 2018.1.0 #3

Merged
merged 4 commits into from
Jul 25, 2018

Conversation

daniel5119
Copy link
Contributor

As per Sup-346 this is to include puppetserver metrics for versions < 2018.1.0

if $facts['pe_server_version'] < '2018.1.0' {

Pe_metric_curl_cron_jobs::Pe_metric <| title == 'puppetserver' |> {
additional_metrics => [
Copy link
Member

Choose a reason for hiding this comment

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

Couple of small changes:

  • When comparing version numbers, we should use the versioncmp() function as string comparison does odd things like treating 10 as being less than 2.

  • Using a collector override isn't necessary in this instance as we can pass the additional metrics directly to the puppet_metrics_collector::pe_metric declaration on line 15.

Something like the following:

if versioncmp($facts['pe_server_version'], '2018.1.0') < 0 {
  $additional_metrics = [
    ...
  ]
} else {
  $additional_metrics = []
}

puppet_metrics_collector::pe_metric { 'puppetserver' :
  ...,
  additional_metrics => $additional_metrics,
}

Copy link
Member

@Sharpie Sharpie left a comment

Choose a reason for hiding this comment

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

Almost there! There's an ordering issue, a parse failure, and some style lint that needs to be fixed up.

}
}

if versioncmp($facts['pe_server_version'], '2018.1.0') < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Variables must be declared before they are used. This if block has to appear before the puppet_metrics_collector::pe_metric that uses it.

{ 'name' => 'puppetdb.command.submit.store report',
'url' => "puppetserver:name=puppetlabs.${::hostname}.puppetdb.command.submit.store report" },
],
} else {
Copy link
Member

Choose a reason for hiding this comment

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

This else block is indented too far --- the braces should line up with the if above and then enclosed statements should be indented by one level.

$additional_metrics = []
}

}
Copy link
Member

Choose a reason for hiding this comment

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

There's an extra space before the final brace here that should be removed.

'url' => "puppetserver:name=puppetlabs.${::hostname}.puppetdb.report.convert_to_wire_format_hash" },
{ 'name' => 'puppetdb.command.submit.store report',
'url' => "puppetserver:name=puppetlabs.${::hostname}.puppetdb.command.submit.store report" },
],
Copy link
Member

Choose a reason for hiding this comment

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

Since this is the end of a variable assignment, the trailing comma is causing a parse failure. Would be appropriate for resource parameters, but doesn't work with assignment.

Copy link
Member

@Sharpie Sharpie left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@Sharpie Sharpie merged commit dd675d1 into puppetlabs:master Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants