From 9cd5cacc7c8cf4315cf1c0af77e25675b76d5f15 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Mon, 4 Nov 2013 22:04:40 -0500 Subject: [PATCH] [COOK-3805] Raise an exception if supervisorctl status output not recognized. Signed-off-by: Sean OMeara --- providers/service.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/providers/service.rb b/providers/service.rb index 2d08621..de63a5b 100644 --- a/providers/service.rb +++ b/providers/service.rb @@ -124,11 +124,18 @@ def cmd_line_args end def get_current_state(service_name) - result = Mixlib::ShellOut.new("supervisorctl status #{service_name}").run_command - if result.stdout.include? "No such process #{service_name}" + cmd = "supervisorctl status #{service_name}" + result = Mixlib::ShellOut.new(cmd).run_command + stdout = result.stdout + if stdout.include? "No such process #{service_name}" "UNAVAILABLE" else - result.stdout.match("(^#{service_name}\\s*)([A-Z]+)(.+)")[2] + match = stdout.match("(^#{service_name}\\s*)([A-Z]+)(.+)") + if match.nil? + raise "The supervisor service is not running as expected. " \ + "The command '#{cmd}' output:\n----\n#{stdout}\n----" + end + match[2] end end