Repository navigation
feat(k8saudit): show CiliumEndpoint under the owning Pod timeline - #1262
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to link resources owned by a Pod with the same namespace and name (such as CiliumEndpoint) to their parent Pods, even when audit logs do not record their manifests. This is achieved by updating resourceOwnerReferenceTimelineMapperTask to support a podOwnedTypesByName map and adding the isOwnedByPodWithSameName helper function. Corresponding documentation and unit tests have been added. The review feedback suggests optimizing isOwnedByPodWithSameName by replacing fmt.Sprintf with string concatenation to avoid unnecessary allocations in a hot path, normalizing apiVersion to handle core resources consistently, and using case-insensitive comparison for resource kinds.
7f1dd07 to
a487b19
Compare
a487b19 to
925a139
Compare
925a139 to
5dcae29
Compare
Code Quality Report — ✅ Cloud Build
|
5dcae29 to
171e10f
Compare
The Cilium agent creates a CiliumEndpoint with the same namespace and name as its Pod and sets the Pod as the owner. The owner reference mapper linked the CiliumEndpoint to the Pod only when audit logs recorded its manifest, but audit logs often record custom resources without their bodies. Link resources of the declared types to the Pod with the same namespace and name regardless of their manifests. The alias path is the same as the one derived from the ownerReferences in the manifest, so both rules point to the same timeline. This shows the creation and the deletion of the CiliumEndpoint next to the lifecycle of the Pod.
… nil check Extract parseOwnerIdentity from ProcessLog to keep cognitive complexity within budget, remove the redundant nil check on bodyReader (guaranteed non-nil by GetLastBodyReader when ok is true), and test missing apiVersion in ownerReferences.
171e10f to
7cdc927
Compare
Summary
Shows the
CiliumEndpointof a Pod under the Pod timeline (owns→<pod>[kind:ciliumendpoint]), even when audit logs do not record the CiliumEndpoint manifest.Stacked on #1261. Part of the GKE Dataplane V2 log support stack.
Motivation
The Cilium agent creates a
CiliumEndpointwith the same namespace and name as its Pod and sets the Pod as the owner. The owner reference mapper linked it to the Pod only when audit logs recorded its manifest withownerReferences. Audit logs often record custom resources at the Metadata level without bodies, so the CiliumEndpoint stayed in a separatecilium.io/v2 > ciliumendpointtimeline, away from the Pod lifecycle.Changes
common/k8saudit/impl/mapper_owner_reference.go: addedpodOwnedTypesByName = {"cilium.io#ciliumendpoint"}. Resources of these types are aliased under the Pod with the same namespace and name, whether or not their manifests are recorded.ownerReferencesin the manifest, so both rules point to the same timeline (no duplicates or errors; covered by tests).Screenshots
Verified on real audit logs: the CiliumEndpoint appears under its Pod with the same revisions as the
cilium.io/v2timeline.Verification
make pre-commitmake build-go && make lint-go && make test-goownsalias with the KHI MCP tools.