|
|
b9462c |
From f9a2eeb64054e740fb1ae3048dde153c257113c8 Mon Sep 17 00:00:00 2001
|
|
|
b9462c |
From: Ulrich Obergfell <uobergfe@redhat.com>
|
|
|
b9462c |
Date: Thu, 10 Oct 2019 11:16:50 +0200
|
|
|
b9462c |
Subject: [PATCH] revert changes introduced by "fix error handling in restore()
|
|
|
b9462c |
function", commit e96a10aef66e
|
|
|
b9462c |
(https://github.com/projectatomic/containerd/pull/10)
|
|
|
b9462c |
|
|
|
b9462c |
Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
|
|
|
b9462c |
---
|
|
|
b9462c |
runtime/container.go | 12 ++++++------
|
|
|
b9462c |
supervisor/supervisor.go | 11 +++--------
|
|
|
b9462c |
2 files changed, 9 insertions(+), 14 deletions(-)
|
|
|
b9462c |
|
|
|
b9462c |
diff --git a/runtime/container.go b/runtime/container.go
|
|
|
b9462c |
index 14002fc..2e9e663 100644
|
|
|
b9462c |
--- a/runtime/container.go
|
|
|
b9462c |
+++ b/runtime/container.go
|
|
|
b9462c |
@@ -146,15 +146,15 @@ func New(opts ContainerOpts) (Container, error) {
|
|
|
b9462c |
}
|
|
|
b9462c |
|
|
|
b9462c |
// Load return a new container from the matchin state file on disk.
|
|
|
b9462c |
-func Load(root, id, shimName string, timeout time.Duration) (Container, error, string) {
|
|
|
b9462c |
+func Load(root, id, shimName string, timeout time.Duration) (Container, error) {
|
|
|
b9462c |
var s state
|
|
|
b9462c |
f, err := os.Open(filepath.Join(root, id, StateFile))
|
|
|
b9462c |
if err != nil {
|
|
|
b9462c |
- return nil, err, "init"
|
|
|
b9462c |
+ return nil, err
|
|
|
b9462c |
}
|
|
|
b9462c |
defer f.Close()
|
|
|
b9462c |
if err := json.NewDecoder(f).Decode(&s); err != nil {
|
|
|
b9462c |
- return nil, err, "init"
|
|
|
b9462c |
+ return nil, err
|
|
|
b9462c |
}
|
|
|
b9462c |
c := &container{
|
|
|
b9462c |
root: root,
|
|
|
b9462c |
@@ -175,7 +175,7 @@ func Load(root, id, shimName string, timeout time.Duration) (Container, error, s
|
|
|
b9462c |
|
|
|
b9462c |
dirs, err := ioutil.ReadDir(filepath.Join(root, id))
|
|
|
b9462c |
if err != nil {
|
|
|
b9462c |
- return nil, err, "init"
|
|
|
b9462c |
+ return nil, err
|
|
|
b9462c |
}
|
|
|
b9462c |
for _, d := range dirs {
|
|
|
b9462c |
if !d.IsDir() {
|
|
|
b9462c |
@@ -184,7 +184,7 @@ func Load(root, id, shimName string, timeout time.Duration) (Container, error, s
|
|
|
b9462c |
pid := d.Name()
|
|
|
b9462c |
s, err := readProcessState(filepath.Join(root, id, pid))
|
|
|
b9462c |
if err != nil {
|
|
|
b9462c |
- return nil, err, pid
|
|
|
b9462c |
+ return nil, err
|
|
|
b9462c |
}
|
|
|
b9462c |
p, err := loadProcess(filepath.Join(root, id, pid), pid, c, s)
|
|
|
b9462c |
if err != nil {
|
|
|
b9462c |
@@ -193,7 +193,7 @@ func Load(root, id, shimName string, timeout time.Duration) (Container, error, s
|
|
|
b9462c |
}
|
|
|
b9462c |
c.processes[pid] = p
|
|
|
b9462c |
}
|
|
|
b9462c |
- return c, nil, ""
|
|
|
b9462c |
+ return c, nil
|
|
|
b9462c |
}
|
|
|
b9462c |
|
|
|
b9462c |
func readProcessState(dir string) (*ProcessState, error) {
|
|
|
b9462c |
diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go
|
|
|
b9462c |
index d92de8a..e21ae7b 100644
|
|
|
b9462c |
--- a/supervisor/supervisor.go
|
|
|
b9462c |
+++ b/supervisor/supervisor.go
|
|
|
b9462c |
@@ -364,15 +364,10 @@ func (s *Supervisor) restore() error {
|
|
|
b9462c |
continue
|
|
|
b9462c |
}
|
|
|
b9462c |
id := d.Name()
|
|
|
b9462c |
- container, err, pid := runtime.Load(s.stateDir, id, s.shim, s.timeout)
|
|
|
b9462c |
+ container, err := runtime.Load(s.stateDir, id, s.shim, s.timeout)
|
|
|
b9462c |
if err != nil {
|
|
|
b9462c |
- if (pid == "init") {
|
|
|
b9462c |
- logrus.WithFields(logrus.Fields{"error": err, "id": id}).Warnf("containerd: failed to load container,removing state directory.")
|
|
|
b9462c |
- os.RemoveAll(filepath.Join(s.stateDir, id))
|
|
|
b9462c |
- } else {
|
|
|
b9462c |
- logrus.WithFields(logrus.Fields{"error": err, "pid": pid}).Warnf("containerd: failed to load exec process,removing state directory.")
|
|
|
b9462c |
- os.RemoveAll(filepath.Join(s.stateDir, id, pid))
|
|
|
b9462c |
- }
|
|
|
b9462c |
+ logrus.WithFields(logrus.Fields{"error": err, "id": id}).Warnf("containerd: failed to load container,removing state directory.")
|
|
|
b9462c |
+ os.RemoveAll(filepath.Join(s.stateDir, id))
|
|
|
b9462c |
continue
|
|
|
b9462c |
}
|
|
|
b9462c |
processes, err := container.Processes()
|