OpenCost v1.121.1 keys its pod UID and phase maps by pod name, omitting namespace. For identically named pods in different namespaces, the last pod returned by GetAllPods() supplies both entries. Allocation metrics retain their namespace labels but receive the same UID, breaking joins on (namespace, pod, uid).
As of September 11, 2026, The defect remains in develop at a1b6790e
podStatus[pod.Name] = pod.Status.Phase
podUIDs[pod.Name] = string(pod.UID)
Direct exporter output confirmed the mismatch in container_cpu_allocation and container_memory_allocation_bytes. The emitted UID switched repeatedly while Kubernetes reported stable, distinct UIDs for the two pods.
Source shows the same lookup supplies UID labels for container_gpu_allocation and pod_pvc_allocation. The phase map controls containerSeen and metric cleanup, so an identically named pod in another namespace can also affect retention.
Reproduce
- Run
database-0 in namespaces team-a and team-b, with nonzero CPU and RAM requests. Confirm both are Running and record their Kubernetes UIDs.
- Inspect their CPU/RAM allocation series directly at OpenCost's
/metrics endpoint.
- Compare each series'
(namespace, pod, uid) labels with Kubernetes. Both pods receive the UID of the last same-named pod enumerated by the exporter. Node placement does not affect the lookup.
Example with placeholder UIDs when team-b is enumerated last:
| Pod |
Kubernetes UID |
Exported UID |
| team-a/database-0 |
uid-a |
uid-b |
| team-b/database-0 |
uid-b |
uid-b |
Fix
Key UID and phase by (namespace, pod). Allocation labels must use that pod's UID; lifecycle bookkeeping must use its phase. Missing metadata must not fall back to an identically named pod in another namespace.
#4040 implements the fix and tests namespace isolation with distinct UIDs/phases, reversed enumeration order, and missing metadata.
OpenCost v1.121.1 keys its pod UID and phase maps by pod name, omitting namespace. For identically named pods in different namespaces, the last pod returned by
GetAllPods()supplies both entries. Allocation metrics retain their namespace labels but receive the same UID, breaking joins on(namespace, pod, uid).As of September 11, 2026, The defect remains in
developat a1b6790eDirect exporter output confirmed the mismatch in
container_cpu_allocationandcontainer_memory_allocation_bytes. The emitted UID switched repeatedly while Kubernetes reported stable, distinct UIDs for the two pods.Source shows the same lookup supplies UID labels for
container_gpu_allocationandpod_pvc_allocation. The phase map controlscontainerSeenand metric cleanup, so an identically named pod in another namespace can also affect retention.Reproduce
database-0in namespacesteam-aandteam-b, with nonzero CPU and RAM requests. Confirm both are Running and record their Kubernetes UIDs./metricsendpoint.(namespace, pod, uid)labels with Kubernetes. Both pods receive the UID of the last same-named pod enumerated by the exporter. Node placement does not affect the lookup.Example with placeholder UIDs when
team-bis enumerated last:Fix
Key UID and phase by
(namespace, pod). Allocation labels must use that pod's UID; lifecycle bookkeeping must use its phase. Missing metadata must not fall back to an identically named pod in another namespace.#4040 implements the fix and tests namespace isolation with distinct UIDs/phases, reversed enumeration order, and missing metadata.