From 3c0c0adf121e44ee00b7191a2693575676eb90be Mon Sep 17 00:00:00 2001
From: jingrui <jingrui@huawei.com>
Date: Tue, 13 Nov 2018 15:38:05 +0800
Subject: [PATCH 73/94] runc: fix state.json: no such file or directory

reason: fix 8c14d652 * runc-17: add compatibility for docker-1.11.2

Change-Id: I8ff0b3ae90611dfb6e1f5fbd1b8170c460d9ea2d
Signed-off-by: jingrui <jingrui@huawei.com>
---
 libcontainer/factory_linux.go | 14 +++++++-------
 script/runc-euleros.spec      |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go
index b533346..fe9ce24 100644
--- a/libcontainer/factory_linux.go
+++ b/libcontainer/factory_linux.go
@@ -368,11 +368,11 @@ func (l *LinuxFactory) updateStateCapabilites(compatState *CompatState, configPa
 	return errors.New("updateStateCapabilites unexpected format for capabilities")
 }
 
-func (l *LinuxFactory) loadOriginState(configPath string) (*State, error) {
+func (l *LinuxFactory) loadOriginState(configPath, id string) (*State, error) {
 	f, err := os.Open(configPath)
 	if err != nil {
 		if os.IsNotExist(err) {
-			return nil, newGenericError(err, ContainerNotExists)
+			return nil, newGenericError(fmt.Errorf("container %q does not exist", id), ContainerNotExists)
 		}
 		return nil, newGenericError(err, SystemError)
 	}
@@ -384,11 +384,11 @@ func (l *LinuxFactory) loadOriginState(configPath string) (*State, error) {
 	return state, nil
 }
 
-func (l *LinuxFactory) loadCompatState(configPath string) (*State, error) {
+func (l *LinuxFactory) loadCompatState(configPath, id string) (*State, error) {
 	dt, err := ioutil.ReadFile(configPath)
 	if err != nil {
 		if os.IsNotExist(err) {
-			return nil, newGenericError(err, ContainerNotExists)
+			return nil, newGenericError(fmt.Errorf("container %q does not exist", id), ContainerNotExists)
 		}
 		return nil, newGenericError(err, SystemError)
 	}
@@ -403,14 +403,14 @@ func (l *LinuxFactory) loadCompatState(configPath string) (*State, error) {
 		return nil, newGenericError(err, SystemError)
 	}
 
-	return l.loadOriginState(configPath)
+	return l.loadOriginState(configPath, id)
 }
 
 func (l *LinuxFactory) loadState(root, id string) (*State, error) {
 	configPath := filepath.Join(root, stateFilename)
-	state, err := l.loadOriginState(configPath)
+	state, err := l.loadOriginState(configPath, id)
 	if err != nil {
-		return l.loadCompatState(configPath)
+		return l.loadCompatState(configPath, id)
 	}
 	return state, nil
 }
diff --git a/script/runc-euleros.spec b/script/runc-euleros.spec
index 16fb43c..536678d 100644
--- a/script/runc-euleros.spec
+++ b/script/runc-euleros.spec
@@ -2,7 +2,7 @@
 
 Name: docker-runc
 Version: 1.0.0.rc3
-Release: 11%{?dist}
+Release: 12%{?dist}
 Summary: runc is a CLI tool for spawning and running containers according to the OCF specification
 
 License: ASL 2.0
-- 
2.7.4.3

