Blob Blame History Raw
From f9a2eeb64054e740fb1ae3048dde153c257113c8 Mon Sep 17 00:00:00 2001
From: Ulrich Obergfell <uobergfe@redhat.com>
Date: Thu, 10 Oct 2019 11:16:50 +0200
Subject: [PATCH] revert changes introduced by "fix error handling in restore()
 function", commit e96a10aef66e
 (https://github.com/projectatomic/containerd/pull/10)

Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
---
 runtime/container.go     | 12 ++++++------
 supervisor/supervisor.go | 11 +++--------
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/runtime/container.go b/runtime/container.go
index 14002fc..2e9e663 100644
--- a/runtime/container.go
+++ b/runtime/container.go
@@ -146,15 +146,15 @@ func New(opts ContainerOpts) (Container, error) {
 }
 
 // Load return a new container from the matchin state file on disk.
-func Load(root, id, shimName string, timeout time.Duration) (Container, error, string) {
+func Load(root, id, shimName string, timeout time.Duration) (Container, error) {
 	var s state
 	f, err := os.Open(filepath.Join(root, id, StateFile))
 	if err != nil {
-		return nil, err, "init"
+		return nil, err
 	}
 	defer f.Close()
 	if err := json.NewDecoder(f).Decode(&s); err != nil {
-		return nil, err, "init"
+		return nil, err
 	}
 	c := &container{
 		root:        root,
@@ -175,7 +175,7 @@ func Load(root, id, shimName string, timeout time.Duration) (Container, error, s
 
 	dirs, err := ioutil.ReadDir(filepath.Join(root, id))
 	if err != nil {
-		return nil, err, "init"
+		return nil, err
 	}
 	for _, d := range dirs {
 		if !d.IsDir() {
@@ -184,7 +184,7 @@ func Load(root, id, shimName string, timeout time.Duration) (Container, error, s
 		pid := d.Name()
 		s, err := readProcessState(filepath.Join(root, id, pid))
 		if err != nil {
-			return nil, err, pid
+			return nil, err
 		}
 		p, err := loadProcess(filepath.Join(root, id, pid), pid, c, s)
 		if err != nil {
@@ -193,7 +193,7 @@ func Load(root, id, shimName string, timeout time.Duration) (Container, error, s
 		}
 		c.processes[pid] = p
 	}
-	return c, nil, ""
+	return c, nil
 }
 
 func readProcessState(dir string) (*ProcessState, error) {
diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go
index d92de8a..e21ae7b 100644
--- a/supervisor/supervisor.go
+++ b/supervisor/supervisor.go
@@ -364,15 +364,10 @@ func (s *Supervisor) restore() error {
 			continue
 		}
 		id := d.Name()
-		container, err, pid := runtime.Load(s.stateDir, id, s.shim, s.timeout)
+		container, err := runtime.Load(s.stateDir, id, s.shim, s.timeout)
 		if err != nil {
-			if (pid == "init") {
-				logrus.WithFields(logrus.Fields{"error": err, "id": id}).Warnf("containerd: failed to load container,removing state directory.")
-				os.RemoveAll(filepath.Join(s.stateDir, id))
-			} else {
-				logrus.WithFields(logrus.Fields{"error": err, "pid": pid}).Warnf("containerd: failed to load exec process,removing state directory.")
-				os.RemoveAll(filepath.Join(s.stateDir, id, pid))
-			}
+			logrus.WithFields(logrus.Fields{"error": err, "id": id}).Warnf("containerd: failed to load container,removing state directory.")
+			os.RemoveAll(filepath.Join(s.stateDir, id))
 			continue
 		}
 		processes, err := container.Processes()