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

fix: 修复容器项目未创建ebpf仪表盘&请求k8sclient超时、404、403日志内容缩短 --bug=117685795 #385

Merged

Conversation

rxwycdh
Copy link
Collaborator

@rxwycdh rxwycdh commented Nov 28, 2023

No description provided.

@rxwycdh rxwycdh added project/apm project apm fix A bug fix. Correlates with PATCH in SemVer labels Nov 28, 2023
@@ -32,7 +32,8 @@ class Meta:


class ClusterRelation(models.Model):
bk_biz_id = models.IntegerField("业务id")
bk_biz_id = models.IntegerField("集群关联的BKCC业务id")
bkm_biz_id = models.IntegerField("监控的容器项目业务ID")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bk_biz_id、bkm_biz_id这两个名字有点混淆,实际bkm_biz_id是存储的bk_biz_id数据,bkm_biz_id存储的是关联业务ID,建议取名修改为
bk_biz_id -> related_bk_biz_id
bkm_biz_id -> bk_biz_id

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已调整

@@ -118,6 +118,31 @@ def perform_request(self, validated_request_data):
]


class GetProjectK8sClustersResource(BcsClusterManagerBaseResource):
"""获取项目下的非共享的K8S集群信息, 返回必要数据"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个resource取名有点问题,并没有说明不包含共享集群。对于使用的人有些迷惑,有两种改法

  1. 修改名称,指明返回内容不包含共享的集群
  2. 增加参数,带上是否包含共享集群的参数

Copy link
Collaborator Author

@rxwycdh rxwycdh Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已调整 GetProjectK8sClustersResource -》 GetProjectK8sNonSharedClustersResource

if self._check_deployment(content):
logger.info(
f"[DeepflowInstaller] (cluster: {self.cluster_id})found valid deployment: {content.name}"
with concurrent.futures.ThreadPoolExecutor() as executor:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么要使用新的线程池方案,而不是直接使用utils下的。新的线程池会导致一些上下文(时区、语言、用户、request)等信息传递不到位

Copy link
Collaborator Author

@rxwycdh rxwycdh Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的想法是需要超时处理,有些集群一直访问不到,在k8s sdk无法传递超时时间,就用线程池控制了


from metadata.models import Space

info = Space.objects.filter(space_id=project_code).first()
Copy link
Collaborator

@liuwenping liuwenping Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个查询逻辑,不太合理,这里已经知道是bkbcs的类型了。建议带上space_type直接查询。

另外其实自己字符串拼接一下也可以得到space_uid,看下代码里有没有类似的逻辑

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaceAPi提供的都是bk_biz_id - space_uid的互转,没有提供space_id到bk_biz_Id的转换,space_id在同步bcs容器项目的定时任务里面用的就是project_code,不能存space_uid,因为grafana那边org_name是业务id
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project_code -> space_uid -> bk_biz_id
是指第一步可以直接字符串拼接


from metadata.models import Space

info = Space.objects.filter(space_id=project_code).first()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project_code -> space_uid -> bk_biz_id
是指第一步可以直接字符串拼接

@liuwenping liuwenping merged commit 7f2b348 into TencentBlueKing:master Dec 7, 2023
4 checks passed
@chenguo367 chenguo367 changed the title fix: 修复容器项目未创建ebpf仪表盘&请求k8sclient超时、404、403日志内容缩短 fix: 修复容器项目未创建ebpf仪表盘&请求k8sclient超时、404、403日志内容缩短 --bug=117685795 Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A bug fix. Correlates with PATCH in SemVer project/apm project apm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants