From 514d54a5c0e495fc81694776408c43b87210fab5 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Wed, 20 Mar 2019 13:56:10 +0100 Subject: [PATCH] Fix neutron probes under python3 Under python3 an Exception no longer has the message attribute, instead you can just str the exception to get the error message Change-Id: I38225a76e01118b88353038ed7ef132d019dd976 --- neutron/templates/bin/_health-probe.py.tpl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/neutron/templates/bin/_health-probe.py.tpl b/neutron/templates/bin/_health-probe.py.tpl index af702e1eae..20d5ec2312 100644 --- a/neutron/templates/bin/_health-probe.py.tpl +++ b/neutron/templates/bin/_health-probe.py.tpl @@ -67,8 +67,9 @@ def check_agent_status(transport): sys.stderr.write("Health probe unable to reach message bus") sys.exit(0) # return success except oslo_messaging.rpc.client.RemoteError as re: - if ("Endpoint does not support RPC method" in re.message) or \ - ("Endpoint does not support RPC version" in re.message): + message = getattr(re, "message", str(re)) + 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 else: sys.stderr.write("Health probe unable to reach agent") @@ -78,8 +79,9 @@ def check_agent_status(transport): "timed out") sys.exit(1) # return failure except Exception as ex: + message = getattr(ex, "message", str(ex)) sys.stderr.write("Health probe caught exception sending message to " - "agent: %s" % ex.message) + "agent: %s" % message) sys.exit(0) except: sys.stderr.write("Health probe caught exception sending message to" @@ -202,12 +204,13 @@ def test_socket_liveness(): "Neutron Metadata agent: " if se.strerror: sys.stderr.write(msg + se.strerror) - elif se.message: + elif getattr(se, "message", False): sys.stderr.write(msg + se.message) sys.exit(1) # return failure except Exception as ex: + message = getattr(ex, "message", str(ex)) 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 if resp.status >= 500: # Probe expects HTTP error code 404 @@ -233,7 +236,8 @@ def test_rpc_liveness(): try: transport = oslo_messaging.get_transport(cfg.CONF) 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 if not cfg.CONF.transport_url or \