56 lines
1.8 KiB
Diff
56 lines
1.8 KiB
Diff
|
|
From f66b0742f72a0f15c6b805751c00af2c7b0f3193 Mon Sep 17 00:00:00 2001
|
||
|
|
From: jingrui <jingrui@huawei.com>
|
||
|
|
Date: Wed, 20 Feb 2019 23:42:00 +0800
|
||
|
|
Subject: [PATCH 105/111] pause: fix pause on exited container
|
||
|
|
|
||
|
|
reason: fix pause on exited container
|
||
|
|
|
||
|
|
Change-Id: I109a88ab6832c3118f6be48f5924679549607740
|
||
|
|
Signed-off-by: jingrui <jingrui@huawei.com>
|
||
|
|
---
|
||
|
|
components/engine/daemon/freezer/freezer.go | 21 ++++++++++++++++++-
|
||
|
|
5 files changed, 26 insertions(+), 7 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/components/engine/daemon/freezer/freezer.go b/components/engine/daemon/freezer/freezer.go
|
||
|
|
index a0ef299852..907c7aac2a 100644
|
||
|
|
--- a/components/engine/daemon/freezer/freezer.go
|
||
|
|
+++ b/components/engine/daemon/freezer/freezer.go
|
||
|
|
@@ -12,6 +12,7 @@ import (
|
||
|
|
|
||
|
|
"github.com/opencontainers/runc/libcontainer/configs"
|
||
|
|
"github.com/opencontainers/runc/libcontainer/utils"
|
||
|
|
+ "github.com/sirupsen/logrus"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Freezer is the interface which could be used to pause/resume container,
|
||
|
|
@@ -131,7 +132,25 @@ func (f *freezer) Pause() error {
|
||
|
|
return fmt.Errorf("error: no tasks running in freeze cgroup")
|
||
|
|
}
|
||
|
|
|
||
|
|
- return f.updateCgroup(string(configs.Frozen))
|
||
|
|
+ err = f.updateCgroup(string(configs.Frozen))
|
||
|
|
+ if err != nil {
|
||
|
|
+ return err
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ tasks, err = readFile(f.path, "tasks")
|
||
|
|
+ if err != nil {
|
||
|
|
+ err := f.updateCgroup(string(configs.Thawed))
|
||
|
|
+ logrus.Warnf("revert pause due to no tasks file. revert-error=%v", err)
|
||
|
|
+ return fmt.Errorf("failed to check container cgroup task status: %v", err)
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ if strings.TrimSpace(tasks) == "" {
|
||
|
|
+ err := f.updateCgroup(string(configs.Thawed))
|
||
|
|
+ logrus.Warnf("revert pause due to no tasks. revert-error=%v", err)
|
||
|
|
+ return fmt.Errorf("error: no tasks running in freeze cgroup")
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// Resume will set the container to running state by writing freeze cgroup.
|
||
|
|
--
|
||
|
|
2.17.1
|
||
|
|
|