Retry CGroup detection using pid
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-09-25 18:53:14 +02:00
parent 4ed99e4822
commit 5be73f9ff9

14
main.go
View File

@@ -15,6 +15,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
@@ -99,10 +100,17 @@ func listenForMounts() {
panic(err)
} else {
pid := info.State.Pid
version, err := cgroup.GetDeviceCGroupVersion("/", pid)
var version int
var err error
for i := 0; i < 20; i++ {
version, err = cgroup.GetDeviceCGroupVersion("/", pid)
if err == nil {
break
} else {
time.Sleep(200 * time.Millisecond)
}
}
log.Printf("The cgroup version for process %d is: %v\n", pid, version)
if err != nil {
log.Println(err)
break