Skip to content

check-ec2-cpu_balance.rb: Make instance families configurable. - #320

Merged
majormoses merged 2 commits into
sensu-plugins:masterfrom
cyrilgdn:cpu_balance_t3
Feb 20, 2019
Merged

majormoses merged 2 commits into
sensu-plugins:masterfrom
cyrilgdn:cpu_balance_t3

Conversation

@cyrilgdn

@cyrilgdn cyrilgdn commented Jan 9, 2019

Copy link
Copy Markdown
Contributor

There's a new CPU burstable instance family: t3
I added it in the default value but thought it may be a good idea to add an option for that.
(So no need to wait for a plugin update when AWS will add another new burstable family.)

@majormoses

Copy link
Copy Markdown
Member

Thanks for your contribution to Sensu plugins! Without people like you submitting PRs we couldn't run the project. I will review it shortly.

@majormoses majormoses left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this looks good after fixing the typo. Could you please also include a changelog entry?

Comment thread bin/check-ec2-cpu_balance.rb Outdated
instances.reservations.each do |reservation|
reservation.instances.each do |instance|
next unless instance.instance_type.start_with? 't2.'
next unless instance.instance_type.start_with?(*config[:instance_families].split(','))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think * is a typo? Also it might make sense to do this when passed in the var, for example: https://github.com/sensu-plugins/sensu-plugins-aws/blob/16.1.0/bin/check-cloudwatch-alarms.rb#L53 this makes it easier to use in other locations in this check if that makes sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think * is a typo?

No, it's the splat operator because start_with does not take an array as argument but as many strings as we want.

Also it might make sense to do this when passed in the var, for example: https://github.com/sensu-plugins/sensu-plugins-aws/blob/16.1.0/bin/check-cloudwatch-alarms.rb#L53 this makes it easier to use in other locations in this check if that makes sense.

Totally, I was not aware of this proc attribute, I'll do that !

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh this might be a splat operator just saw the error with CI and assumed it was a typo.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah thanks for the explanation sorry I didnt see it, was not refreshed when I was looking.

@cyrilgdn

cyrilgdn commented Jan 9, 2019

Copy link
Copy Markdown
Contributor Author

Could you please also include a changelog entry?

@majormoses I already did. Or maybe I missed something ?

@majormoses

Copy link
Copy Markdown
Member

@cyrilgdn nope I must have been multitasking too much.

@majormoses

Copy link
Copy Markdown
Member

I will look into the CI failure this evening.

@cyrilgdn

cyrilgdn commented Jan 9, 2019

Copy link
Copy Markdown
Contributor Author

I will look into the CI failure this evening.

@majormoses Yes I was about to asking your help because it does not seem to be linked to what I've done.

Also it might make sense to do this when passed in the var

I moved the split in the proc attr.

@majormoses

Copy link
Copy Markdown
Member

Yes I was about to asking your help because it does not seem to be linked to what I've done.

Ya looks unrelated, I will let you know what I find and will probably commit a fix to your branch assuming you dont have an issue with that.

@majormoses

Copy link
Copy Markdown
Member

@cyrilgdn if you rebase from master it was fixed in #322

There's a new CPU burstable instance family: t3
I added it in the default value but thought it may be a good idea to add an option for that.
(So no need to wait for a plugin update when AWS will add another new burstable family.)

# Conflicts:
#	CHANGELOG.md
@cyrilgdn

Copy link
Copy Markdown
Contributor Author

@majormoses Done ! (but for now Travis build is pending since hours)

Comment thread bin/check-ec2-cpu_balance.rb Outdated
short: '-f t2,t3',
long: '--instance-families t2,t3',
proc: proc { |x| x.split(',') },
default: ['t2', 't3']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since you are doing a split(',') on input the default should be t2,t3

@majormoses

Copy link
Copy Markdown
Member

@majormoses Done ! (but for now Travis build is pending since hours)

Ya unfortunately we get so many concurrent builders from travis and I made a major release of sensu-plugin gem that 99% of all the plugins use as a base and dependabot probably opened up a bunch of PRs to update the dependency therefore clogging up the travis pipeline.

@cyrilgdn
cyrilgdn force-pushed the cpu_balance_t3 branch 2 times, most recently from 5d51ce0 to c0fb668 Compare February 19, 2019 10:38
@cyrilgdn

Copy link
Copy Markdown
Contributor Author

@majormoses Travis is green 👍

@majormoses majormoses left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@majormoses
majormoses merged commit 463f1d9 into sensu-plugins:master Feb 20, 2019
@majormoses

Copy link
Copy Markdown
Member

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.

2 participants