Martin Sivák has uploaded a new change for review. Change subject: Kill the agent if three subsequent broker requests fail ......................................................................
Kill the agent if three subsequent broker requests fail Change-Id: Ia5ec6935673133af2e60f339b035dba3438b617f Signed-off-by: Martin Sivak <msi...@redhat.com> --- M ovirt_hosted_engine_ha/agent/constants.py.in M ovirt_hosted_engine_ha/agent/hosted_engine.py 2 files changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha refs/changes/94/19294/1 diff --git a/ovirt_hosted_engine_ha/agent/constants.py.in b/ovirt_hosted_engine_ha/agent/constants.py.in index 7ab92aa..59fa965 100644 --- a/ovirt_hosted_engine_ha/agent/constants.py.in +++ b/ovirt_hosted_engine_ha/agent/constants.py.in @@ -57,3 +57,6 @@ SD_MOUNT_PARENT = '/rhev/data-center/mnt' SD_METADATA_DIR = 'ha_agent' LOCKSPACE_NAME = SERVICE_TYPE + +# Maximum request error count +MAX_ERROR_COUNT = 3 \ No newline at end of file diff --git a/ovirt_hosted_engine_ha/agent/hosted_engine.py b/ovirt_hosted_engine_ha/agent/hosted_engine.py index 2b8aac2..e6d8ccb 100644 --- a/ovirt_hosted_engine_ha/agent/hosted_engine.py +++ b/ovirt_hosted_engine_ha/agent/hosted_engine.py @@ -219,7 +219,10 @@ 'interval': constants.INTERMITTENT_LOG_INTERVAL_SECS} def start_monitoring(self): - while not self._shutdown_requested_callback(): + error_count = 0 + + while error_count < constants.MAX_ERROR_COUNT and \ + not self._shutdown_requested_callback(): try: self._initialize_broker() self._initialize_vdsm() @@ -239,14 +242,21 @@ self._log.warning("Unexpected error", exc_info=True) delay = 60 + error_count += 1 self._log.info("Sleeping %d seconds", delay) else: delay = 10 + error_count = 0 # All is well, reset the error counter self._log.debug("Sleeping %d seconds", delay) time.sleep(delay) + if error_count >= constants.MAX_ERROR_COUNT: + self._log.error("Shutting down the agent because a broker " + "request failed %d times in a row!", + constants.MAX_ERROR_COUNT) + self._log.debug("Disconnecting from ha-broker") if self._broker and self._broker.is_connected(): self._broker.disconnect() -- To view, visit http://gerrit.ovirt.org/19294 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia5ec6935673133af2e60f339b035dba3438b617f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-ha Gerrit-Branch: master Gerrit-Owner: Martin Sivák <msi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches