summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChibuikem Amaechi <cramaechi@me.com>2018-01-10 22:47:22 -0600
committerChibuikem Amaechi <cramaechi@me.com>2018-01-10 22:47:22 -0600
commita1c2fa3d3f64d85e16ce45f66c3d1f8b516799ce (patch)
tree4432076427fca691b9df039ade14a5877792edf3
parent334264b3372c8e577ba630cd90c886b11d557e78 (diff)
downloadchef-a1c2fa3d3f64d85e16ce45f66c3d1f8b516799ce.tar.gz
Fix knife status to show seconds when needed #5055
When a node.save operation is executed and a "knife status" is immediately executed I get "xx minutes" instead of "xx seconds". The code behind 'knife status' isn't designed to have the ability to format the time difference in seconds. To remediate issue, make sure there is a condition in place to format the time difference in seconds when appropriate. Signed-off-by: Chibuikem Amaechi <cramaechi@me.com>
-rw-r--r--lib/chef/knife/core/status_presenter.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index f55f9abcbb..12f375365b 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -101,9 +101,10 @@ class Chef
fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn]
name = node["name"] || node.name
- hours, minutes, = time_difference_in_hms(node["ohai_time"])
+ hours, minutes, seconds = time_difference_in_hms(node["ohai_time"])
hours_text = "#{hours} hour#{hours == 1 ? ' ' : 's'}"
minutes_text = "#{minutes} minute#{minutes == 1 ? ' ' : 's'}"
+ seconds_text = "#{seconds} second#{seconds == 1 ? ' ' : 's'}"
run_list = "#{node['run_list']}" if config[:run_list]
if hours > 24
color = :red
@@ -111,9 +112,12 @@ class Chef
elsif hours >= 1
color = :yellow
text = hours_text
- else
+ elsif minutes >= 1
color = :green
text = minutes_text
+ else
+ color = :green
+ text = seconds_text
end
line_parts = Array.new