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: k8s meta index #2032

Merged
merged 3 commits into from
Jan 14, 2025
Merged

fix: k8s meta index #2032

merged 3 commits into from
Jan 14, 2025

Conversation

Abingcbc
Copy link
Collaborator

@Abingcbc Abingcbc commented Jan 10, 2025

问题

由于存在多个对象index相同的情况,所以索引中的value是一个数组。但是处理update事件时没有覆盖旧的索引,导致重复发送。

修复

  1. 将索引底层更换为一个set
  2. 修复生成link的逻辑
  3. 调整一些字段,Job的Status和namespace的label序列化为json

@Abingcbc Abingcbc force-pushed the k8s_meta branch 2 times, most recently from 2023b06 to d4c641e Compare January 12, 2025 06:24
pkg/helper/k8smeta/k8s_meta_cache.go Outdated Show resolved Hide resolved
pkg/helper/k8smeta/k8s_meta_link.go Outdated Show resolved Hide resolved
@@ -10,6 +10,24 @@ import (
"github.com/alibaba/ilogtail/pkg/logger"
)

type IndexItem struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

1、cache是内存密集型的,需要把内存通过指标体现出来
2、指标现在是否能通过Lens承载。指标现在比较多(包括之前的http请求),需要考虑后端的承载能力,不一定都会上报上来。

pkg/helper/k8smeta/k8s_meta_http_server.go Outdated Show resolved Hide resolved
plugins/input/kubernetesmetav2/meta_collector_batch.go Outdated Show resolved Hide resolved
@Abingcbc Abingcbc force-pushed the k8s_meta branch 2 times, most recently from 7791db0 to a1836d9 Compare January 12, 2025 16:20
@@ -169,36 +163,14 @@ func (m *MetaManager) RegisterSendFunc(projectName, configName, resourceType str
}
}

func (m *MetaManager) UnRegisterSendFunc(projectName, configName, resourceType string) {
if cache, ok := m.cacheMap[resourceType]; ok {
func (m *MetaManager) UnRegisterAllSendFunc(projectName, configName string) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这里是优化了一下锁。因为每种资源的cache unregister很快,在Manager这里不用频繁申请锁了,直接申请一次,全部遍历一遍

pkg/logtail/libGoPluginAdapter.so Outdated Show resolved Hide resolved
switch pod.OwnerReferences[0].Kind {
case "ReplicaSet":
switch {
case linkType == POD_REPLICASET && pod.OwnerReferences[0].Kind == "ReplicaSet":
Copy link
Collaborator

Choose a reason for hiding this comment

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

后续还得抽点时间改掉这个时间

event.Object.FirstObservedTime = obj.FirstObservedTime
oldIdxKeys = m.getIdxKeys(obj)
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果是update事件,还需要先delete再add吗?你这里怎么判断是1还是2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

update也需要先delete再add,因为新的索引和旧的索引可能不同,例如Pod的container id

@Abingcbc Abingcbc force-pushed the k8s_meta branch 2 times, most recently from 61f3ec5 to 9292932 Compare January 13, 2025 12:06
@linrunqi08 linrunqi08 merged commit 122a3bc into main Jan 14, 2025
15 checks passed
linrunqi08 pushed a commit that referenced this pull request Jan 14, 2025
@henryzhx8 henryzhx8 added the bug Something isn't working label Jan 15, 2025
@henryzhx8 henryzhx8 added this to the v3.0 milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants