Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bcs采集项接口支持多配置 --story=120262545 #3531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions bklog/apps/log_databus/handlers/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3158,9 +3158,9 @@ def create_bcs_container_config(self, data, bk_app_code="bk_bcs"):
parent_container_config_id = 0
# 注入索引集标签
tag_id = IndexSetTag.get_tag_id(data["bcs_cluster_id"])
is_send_create_notify = False
is_send_path_create_notify = is_send_std_create_notify = False
for config in data["config"]:
if config["paths"]:
if config["paths"] and not is_send_path_create_notify:
# 创建路径采集项
path_collector_config = self.create_bcs_collector(
{
Expand All @@ -3186,11 +3186,11 @@ def create_bcs_container_config(self, data, bk_app_code="bk_bcs"):
conf=conf,
async_bkdata=False,
)
is_send_create_notify = True
is_send_path_create_notify = True
# 注入索引集标签
IndexSetHandler(path_collector_config.index_set_id).add_tag(tag_id=tag_id)

if config["enable_stdout"]:
if config["enable_stdout"] and not is_send_std_create_notify:
# 创建标准输出采集项
std_collector_config = self.create_bcs_collector(
{
Expand Down Expand Up @@ -3228,6 +3228,8 @@ def create_bcs_container_config(self, data, bk_app_code="bk_bcs"):
if collector_config_obj:
parent_container_config_id = collector_config_obj.collector_config_id

is_send_std_create_notify = True

container_collector_config_list = []
for config in data["config"]:
workload_type = config["container"].get("workload_type", "")
Expand Down Expand Up @@ -3297,9 +3299,12 @@ def create_bcs_container_config(self, data, bk_app_code="bk_bcs"):

ContainerCollectorConfig.objects.bulk_create(container_collector_config_list)

if is_send_create_notify:
if is_send_path_create_notify:
self.send_create_notify(path_collector_config)

if is_send_std_create_notify:
self.send_create_notify(std_collector_config)

return {
"rule_id": bcs_rule.id,
"rule_file_index_set_id": path_collector_config.index_set_id if path_collector_config else 0,
Expand Down Expand Up @@ -3488,7 +3493,7 @@ def update_bcs_container_config(self, data, rule_id, bk_app_code="bk_bcs"):
is_exist_bcs_std = True

# 如果还没有创建容器配置,那么当config["paths"]或config["enable_stdout"]存在时需要创建容器配置
if config["paths"] and not is_exist_bcs_path:
if config["paths"] and not is_exist_bcs_path and not is_send_path_create_notify:
# 创建路径采集项
path_collector_config = self.create_bcs_collector(
{
Expand Down Expand Up @@ -3517,7 +3522,7 @@ def update_bcs_container_config(self, data, rule_id, bk_app_code="bk_bcs"):
is_send_path_create_notify = True
# 注入索引集标签
IndexSetHandler(path_collector_config.index_set_id).add_tag(tag_id=tag_id)
if config["enable_stdout"] and not is_exist_bcs_std:
if config["enable_stdout"] and not is_exist_bcs_std and not is_send_std_create_notify:
# 创建标准输出采集项
std_collector_config = self.create_bcs_collector(
{
Expand Down
Loading