From d9057f39797b291c21fa89f97ba26394704d5842 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Wed, 28 Aug 2024 23:14:42 +0500 Subject: [PATCH] Stop on docker status instead of checking db pool or service.started as there is a race condition there --- src/middlewared/middlewared/plugins/apps/stats.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/middlewared/middlewared/plugins/apps/stats.py b/src/middlewared/middlewared/plugins/apps/stats.py index 272e072a904bf..3d067f12557cb 100644 --- a/src/middlewared/middlewared/plugins/apps/stats.py +++ b/src/middlewared/middlewared/plugins/apps/stats.py @@ -1,6 +1,7 @@ import time from middlewared.event import EventSource +from middlewared.plugins.docker.state_utils import Status from middlewared.schema import Dict, Int, Str, List from middlewared.service import CallError from middlewared.validators import Range @@ -63,10 +64,7 @@ def run_sync(self): old_projects_stats = project_stats time.sleep(interval) except Exception: - if self.middleware.call_sync('docker.config')['pool'] is None: - return - if self.middleware.call_sync('service.started', 'docker') is False: - self.middleware.logger.error('Unable to retrieve app stats as docker service has been stopped') + if self.middleware.call_sync('docker.status')['status'] != Status.RUNNING.value: return raise