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 \