Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#1176 from hanshuaikang/feature/dev…
Browse files Browse the repository at this point in the history
…elop_by_han

minor: 补充bk sops插件的日志
  • Loading branch information
hanshuaikang authored Aug 18, 2023
2 parents 5e6200f + 5259687 commit 942d10e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app_desc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ modules:
plan: 4C1G5R
replicas: 1
pworker:
command: python manage.py celery worker -n prefork@%h -P threads -c 10 -l info -O fair --maxtasksperchild=100
command: python manage.py celery worker -n prefork@%h -P threads -c 10 -l info --maxtasksperchild=100
plan: 4C2G5R
replicas: 5
gworker:
Expand Down
4 changes: 3 additions & 1 deletion itsm/iadmin/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def validate_sys_file_path(value):
logger.error("测试路径移除异常:%s" % e)
except Exception as e:
logger.error("PathTypeValidators:路径无法写入, %s" % e)
raise AnnexStoreValidateError(_("路径无法写入,请联系管理员!"))
raise AnnexStoreValidateError(
"路径无法写入, path = {}. err={},请联系管理员!".format(path, str(e))
)

@staticmethod
def validate_is_organization(value):
Expand Down
32 changes: 30 additions & 2 deletions itsm/pipeline_plugins/components/collections/bk_sops.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ def execute(self, data, parent_data):
)
return False

logger.info(
"[bk_sops_execute] start sops task success, task_id = {}".format(
sops_task_id
)
)
data.set_outputs("sops_task_id", sops_task_id)
data.set_outputs("bk_biz_id", task_params["bk_biz_id"])
data.set_outputs("api_info", api_info)
Expand All @@ -244,6 +249,12 @@ def execute(self, data, parent_data):
def schedule(self, data, parent_data, callback_data=None):

sops_task_id = data.outputs.get("sops_task_id", None)
logger.info(
"[bk_sops_schedule] start query task status, task_id = {}".format(
sops_task_id
)
)

bk_biz_id = data.outputs.get("bk_biz_id", None)
api_info = data.outputs.get("api_info", None)
state_id = data.inputs.state_id
Expand Down Expand Up @@ -295,6 +306,7 @@ def schedule(self, data, parent_data, callback_data=None):
)
self.finish_schedule()
return False

if task_result.get("result", False) is False:
error_message = task_result.get("message", "")
self.do_exit_plugins(
Expand All @@ -313,8 +325,19 @@ def schedule(self, data, parent_data, callback_data=None):
task_info = task_result.get("data", {})

current_status = task_info.get("state")
logger.info(
"[bk_sops_schedule] get task state success, state = {}".format(
current_status
)
)

if current_status in ["CREATED", "RUNNING", "SUSPENDED"]:
# 还在执行过程中,继续轮询
logger.info(
"[bk_sops_schedule] task_id = {}, state={}".format(
sops_task_id, current_status
)
)
return True
if current_status in ["FAILED", "REVOKED"]:
data.set_outputs("params_sops_result_%s" % state_id, False)
Expand All @@ -335,6 +358,11 @@ def schedule(self, data, parent_data, callback_data=None):
return False

if current_status in ["FINISHED"]:
logger.info(
"[bk_sops_schedule] task_id = {}, state={}".format(
sops_task_id, current_status
)
)
data.set_outputs("params_sops_result_%s" % state_id, True)
self.finish_schedule()
self.update_info(current_node, sops_result, result=True)
Expand Down Expand Up @@ -366,8 +394,8 @@ def get_detail_message(task_params, task_info, task_node):
task_params.update({"__raw": True, "node_id": child["id"]})
result = client_backend.sops.get_task_node_detail(task_params)
error_messages.append(
u"{}:{}".format(
child["name"], result.get("data", {}).get("ex_data") or u"未知错误"
"{}:{}".format(
child["name"], result.get("data", {}).get("ex_data") or "未知错误"
)
)
return "\n".join(error_messages)
Expand Down
2 changes: 1 addition & 1 deletion itsm/pipeline_plugins/components/collections/itsm_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AutoStateService(ItsmBaseService):
"""

__need_schedule__ = True
interval = StaticIntervalGenerator(1)
interval = StaticIntervalGenerator(3)

@staticmethod
def poll_proceed(api_config, success_conditions):
Expand Down
2 changes: 0 additions & 2 deletions itsm/pipeline_plugins/components/collections/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
ItsmBaseService,
)
from itsm.ticket.models import Ticket, TicketGlobalVariable, SYSTEM_OPERATE
from pipeline.core.flow.activity import StaticIntervalGenerator

logger = logging.getLogger("celery")

Expand Down Expand Up @@ -128,7 +127,6 @@ class WebHookService(ItsmBaseService):
"""

__need_schedule__ = False
interval = StaticIntervalGenerator(1)

def update_info(self, current_node, **kwargs):
"""
Expand Down

0 comments on commit 942d10e

Please sign in to comment.