Skip to content

Commit

Permalink
feat: 任务状态展示支持降级 #6653
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Mar 11, 2024
1 parent 8ff3675 commit 99cc4e8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
1 change: 1 addition & 0 deletions gcloud/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions gcloud/taskflow3/domains/dispatchers/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down Expand Up @@ -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", "")
# 已暂停 -> 等待处理
Expand All @@ -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)
Expand Down

0 comments on commit 99cc4e8

Please sign in to comment.