From d64e06c213a35721ed37f28a0ba78bc552e16778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Casta=C3=B1=C3=A9?= Date: Tue, 28 Jan 2025 12:18:28 +0100 Subject: [PATCH] feat(internal): update Entity ID to new format `ci-` --- internal/container_linux.go | 6 +++--- internal/container_linux_test.go | 2 +- internal/container_stub.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/container_linux.go b/internal/container_linux.go index 237c293e21..6ac57029f9 100644 --- a/internal/container_linux.go +++ b/internal/container_linux.go @@ -48,7 +48,7 @@ var ( // containerID is the containerID read at init from /proc/self/cgroup containerID string - // entityID is the entityID to use for the container. It is the `cid-` if the container id available, + // entityID is the entityID to use for the container. It is the `ci-` if the container id available, // otherwise the cgroup node controller's inode prefixed with `in-` or an empty string on incompatible OS. // We use the memory controller on cgroupv1 and the root cgroup on cgroupv2. entityID string @@ -151,7 +151,7 @@ func readEntityID(mountPath, cgroupPath string, isHostCgroupNamespace bool) stri // First try to emit the containerID if available. It will be retrieved if the container is // running in the host cgroup namespace, independently of the cgroup version. if containerID != "" { - return "cid-" + containerID + return "ci-" + containerID } // Rely on the inode if we're not running in the host cgroup namespace. if isHostCgroupNamespace { @@ -161,7 +161,7 @@ func readEntityID(mountPath, cgroupPath string, isHostCgroupNamespace bool) stri } // EntityID attempts to return the container ID or the cgroup node controller's inode if the container ID -// is not available. The cid is prefixed with `cid-` and the inode with `in-`. +// is not available. The cid is prefixed with `ci-` and the inode with `in-`. func EntityID() string { return entityID } diff --git a/internal/container_linux_test.go b/internal/container_linux_test.go index 029ff647c4..83796086f7 100644 --- a/internal/container_linux_test.go +++ b/internal/container_linux_test.go @@ -93,7 +93,7 @@ func TestReadEntityIDPrioritizeCID(t *testing.T) { containerID = "fakeContainerID" eid := readEntityID("", "", true) - assert.Equal(t, "cid-fakeContainerID", eid) + assert.Equal(t, "ci-fakeContainerID", eid) } func TestReadEntityIDFallbackOnInode(t *testing.T) { diff --git a/internal/container_stub.go b/internal/container_stub.go index c6c2487406..38f4e5ce21 100644 --- a/internal/container_stub.go +++ b/internal/container_stub.go @@ -13,7 +13,7 @@ func ContainerID() string { } // EntityID attempts to return the container ID or the cgroup v2 node inode if the container ID is not available. -// The cid is prefixed with `cid-` and the inode with `in-`. +// The cid is prefixed with `ci-` and the inode with `in-`. func EntityID() string { return "" }