Repository navigation
fix: skip Pod metadata retries for standalone containers - #1026
Conversation
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The reviewed standalone-container handling has no established issue that needs resolution before merge. Pre-merge checks |
|
matthyx
left a comment
There was a problem hiding this comment.
Reviewed 5d6287e0c14c2f8f64908d9a82f1aa02bd7c9d48 against main at 71818df6be721164d76daa67093d918c88e8c0c4. Verdict: approve. No change-related blockers found.
The fix is needed: #1025 describes a path still present on current main. Its watcher, rule-manager and network-stream regressions fail against main and pass on this head. For the rule-manager baseline I extracted the shared-data test alone, removing unused imports because later tests reference the new registration map. These are synthetic callback reproductions, not live runtime tests.
The namespace/Pod-name predicate matches the existing Kubernetes context detector. An addressable Pod still enters normal metadata/error handling even without a container name. Standalone registrations retain runtime monitoring, use independent runtime keys, and remove the original registration after metadata enrichment. Host handling and registration-scoped cancellation remain intact. The diff adds no dependencies or configuration/data-format changes; the identity map follows existing SafeMap usage and is deleted on removal. Existing callback concurrency limitations are not introduced by this change.
History: #887 fixed non-Kubernetes network attribution; #911 established context-filtered rules; #920 fixed monitor cancellation. None bypasses these standalone Pod waits. Open #993 concerns removal during profile registration, a separate path. #982 was explicitly deferred, not rejected; its host-identity lookup/cancellation concerns do not apply to this diff. #525 was superseded by #533 following worker-pool design discussion; this PR preserves that callback architecture. Closed #545 has supportive discussion, not a documented rejection.
All-state PR/issue searches used standalone, metadata, shared data, Pod metadata, missing Pod, containercallback, startRuleManager and registration/removal terms, capped at 100 results per query. No superseding fix found; GitHub search is indexed text, not an exhaustive diff/history search.
Validation in a credential-free Linux Go 1.27.1 container with capabilities dropped and read-only source archives:
go test -p 4 -race -count=1 -timeout=10m ./pkg/utils ./pkg/rulemanager ./pkg/containerwatcher/v2 ./pkg/networkstream/v1passed on rerun. The first run failed the unchangedTestListenerCache_CoalescesConcurrentReads(2 reads instead of 1). Running that test with-race -count=100on main reproduced the failure (2–3 reads), establishing it as pre-existing.- Focused
go test -p 4 -race -count=1 -timeout=3m -run 'Test.*Standalone'passed in the three callback packages. go vet -p 4passed in all four affected packages;git diff --checkpassed.- The fork workflow also succeeded; its checkout and SHA assertion bind tests/vet to this contribution head, despite the workflow run's different SHA.
DCO, GitGuardian and CodeRabbit succeed. Upstream build/component/benchmark workflows are action_required, so they provide no test result. Main protection currently has no required status-check contexts; approval is required. Full-project build/lint, component tests and live kernel/alert-export validation were not run locally. gopls tools were unavailable, so relationship inspection was manual. These limits do not leave a material correctness uncertainty for this scoped callback fix.
Overview
Standalone containers do not have a Kubernetes Pod to look up. They currently enter the Pod-metadata retry path anyway, which produces misleading errors and delays their monitoring setup.
Skip that lookup when the namespace or Pod name is missing, while retaining runtime monitoring and rule registration. Containers with an addressable Pod still use the existing lookup and error handling, including when their container name is incomplete.
Standalone monitors use the runtime container ID so separate containers do not share an empty Kubernetes identity. Removal retains that original identity even if Kubernetes metadata arrives later.
How to Test
On Linux, run the affected packages with the race detector:
go test -race ./pkg/utils ./pkg/rulemanager ./pkg/containerwatcher/v2 ./pkg/networkstream/v1 go vet ./pkg/utils ./pkg/rulemanager ./pkg/containerwatcher/v2 ./pkg/networkstream/v1The regressions cover standalone and partial identities, normal Pod error handling, network-stream setup, separate runtime IDs, and removal after metadata enrichment.
Linux validation passed. That fork-only workflow checks out and asserts contribution commit
5d6287e0c14c2f8f64908d9a82f1aa02bd7c9d48; it is not included in this PR. The regressions were also exercised before their fixes. Local Linux tests were not run on my macOS host.Related issues/PRs
Resolves #1025.
Checklist before requesting a review
The template mentions
dev, but that branch no longer exists. This targetsmain, consistent with recent merged code changes.Summary by CodeRabbit