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
This commit is contained in:
Brian Haley 2019-01-24 16:19:01 -05:00 committed by Slawek Kaplonski
parent b86fa161ed
commit a8afd1f124
1 changed files with 6 additions and 0 deletions

View File

@ -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)