-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 container enricher with correct container ids for pods with multiple containers #34516
Changes from 1 commit
696d5c6
8562596
cdc87ae
600fa30
bf865e7
e916112
2018930
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,7 +277,7 @@ func NewContainerMetadataEnricher( | |
if !ok { | ||
base.Logger().Debugf("Error while casting event: %s", ok) | ||
} | ||
meta := metaGen.Generate(pod) | ||
pmeta := metaGen.Generate(pod) | ||
|
||
statuses := make(map[string]*kubernetes.PodContainerStatus) | ||
mapStatuses := func(s []kubernetes.PodContainerStatus) { | ||
|
@@ -293,6 +293,7 @@ func NewContainerMetadataEnricher( | |
podStore, _ := nodeStore.AddPodStore(podId) | ||
|
||
for _, container := range append(pod.Spec.Containers, pod.Spec.InitContainers...) { | ||
cmeta := mapstr.M{} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 |
||
metrics := NewContainerMetrics() | ||
|
||
if cpu, ok := container.Resources.Limits["cpu"]; ok { | ||
|
@@ -314,14 +315,15 @@ func NewContainerMetadataEnricher( | |
// which is in the form of <container.runtime>://<container.id> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think is time to allign here also with kube_state container.id where container.runtime is not splitted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that is another issue right? Good if we can fix them both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be a breaking change. For state_container metricset as far as I see, the container.id is the same form. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. So it is time maybe to test here both container.ids and align them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does fixing mean? I prefer the splitted container.id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
split := strings.Index(s.ContainerID, "://") | ||
if split != -1 { | ||
kubernetes2.ShouldPut(meta, "container.id", s.ContainerID[split+3:], base.Logger()) | ||
kubernetes2.ShouldPut(cmeta, "container.id", s.ContainerID[split+3:], base.Logger()) | ||
|
||
kubernetes2.ShouldPut(meta, "container.runtime", s.ContainerID[:split], base.Logger()) | ||
kubernetes2.ShouldPut(cmeta, "container.runtime", s.ContainerID[:split], base.Logger()) | ||
} | ||
} | ||
|
||
id := join(pod.GetObjectMeta().GetNamespace(), pod.GetObjectMeta().GetName(), container.Name) | ||
m[id] = meta | ||
cmeta.DeepUpdate(pmeta) | ||
m[id] = cmeta | ||
} | ||
}, | ||
// delete | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we have a for here, but just doublehcecking if we can make a test wit 3 containers. In case we miss sth and compare with kube_state.container dataset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can reassure you it works because I tested it!