Skip to content

Commit

Permalink
fix(backend): 密码随机化增加错误信息 #8290
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud authored and zhangzhw8 committed Nov 29, 2024
1 parent 96ced77 commit 4756bb1
Show file tree
Hide file tree
Showing 18 changed files with 11,661 additions and 7,892 deletions.
10 changes: 5 additions & 5 deletions dbm-ui/backend/configuration/handlers/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from backend.db_periodic_task.models import DBPeriodicTask
from backend.db_services.ipchooser.query.resource import ResourceQueryHelper
from backend.db_services.taskflow.handlers import TaskFlowHandler
from backend.flow.consts import DEFAULT_INSTANCE, FAILED_STATES, SUCCEED_STATES
from backend.flow.consts import DEFAULT_INSTANCE, SUCCEED_STATES
from backend.flow.engine.bamboo.engine import BambooEngine
from backend.flow.engine.controller.mysql import MySQLController
from backend.flow.models import FlowTree
Expand Down Expand Up @@ -214,8 +214,8 @@ def query_async_modify_result(cls, root_id: str):
@param root_id: 任务ID
"""
flow_tree = FlowTree.objects.get(root_id=root_id)
# 任务未完成,退出
if flow_tree.status not in [*FAILED_STATES, *SUCCEED_STATES]:
# 任务未完成或失败,退出
if flow_tree.status not in [*SUCCEED_STATES]:
return {"status": flow_tree.status, "data": ""}

# 查询修改密码的节点id
Expand All @@ -224,8 +224,8 @@ def query_async_modify_result(cls, root_id: str):
0
]
# 查询输出数据
result = BambooEngine(root_id).get_node_output_data(node_id).data["resp"]["data"]
result.update(status=flow_tree.status)
resp = BambooEngine(root_id).get_node_output_data(node_id).data["resp"]
result = {"status": flow_tree.status, "error": resp["message"], "data": resp["data"], "result": resp["result"]}
return result

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dataclasses import asdict
from typing import List

from django.utils.translation import gettext as _
from django.utils.translation import ugettext as _

from backend import env
from backend.components import CCApi
Expand Down
2 changes: 1 addition & 1 deletion dbm-ui/backend/flow/engine/bamboo/scene/common/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_random_pass_act(self):
流程串联添加临时账号的活动节点
"""
act = self.add_act(
act_name="create job user",
act_name="create temp job account",
act_component_code=AddTempUserForClusterComponent.code,
kwargs={"cluster_ids": self.need_random_pass_cluster_ids},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -94,7 +94,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def run_flow(self):

# 创建随机账号
cluster_sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -202,7 +202,7 @@ def run_flow(self):

# 删除随机账号
cluster_sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(
DropRandomJobUserKwargs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -128,7 +128,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -136,7 +136,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -154,7 +154,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -257,7 +257,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -297,7 +297,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[target_cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def full_dts_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -290,7 +290,7 @@ def full_dts_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id, target_cluster.id])),
)
Expand Down Expand Up @@ -364,7 +364,7 @@ def incr_dts_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -484,7 +484,7 @@ def incr_dts_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id, target_cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def run_flow(self):

# 创建随机账号
cluster_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -196,7 +196,7 @@ def run_flow(self):

# 删除随机账号
cluster_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -136,7 +136,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def slave_rebuild_in_local_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -230,7 +230,7 @@ def slave_rebuild_in_local_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down Expand Up @@ -304,7 +304,7 @@ def slave_rebuild_in_new_slave_flow(self):

# 创建随机账号
cluster_sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand Down Expand Up @@ -428,7 +428,7 @@ def slave_rebuild_in_new_slave_flow(self):

# 删除随机账号
cluster_sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(
DropRandomJobUserKwargs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def run_flow(self):

# 创建随机账号
sub_pipeline.add_act(
act_name=_("create job user"),
act_name=_("create temp job account"),
act_component_code=SqlserverAddJobUserComponent.code,
kwargs=asdict(
CreateRandomJobUserKwargs(
Expand All @@ -162,7 +162,7 @@ def run_flow(self):

# 删除随机账号
sub_pipeline.add_act(
act_name=_("drop job user"),
act_name=_("remove temp job account"),
act_component_code=SqlserverDropJobUserComponent.code,
kwargs=asdict(DropRandomJobUserKwargs(cluster_ids=[cluster.id])),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def custom_ticket_flows(self):
]
# 如果存在dumper,则串dumper迁移流程
if self.check_cluster_dumper_migrate(self.ticket):
flows.append(
Flow(
ticket=self.ticket,
flow_type=FlowType.PAUSE.value,
details=self.pause_node_builder(self.ticket).get_params(),
flow_alias=_("人工确认"),
),
)
flows.append(
Flow(
ticket=self.ticket,
Expand Down
Loading

0 comments on commit 4756bb1

Please sign in to comment.