From d4e53be7cea4e4af6dadb114e417cdaafe7cdee6 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:47:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9core=20celery=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=8A=B6=E6=80=81=20(#12684)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/terminal/models/component/terminal.py | 3 ++- apps/terminal/utils/components.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/terminal/models/component/terminal.py b/apps/terminal/models/component/terminal.py index a76d67dc6..0337fce69 100644 --- a/apps/terminal/models/component/terminal.py +++ b/apps/terminal/models/component/terminal.py @@ -19,6 +19,7 @@ logger = get_logger(__file__) class TerminalStatusMixin: id: str + type: str ALIVE_KEY = 'TERMINAL_ALIVE_{}' status_set: models.Manager @@ -29,7 +30,7 @@ class TerminalStatusMixin: @lazyproperty def load(self): from ...utils import ComputeLoadUtil - return ComputeLoadUtil.compute_load(self.last_stat) + return ComputeLoadUtil.compute_load(self.last_stat, self.type) @property def is_alive(self): diff --git a/apps/terminal/utils/components.py b/apps/terminal/utils/components.py index 2c3786dbf..692fe28fd 100644 --- a/apps/terminal/utils/components.py +++ b/apps/terminal/utils/components.py @@ -3,7 +3,7 @@ from itertools import groupby from common.utils import get_logger -from terminal.const import ComponentLoad +from terminal.const import ComponentLoad, TerminalType logger = get_logger(__name__) @@ -38,9 +38,13 @@ class ComputeLoadUtil: return system_status @classmethod - def compute_load(cls, stat): + def compute_load(cls, stat, terminal_type=None): if not stat: - return ComponentLoad.offline + # TODO The core component and celery component will return true for the time being. + if terminal_type in [TerminalType.core, TerminalType.celery]: + return ComponentLoad.normal + else: + return ComponentLoad.offline system_status_values = cls._compute_system_stat_status(stat).values() if ComponentLoad.critical in system_status_values: return ComponentLoad.critical