...
1
16
17 package app
18
19 import (
20 "k8s.io/klog/v2"
21 "k8s.io/utils/inotify"
22
23 libcontainercgroups "github.com/opencontainers/runc/libcontainer/cgroups"
24 )
25
26 func watchForLockfileContention(path string, done chan struct{}) error {
27 watcher, err := inotify.NewWatcher()
28 if err != nil {
29 klog.ErrorS(err, "Unable to create watcher for lockfile")
30 return err
31 }
32 if err = watcher.AddWatch(path, inotify.InOpen|inotify.InDeleteSelf); err != nil {
33 klog.ErrorS(err, "Unable to watch lockfile")
34 watcher.Close()
35 return err
36 }
37 go func() {
38 select {
39 case ev := <-watcher.Event:
40 klog.InfoS("Inotify event", "event", ev)
41 case err = <-watcher.Error:
42 klog.ErrorS(err, "inotify watcher error")
43 }
44 close(done)
45 watcher.Close()
46 }()
47 return nil
48 }
49
50 func isCgroup2UnifiedMode() bool {
51 return libcontainercgroups.IsCgroup2UnifiedMode()
52 }
53
View as plain text