Log output of subprocess check_output() errors
This patch adds the command output text to the error logging when we use subprocess.check_output(). Change-Id: I2cee71d84fa70a077cfbd81096cbccccfecaad07
This commit is contained in:
parent
01efd68aa6
commit
414eeb65e9
@ -109,7 +109,7 @@ class Keepalived(object):
|
|||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.debug('Failed to enable octavia-keepalived service: '
|
LOG.debug('Failed to enable octavia-keepalived service: '
|
||||||
'%(err)s', {'err': e})
|
'%(err)s %(output)s', {'err': e, 'output': e.output})
|
||||||
return webob.Response(json=dict(
|
return webob.Response(json=dict(
|
||||||
message="Error enabling octavia-keepalived service",
|
message="Error enabling octavia-keepalived service",
|
||||||
details=e.output), status=500)
|
details=e.output), status=500)
|
||||||
@ -134,10 +134,11 @@ class Keepalived(object):
|
|||||||
try:
|
try:
|
||||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.debug('Failed to %s keepalived service: %s', action, e)
|
LOG.debug('Failed to %s octavia-keepalived service: %s %s',
|
||||||
|
action, e, e.output)
|
||||||
return webob.Response(json=dict(
|
return webob.Response(json=dict(
|
||||||
message="Failed to {0} keepalived service".format(action),
|
message="Failed to {0} octavia-keepalived service".format(
|
||||||
details=e.output), status=500)
|
action), details=e.output), status=500)
|
||||||
|
|
||||||
return webob.Response(
|
return webob.Response(
|
||||||
json=dict(message='OK',
|
json=dict(message='OK',
|
||||||
|
@ -141,7 +141,7 @@ class Listener(object):
|
|||||||
try:
|
try:
|
||||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.error("Failed to verify haproxy file: %s", e)
|
LOG.error("Failed to verify haproxy file: %s %s", e, e.output)
|
||||||
# Save the last config that failed validation for debugging
|
# Save the last config that failed validation for debugging
|
||||||
os.rename(name, ''.join([name, '-failed']))
|
os.rename(name, ''.join([name, '-failed']))
|
||||||
return webob.Response(
|
return webob.Response(
|
||||||
@ -225,8 +225,9 @@ class Listener(object):
|
|||||||
subprocess.check_output(init_enable_cmd.split(),
|
subprocess.check_output(init_enable_cmd.split(),
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.error("Failed to enable haproxy-%(list)s service: %(err)s",
|
LOG.error("Failed to enable haproxy-%(list)s service: "
|
||||||
{'list': listener_id, 'err': e})
|
"%(err)s %(out)s", {'list': listener_id, 'err': e,
|
||||||
|
'out': e.output})
|
||||||
return webob.Response(json=dict(
|
return webob.Response(json=dict(
|
||||||
message="Error enabling haproxy-{0} service".format(
|
message="Error enabling haproxy-{0} service".format(
|
||||||
listener_id), details=e.output), status=500)
|
listener_id), details=e.output), status=500)
|
||||||
@ -266,8 +267,10 @@ class Listener(object):
|
|||||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
if 'Job is already running' not in e.output:
|
if 'Job is already running' not in e.output:
|
||||||
LOG.debug("Failed to %(action)s HAProxy service: %(err)s",
|
LOG.debug(
|
||||||
{'action': action, 'err': e})
|
"Failed to %(action)s haproxy-%(list)s service: %(err)s "
|
||||||
|
"%(out)s", {'action': action, 'list': listener_id,
|
||||||
|
'err': e, 'out': e.output})
|
||||||
return webob.Response(json=dict(
|
return webob.Response(json=dict(
|
||||||
message="Error {0}ing haproxy".format(action),
|
message="Error {0}ing haproxy".format(action),
|
||||||
details=e.output), status=500)
|
details=e.output), status=500)
|
||||||
@ -299,7 +302,8 @@ class Listener(object):
|
|||||||
try:
|
try:
|
||||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.error("Failed to stop HAProxy service: %s", e)
|
LOG.error("Failed to stop haproxy-%s service: %s %s",
|
||||||
|
listener_id, e, e.output)
|
||||||
return webob.Response(json=dict(
|
return webob.Response(json=dict(
|
||||||
message="Error stopping haproxy",
|
message="Error stopping haproxy",
|
||||||
details=e.output), status=500)
|
details=e.output), status=500)
|
||||||
@ -342,7 +346,8 @@ class Listener(object):
|
|||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.error("Failed to disable haproxy-%(list)s service: "
|
LOG.error("Failed to disable haproxy-%(list)s service: "
|
||||||
"%(err)s", {'list': listener_id, 'err': e})
|
"%(err)s %(out)s", {'list': listener_id, 'err': e,
|
||||||
|
'out': e.output})
|
||||||
return webob.Response(json=dict(
|
return webob.Response(json=dict(
|
||||||
message="Error disabling haproxy-{0} service".format(
|
message="Error disabling haproxy-{0} service".format(
|
||||||
listener_id), details=e.output), status=500)
|
listener_id), details=e.output), status=500)
|
||||||
|
@ -184,7 +184,8 @@ class BaseOS(object):
|
|||||||
try:
|
try:
|
||||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.error('Failed to if up %s due to error: %s', interface, e)
|
LOG.error('Failed to ifup %s due to error: %s %s', interface, e,
|
||||||
|
e.output)
|
||||||
raise exceptions.HTTPException(
|
raise exceptions.HTTPException(
|
||||||
response=webob.Response(json=dict(
|
response=webob.Response(json=dict(
|
||||||
message='Error plugging {0}'.format(what),
|
message='Error plugging {0}'.format(what),
|
||||||
@ -197,8 +198,9 @@ class BaseOS(object):
|
|||||||
ns=consts.AMPHORA_NAMESPACE, params=interface))
|
ns=consts.AMPHORA_NAMESPACE, params=interface))
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError as e:
|
||||||
pass
|
LOG.info('Ignoring failure to ifdown %s due to error: %s %s',
|
||||||
|
interface, e, e.output)
|
||||||
|
|
||||||
def bring_interfaces_up(self, ip, primary_interface, secondary_interface):
|
def bring_interfaces_up(self, ip, primary_interface, secondary_interface):
|
||||||
self._bring_if_down(primary_interface)
|
self._bring_if_down(primary_interface)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user