From 403648a5769d86e5007fd46743902703ce6346e0 Mon Sep 17 00:00:00 2001 From: frikky Date: Fri, 26 Feb 2021 08:06:45 +0100 Subject: [PATCH] #275: Added check for whether the ID exists or not instead of opening new FD's --- functions/onprem/worker/worker.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/onprem/worker/worker.go b/functions/onprem/worker/worker.go index 259b3f06..7a11bb0c 100644 --- a/functions/onprem/worker/worker.go +++ b/functions/onprem/worker/worker.go @@ -52,6 +52,10 @@ var containerId string // form container id of current running container func getThisContainerId() string { + if len(containerId) > 0 { + return containerId + } + id := "" cmd := fmt.Sprintf("cat /proc/self/cgroup | grep memory | tail -1 | cut -d/ -f3 | grep -o -E '[0-9A-z]{64}'") out, err := exec.Command("bash", "-c", cmd).Output()