Merge "Fix neutron probes under python3"

This commit is contained in:
Zuul 2019-03-27 23:38:34 +00:00 committed by Gerrit Code Review
commit 6b82435cfe

View File

@ -67,8 +67,9 @@ def check_agent_status(transport):
sys.stderr.write("Health probe unable to reach message bus") sys.stderr.write("Health probe unable to reach message bus")
sys.exit(0) # return success sys.exit(0) # return success
except oslo_messaging.rpc.client.RemoteError as re: except oslo_messaging.rpc.client.RemoteError as re:
if ("Endpoint does not support RPC method" in re.message) or \ message = getattr(re, "message", str(re))
("Endpoint does not support RPC version" in re.message): if ("Endpoint does not support RPC method" in message) or \
("Endpoint does not support RPC version" in message):
sys.exit(0) # Call reached the agent sys.exit(0) # Call reached the agent
else: else:
sys.stderr.write("Health probe unable to reach agent") sys.stderr.write("Health probe unable to reach agent")
@ -78,8 +79,9 @@ def check_agent_status(transport):
"timed out") "timed out")
sys.exit(1) # return failure sys.exit(1) # return failure
except Exception as ex: except Exception as ex:
message = getattr(ex, "message", str(ex))
sys.stderr.write("Health probe caught exception sending message to " sys.stderr.write("Health probe caught exception sending message to "
"agent: %s" % ex.message) "agent: %s" % message)
sys.exit(0) sys.exit(0)
except: except:
sys.stderr.write("Health probe caught exception sending message to" sys.stderr.write("Health probe caught exception sending message to"
@ -202,12 +204,13 @@ def test_socket_liveness():
"Neutron Metadata agent: " "Neutron Metadata agent: "
if se.strerror: if se.strerror:
sys.stderr.write(msg + se.strerror) sys.stderr.write(msg + se.strerror)
elif se.message: elif getattr(se, "message", False):
sys.stderr.write(msg + se.message) sys.stderr.write(msg + se.message)
sys.exit(1) # return failure sys.exit(1) # return failure
except Exception as ex: except Exception as ex:
message = getattr(ex, "message", str(ex))
sys.stderr.write("Health probe caught exception sending message to " sys.stderr.write("Health probe caught exception sending message to "
"Neutron Metadata agent: %s" % ex.message) "Neutron Metadata agent: %s" % message)
sys.exit(0) # return success sys.exit(0) # return success
if resp.status >= 500: # Probe expects HTTP error code 404 if resp.status >= 500: # Probe expects HTTP error code 404
@ -233,7 +236,8 @@ def test_rpc_liveness():
try: try:
transport = oslo_messaging.get_transport(cfg.CONF) transport = oslo_messaging.get_transport(cfg.CONF)
except Exception as ex: except Exception as ex:
sys.stderr.write("Message bus driver load error: %s" % ex.message) message = getattr(ex, "message", str(ex))
sys.stderr.write("Message bus driver load error: %s" % message)
sys.exit(0) # return success sys.exit(0) # return success
if not cfg.CONF.transport_url or \ if not cfg.CONF.transport_url or \