From bdf9bc576cc9617bb6a9643349bdf7397c545978 Mon Sep 17 00:00:00 2001 From: tangr Date: Thu, 4 Sep 2025 15:25:58 +0800 Subject: [PATCH] fix wehook trigger ok when http status failed (#718) Co-authored-by: tangshoubin --- cmdb-api/api/commands/click_cmdb.py | 4 +++- cmdb-api/api/lib/cmdb/ci.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmdb-api/api/commands/click_cmdb.py b/cmdb-api/api/commands/click_cmdb.py index ad43607..c1902d4 100644 --- a/cmdb-api/api/commands/click_cmdb.py +++ b/cmdb-api/api/commands/click_cmdb.py @@ -255,7 +255,9 @@ def cmdb_trigger(): try: ready_cis = CITriggerManager.waiting_cis(trigger) except Exception as e: - print(e) + import traceback + current_app.logger.error("cmdb trigger waiting_cis exception for trigger_id {}: {}".format(trigger.id, e)) + current_app.logger.error("traceback: {}".format(traceback.format_exc())) continue if trigger.id not in trigger2cis: diff --git a/cmdb-api/api/lib/cmdb/ci.py b/cmdb-api/api/lib/cmdb/ci.py index 6f49f4a..6f1998d 100644 --- a/cmdb-api/api/lib/cmdb/ci.py +++ b/cmdb-api/api/lib/cmdb/ci.py @@ -1618,7 +1618,8 @@ class CITriggerManager(object): ci_id, need_children=False, use_master=False, enum_use_label=True) try: - response = webhook_request(webhook, ci_dict).text + response = webhook_request(webhook, ci_dict) + response.raise_for_status() is_ok = True except Exception as e: current_app.logger.warning("exec webhook failed: {}".format(e))