Skip to content

Update k8s meta with specific relation type #2224

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

Merged

Conversation

StartE
Copy link
Collaborator

@StartE StartE commented May 20, 2025

Pass relationtype to cluster-entity link by entity type
原 : 对于cluster到Namespace、Node的link的关系类型,默认runs,参数配置没有生效
现 : 基于具体的参数配置(Cluster2Namespace等) 进行关系类型设定

@StartE StartE requested review from messixukejia and Abingcbc May 20, 2025 03:04
@@ -241,8 +241,9 @@ func (m *metaCollector) handleAddOrUpdate(event *k8smeta.K8sMetaEvent) {
logs := processor(event.Object, "Update")
for _, log := range logs {
m.send(log, isEntity(event.Object.ResourceType))
if isEntity(event.Object.ResourceType) && canClusterLinkDirectly(event.Object.ResourceType, m.serviceK8sMeta) {
link := m.generateEntityClusterLink(log)
canClusterLinkDirectly, relationType := canClusterLinkDirectly(event.Object.ResourceType, m.serviceK8sMeta)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个变量名和函数名一致了,会覆盖函数变量

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

link := m.generateEntityClusterLink(log)
canClusterLinkDirectly, relationType := canClusterLinkDirectly(event.Object.ResourceType, m.serviceK8sMeta)
if isEntity(event.Object.ResourceType) && canClusterLinkDirectly {
link := m.generateEntityClusterLink(log, relationType)
Copy link
Collaborator

Choose a reason for hiding this comment

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

其他地方好像都叫linkType,不叫relationType

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image
这个定义就是relation type,为了清晰,此处改成linkRelationType

@@ -417,8 +419,11 @@ func (m *metaCollector) generateEntityClusterLink(entityEvent models.PipelineEve
log.Contents.Add(entityLinkDestDomainFieldName, m.serviceK8sMeta.domain)
log.Contents.Add(entityLinkDestEntityTypeFieldName, content.Get(entityTypeFieldName))
log.Contents.Add(entityLinkDestEntityIDFieldName, content.Get(entityIDFieldName))

log.Contents.Add(entityLinkRelationTypeFieldName, "runs")
if relationType != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里是不是保留空字符串就行了,其他关系也没配默认值

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@StartE StartE requested a review from Abingcbc May 20, 2025 06:14
@linrunqi08 linrunqi08 merged commit d4de16c into alibaba:main May 20, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants