From e12061a4e08808c4318144d37b028eb820ae0bb5 Mon Sep 17 00:00:00 2001 From: Song Zhang Date: Sat, 31 Aug 2024 10:44:43 +0800 Subject: [PATCH] libcontainer/cgroups/fs: fix OCI runtime pause failed For some instance, runc pause still failed with `ctr: OCI runtime pause failed: unable to freeze: unknown`. We should let it sleep a longer time for some really very slow system or machine. Signed-off-by: Song Zhang --- libcontainer/cgroups/fs/freezer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libcontainer/cgroups/fs/freezer.go b/libcontainer/cgroups/fs/freezer.go index 987f1bf5e74..ed2de3dc2f3 100644 --- a/libcontainer/cgroups/fs/freezer.go +++ b/libcontainer/cgroups/fs/freezer.go @@ -58,6 +58,7 @@ func (s *FreezerGroup) Set(path string, r *configs.Resources) (Err error) { // Alas, this is still a game of chances, since the real fix // belong to the kernel (cgroup v2 do not have this bug). + var d time.Duration = 1 for i := 0; i < 1000; i++ { if i%50 == 49 { // Occasional thaw and sleep improves @@ -79,6 +80,14 @@ func (s *FreezerGroup) Set(path string, r *configs.Resources) (Err error) { // system. time.Sleep(10 * time.Microsecond) } + + if i%200 == 199 { + // should sleep a longer time for + // some really very slow machine. + time.Sleep(d * time.Second) + d <<= 1 + } + state, err := cgroups.ReadFile(path, "freezer.state") if err != nil { return err