summaryrefslogtreecommitdiff
path: root/lib/chef/knife/status.rb
diff options
context:
space:
mode:
authorJeff Blaine <jblaine@kickflop.net>2015-08-13 21:02:38 -0400
committerLamont Granquist <lamont@scriptkiddie.org>2015-10-24 17:57:57 -0700
commit8766e4b1012f51ab584f8eb2397ea43d6be92122 (patch)
tree6cbc4d071a4a11650dc2d44afac06ec9e9360984 /lib/chef/knife/status.rb
parent848b629b86e1394a76cab67d97e3a57925afa3b7 (diff)
downloadchef-8766e4b1012f51ab584f8eb2397ea43d6be92122.tar.gz
Changes --hide-healthy to --hide-by-mins MINS
Fixes #3679 Reasoning: The definition of "healthy" is overloaded in the old form (--hide-healthy) to be "a host that has run chef". The code makes no check to determine if the chef run was successful, so it has the capability to provide false positives for "health". Just because a node object was saved with ohai_time set doesn't mean the Chef run was successful. There are exception handlers like lastrun that intentionally save the node object on exception. The previous 1 hour hardcoded time was totally arbitrary. Perhaps "healthy" to others means "nodes that have run chef in the last 4 hours" (or 30 minutes, or 3 days...).
Diffstat (limited to 'lib/chef/knife/status.rb')
-rw-r--r--lib/chef/knife/status.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 95f2c724ff..e7a9b68ce6 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -41,10 +41,10 @@ class Chef
:long => "--sort-reverse",
:description => "Sort the status list by last run time descending"
- option :hide_healthy,
- :short => "-H",
- :long => "--hide-healthy",
- :description => "Hide nodes that have run chef in the last hour"
+ option :hide_by_mins,
+ :short => "-H MINS",
+ :long => "--hide-by-mins MINS",
+ :description => "Hide nodes that have run chef in the last MINS minutes"
def append_to_query(term)
@query << " AND " unless @query.empty?
@@ -67,11 +67,12 @@ class Chef
append_to_query(@name_args[0]) if @name_args[0]
append_to_query("chef_environment:#{config[:environment]}") if config[:environment]
- if config[:hide_healthy]
+ if config[:hide_by_mins]
+ hidemins = config[:hide_by_mins].to_i
time = Time.now.to_i
# AND NOT is not valid lucene syntax, so don't use append_to_query
@query << " " unless @query.empty?
- @query << "NOT ohai_time:[#{(time - 60*60).to_s} TO #{time.to_s}]"
+ @query << "NOT ohai_time:[#{(time - hidemins*60).to_s} TO #{time.to_s}]"
end
@query = @query.empty? ? "*:*" : @query