From a8afd1f124472f0d8f9d6c84836b851b1187b525 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Thu, 24 Jan 2019 16:19:01 -0500 Subject: [PATCH] Change Metering agent to log message after failure If the Metering agent fails to send its report_state to the server, it logs an exception: Failed reporting state!: MessagingTimeout: Timed out... If it then tries a second time and succeeds it just goes on happily. It would be nice if it logged that it had success on the subsequent attempt so someone looking at the logs know it recovered. Change-Id: If5522e5a975e05f195f1760d7fbd60264ac91fc3 --- neutron/services/metering/agents/metering_agent.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neutron/services/metering/agents/metering_agent.py b/neutron/services/metering/agents/metering_agent.py index 03540f8feb9..5b75498281f 100644 --- a/neutron/services/metering/agents/metering_agent.py +++ b/neutron/services/metering/agents/metering_agent.py @@ -247,6 +247,7 @@ class MeteringAgentWithStateReport(MeteringAgent): super(MeteringAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) + self.failed_report_state = False self.agent_state = { 'binary': 'neutron-metering-agent', 'host': host, @@ -278,7 +279,12 @@ class MeteringAgentWithStateReport(MeteringAgent): "State report for this agent will be disabled.") self.heartbeat.stop() except Exception: + self.failed_report_state = True LOG.exception("Failed reporting state!") + return + if self.failed_report_state: + self.failed_report_state = False + LOG.info("Successfully reported state after a previous failure.") def agent_updated(self, context, payload): LOG.info("agent_updated by server side %s!", payload)