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

check-kube-service-available: Add --ignore-evicted #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here ](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Changed
- `check-kube-service-available.rb`: added `--ignore-evicted` which will ignore pods that are in the Evicted state (@dave-shawley)

## [5.0.2] - 2020-09-15
### Fixed
Expand Down
9 changes: 9 additions & 0 deletions bin/check-kube-service-available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# --token-file TOKEN-FILE File containing bearer token for authorization
# -l, --list SERVICES List of services to check (required)
# -p, --pending SECONDS Time (in seconds) a pod may be pending for and be valid
# --ignore-evicted Ignore evicted pods when calculating availability
#
# NOTES:
#
Expand Down Expand Up @@ -57,6 +58,12 @@ class AllServicesUp < Sensu::Plugins::Kubernetes::CLI
default: 0,
proc: proc(&:to_i)

option :ignoreEvicted,
description: 'Skip evicted pods when deciding if a service is available',
long: '--ignore-evicted',
boolean: true,
default: false

def run
services = parse_list(config[:service_list])
failed_services = []
Expand Down Expand Up @@ -103,6 +110,8 @@ def run
end
break if pod_available
end
when 'Evicted'
next if config[:ignoreEvicted]
end
failed_services << "#{p.metadata.namespace}.#{p.metadata.name}" if pod_available == false
end
Expand Down