Repository navigation
feat(k8snode): bind container and pod sandbox IDs in all node component logs - #1028
Merged
Merged
Conversation
…nt logs Node logs emitted by components other than containerd and kubelet, such as gcfsd, reference container IDs and pod sandbox IDs, but KHI never resolved them. Pattern matching only attempted a match after a '"' or '=', so IDs written as 'ContainerID:<id>' or '/containers/<id>/' were missed, and the fallback mapper did not associate those logs with pod or container timelines at all. - Add patternfinder.FindAllHexTokens, which matches a registered pattern only when it forms a whole lowercase hexadecimal token. This finds IDs regardless of the surrounding punctuation and keeps an ID from matching inside a longer digest that shares its prefix. - Extract findPodAndContainerReferences, replacing the ID lookup duplicated across the log ingester and the containerd and kubelet mappers. - Associate logs of other node components with pod and container timelines.
kyasbal
requested review from
K53,
jyane,
kkuchima and
renamoo
as code owners
September 17, 2026 13:54
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new pattern-matching function FindAllHexTokens to identify lowercase hexadecimal tokens (such as container and pod sandbox IDs) within log messages, along with corresponding tests and benchmarks. It refactors several log mappers and ingesters to use a unified helper function findPodAndContainerReferences for resolving pod and container references. Feedback on the changes highlights a potential nil pointer dereference panic in findPodAndContainerReferences when pattern finders are nil (e.g., in dry-run mode), recommending explicit nil checks to ensure robustness.
Merged
via the queue into
GoogleCloudPlatform:main
with commit Sep 17, 2026
b14ad9b
17 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Resolves container IDs and pod sandbox IDs in node logs emitted by components other than
containerdandkubelet, such asgcfsd.Why
KHI builds a mapping from container IDs and pod sandbox IDs to the pods and containers they belong to, and uses it to replace unreadable IDs in log summaries and to attach logs to pod and container timelines. Two gaps prevented this from working outside
containerdandkubeletlogs.1. ID detection only started after
"or=.patternfinder.FindAllWithStarterRunes(raw, finder, false, '"', '=')attempts a match only when the preceding character is one of the listed delimiters. Other components punctuate IDs differently, so no match was ever found. For example, in agcfsdlog:the ID is preceded by
:and by/, so all three occurrences were missed.2. The fallback mapper never looked at IDs.
Pod and container timeline association existed only in
mapper_containerd.goandmapper_kubelet.go.mapper_fallback.go, which handles every other node component, only added an event to the component timeline.How
patternfinder.FindAllHexTokens. Container IDs and pod sandbox IDs are lowercase hexadecimal strings, so a genuine occurrence is always delimited by non-hexadecimal bytes on both ends. Matching on that boundary finds IDs regardless of the surrounding punctuation, removes the need to enumerate delimiters, and keeps a registered ID from matching inside a longer digest that merely shares its prefix.FindAllWithStarterRunesstays for resource UID lookups, which are not plain hexadecimal.findPodAndContainerReferencesinparser_utility.go, replacing the ID lookup that was duplicated across the log ingester and thecontainerdandkubeletmappers.mapper_fallback.goattach logs of other node components to pod and container timelines.registration.go.Out of scope
Resource UID (UUID) lookup is unchanged. UUIDs contain hyphens, so the hexadecimal token rule does not apply directly. A similar gap may exist there and is left for a separate change.
Testing
TestFindAllHexTokenscovers:,/,", and=delimiters, a match at the start of the text, rejection of a match embedded in a longer hexadecimal run on either side, repeated IDs, and unregistered IDs.TestFindPodAndContainerReferencescovers pod resolution, container resolution with the owning pod, omission of container IDs whose pod sandbox is unknown, and unregistered IDs.gcfsdcases verify summary replacement incommon_test.go, and pod and container timeline association inmapper_fallback_test.go.BenchmarkFindAllHexTokensWithContainerIDScenariomirrors the existing starter-rune benchmark.make pre-commit,make lint-go, andmake test-goall pass.