From c14785891f0e6fb533d3d6a54425d1b1ac51df13 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 Jul 2026 23:46:38 +0000 Subject: [PATCH] log: add debug logging to extractContainerIDFromCgroupFiles Add meaningful debug logging to the cgroup file scanning function in internal/sys/container.go to help troubleshoot container detection issues. The new log calls record: - How many cgroup files are being scanned - When a file is unreadable (with path and error) - When a container ID is successfully extracted (with path and ID) - When no container ID is found in a given file - When all files have been exhausted without finding an ID Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/sys/container.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/sys/container.go b/internal/sys/container.go index 673bf651f..1b7c7de84 100644 --- a/internal/sys/container.go +++ b/internal/sys/container.go @@ -88,15 +88,20 @@ func extractContainerIDFromCgroup() string { // extractContainerIDFromCgroupFiles reads the given cgroup files in order and // returns the first container ID found, or "" if none is extractable. func extractContainerIDFromCgroupFiles(paths []string) string { + logSys.Printf("Scanning %d cgroup file(s) for container ID", len(paths)) for _, cgroupPath := range paths { data, err := os.ReadFile(cgroupPath) if err != nil { + logSys.Printf("Skipping cgroup file (unreadable): path=%s, err=%v", cgroupPath, err) continue } if id := extractContainerIDFromContent(string(data)); id != "" { + logSys.Printf("Extracted container ID from cgroup file: path=%s, id=%s", cgroupPath, id) return id } + logSys.Printf("No container ID found in cgroup file: path=%s", cgroupPath) } + logSys.Print("No container ID found in any cgroup file") return "" }