def _monitoring_loop(self): vmuuid = self.get_uuid() log.info("monitor_loop handles VM %s" % (vmuuid)) start_time = time.time() docker.wipe_docker_other_config(self) # keep track of when to wipe other_config to safe CPU-time while not self._stop_monitoring_request: try: docker.update_docker_info(self) docker.update_docker_version(self) # if we got past the above, it's about time to delete the # error message, as all appears to be working again self._wipe_monitor_error_message_if_needed() try: try: self.__monitor_vm_events() finally: docker.wipe_docker_other_config(self) except (XenAPI.Failure, util.XSContainerException): log.exception("__monitor_vm_events threw an exception, " "will retry") raise except (XenAPI.Failure, util.XSContainerException): passed_time = time.time() - start_time if (not self._error_message and passed_time >= MONITOR_TIMEOUT_WARNING_S): self._send_monitor_error_message() log.info("Could not connect to VM %s, will retry" % (vmuuid)) if not self._stop_monitoring_request: time.sleep(MONITORRETRYSLEEPINS) # Make sure that we don't leave back error messsages for VMs that are # not monitored anymore self._wipe_monitor_error_message_if_needed() log.info("monitor_loop returns from handling vm %s" % (vmuuid))
def handle_docker_event(self, event): if 'status' in event: if event['status'] in ['create', 'destroy', 'die', 'kill', 'pause', 'restart', 'start', 'stop', 'unpause']: try: docker.update_docker_ps(self) except util.XSContainerException as exception: # This can happen, when the docker daemon stops log.exception(exception) elif event['status'] in ['create', 'destroy', 'delete']: try: docker.update_docker_info(self) except util.XSContainerException as exception: # This can happen, when the docker daemon stops log.exception(exception)
def handle_docker_event(self, event): if 'status' in event: if event['status'] in ['create', 'destroy', 'die', 'kill', 'pause', 'restart', 'start', 'stop', 'unpause']: try: docker.update_docker_ps(self) except util.XSContainerException, exception: # This can happen, when the docker daemon stops log.exception(exception) elif event['status'] in ['create', 'destroy', 'delete']: try: docker.update_docker_info(self) except util.XSContainerException, exception: # This can happen, when the docker daemon stops log.exception(exception)