diff --git a/config/default.py b/config/default.py index aa8f5f1284..79ab3d5c3b 100644 --- a/config/default.py +++ b/config/default.py @@ -797,6 +797,8 @@ def check_engine_admin_permission(request, *args, **kwargs): PIPELINE_ENGINE_ADMIN_API_PERMISSION = "config.default.check_engine_admin_permission" +TASK_STATUS_DISPLAY_VERSION = env.TASK_STATUS_DISPLAY_VERSION + BKCRYPTO = { "ASYMMETRIC_CIPHERS": { diff --git a/env.py b/env.py index 832acf7ae7..b8ad3b1de6 100644 --- a/env.py +++ b/env.py @@ -112,6 +112,9 @@ # 获取 PaaS 注入的蓝鲸域名 BKPAAS_BK_DOMAIN = os.getenv("BKPAAS_BK_DOMAIN", "") or os.getenv("BK_DOMAIN", "") +# 任务状态展示版本, v2 为支持了等待处理展示的版本,修改为 v1 会退化为不计算独立子任务的状态 +TASK_STATUS_DISPLAY_VERSION = os.getenv("BKAPP_TASK_STATUS_DISPLAY_VERSION", "v2") + # 获取加密类型 BKPAAS_BK_CRYPTO_TYPE = ( diff --git a/gcloud/core/context_processors.py b/gcloud/core/context_processors.py index b4bfb59836..be60adbe6d 100644 --- a/gcloud/core/context_processors.py +++ b/gcloud/core/context_processors.py @@ -127,6 +127,7 @@ def mysetting(request): "ENABLE_NOTICE_CENTER": enable_notice_center, "TASK_LIST_STATUS_FILTER_DAYS": settings.TASK_LIST_STATUS_FILTER_DAYS, "MESSAGE_HELPER_URL": settings.MESSAGE_HELPER_URL, + "TASK_STATUS_DISPLAY_VERSION": settings.TASK_STATUS_DISPLAY_VERSION, } # custom context config diff --git a/gcloud/taskflow3/domains/dispatchers/task.py b/gcloud/taskflow3/domains/dispatchers/task.py index 9066909f9c..66926a8576 100644 --- a/gcloud/taskflow3/domains/dispatchers/task.py +++ b/gcloud/taskflow3/domains/dispatchers/task.py @@ -24,6 +24,7 @@ from bamboo_engine.context import Context from bamboo_engine.eri import ContextValue from django.apps import apps +from django.conf import settings from django.db import transaction from django.utils import timezone from django.utils.translation import ugettext_lazy as _ @@ -768,7 +769,9 @@ def format_bamboo_engine_status( status_tree["state"] = TaskExtraStatus.PENDING_PROCESSING.value elif status_tree["state"] == bamboo_engine_states.RUNNING: # 独立子流程下钻 - if status_tree["id"] in node_ids_gby_code.get("subprocess_plugin", set()): + if settings.TASK_STATUS_DISPLAY_VERSION != "v1" and status_tree["id"] in node_ids_gby_code.get( + "subprocess_plugin", set() + ): self.handle_subprocess_node_status(status_tree) status_tree["subprocess_state"] = status_tree.get("state", "") # 已暂停 -> 等待处理 @@ -785,7 +788,9 @@ def format_bamboo_engine_status( status_tree["state"] = code__status_map[code] elif status_tree["state"] == bamboo_engine_states.FAILED: - if status_tree["id"] in node_ids_gby_code.get("subprocess_plugin", set()): + if settings.TASK_STATUS_DISPLAY_VERSION != "v1" and status_tree["id"] in node_ids_gby_code.get( + "subprocess_plugin", set() + ): AutoRetryNodeStrategy = apps.get_model("taskflow3", "AutoRetryNodeStrategy") if AutoRetryNodeStrategy.objects.filter(root_pipeline_id=status_tree["id"]).exists(): self.handle_subprocess_node_status(status_tree)