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

New Regex flag to filter container using Regex String. #69

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

parinapatel
Copy link

@parinapatel parinapatel commented Sep 21, 2018

Pull Request Checklist

Is this in reference to an existing issue?
No , but Filter by regex was feature I wanted for quite some time.

General

  • Update Changelog following the conventions laid out on Our CHANGELOG Guidelines

  • Update README with any necessary configuration snippets

  • Binstubs are created if needed

  • RuboCop passes

  • Existing tests pass

New Plugins

  • Tests

  • Add the plugin to the README

  • Does it have a complete header as outlined here

Purpose

Known Compatibility Issues

@majormoses
Copy link
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.

CHANGELOG.md Outdated
@@ -6,6 +6,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)

## [Unreleased]

## [3.1.2] - 2018
Copy link
Member

Choose a reason for hiding this comment

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

In general the versioning and dating are left to the maintainers for several reasons:

  • we may disagree on the impact of the change and therefore how its versioned. In this case it would be a minor version bump not a patch as you are adding new functionality. To better understand how we version you can read about it here
  • we date the release rather then when the contribution was submitted, PR review and acceptance has no SLA and is not guaranteed to be merged within the same day
  • PRs are not a FIFO queue, as such versioning them prior to acceptance leads to needing to ask people to rebase more often

CHANGELOG.md Outdated
@@ -6,6 +6,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)

## [Unreleased]

## [3.1.2] - 2018
### Added
- metrics-docker-stats.rb: New Regex flag to filter container using Regex String.
Copy link
Member

Choose a reason for hiding this comment

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

let's include the flag name here --container-list-regex

description: 'Regex for container list to collect metrics for',
short: '-R CONTAINER_LIST_REGEX',
long: '--container-list-regex CONTAINER_LIST_REGEX',
default: ''
Copy link
Member

Choose a reason for hiding this comment

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

any benefit of defaulting to an empty string vs just checking when its nil?

Copy link
Author

Choose a reason for hiding this comment

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

We can check as nil , I will refactor code to usenil.

def run
@timestamp = Time.now.to_i
@client = DockerApi.new(config[:docker_host])

list = if config[:container] != ''
[config[:container]]
elsif config[:container_list_regex] != ''
Copy link
Member

Choose a reason for hiding this comment

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

this can alternatively be expressed as elsif !config[:container_list_regex].empty? but I think it might be best to remove the default empty string and check for !config[:container_list_regex].nil?

@majormoses
Copy link
Member

Overall looks like a great improvement. I took a look at the CI failures, I will work on getting those clean this weekend.

@majormoses
Copy link
Member

So the CI failure is caused by ruby/net-telnet#14 where 0.2.0 dropped ruby < 2.3 support. We can pin it for now but I plan on releasing a major shortly after dropping support for the same to cut down on these kinds of issues saving maintainers time and because we also follow the policy of supporting the latest supporting versions of ruby only.

…nymore

Fixed up minor PR issues.

Signed-off-by: Ben Abrams <me@benabrams.it>
@parinapatel
Copy link
Author

its failing for ruby 2.1. @majormoses Would you take a look into it ? I though it was dropping support for ruby 2.3?

@majormoses
Copy link
Member

So the problem now was that net-ssh requires at least ruby 2.2:

Fetching: net-ssh-5.0.2.gem (100%)
       /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/installer.rb:611:in `ensure_required_ruby_version_met': net-ssh requires Ruby version >= 2.2.6. (Gem::InstallError)

Honestly at this point ruby < 2.3 is EOL so we should not put too much more effort into that and should just remove support and testing on our end. Here are the things you will want to add, remove, or edit:

In the changelog you will want a section such as this:

### Breaking Changes
- removed support for ruby versions `< 2.3.0` as they are EOL (@yourgithubuser)

This changelog entry should go above your other changes as we want people to first read about breaking changes and then what new features or fixes they want.

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