Browse code

Fix error for restarting container

Fix error message for `--net container:b` and `--ipc container:b`,
container `b` is a restarting container.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>

Zhang Wei authored on 2016/02/02 21:36:13
Showing 2 changed files
... ...
@@ -975,6 +975,9 @@ func (daemon *Daemon) getIpcContainer(container *container.Container) (*containe
975 975
 	if !c.IsRunning() {
976 976
 		return nil, derr.ErrorCodeIPCRunning.WithArgs(containerID)
977 977
 	}
978
+	if c.IsRestarting() {
979
+		return nil, derr.ErrorCodeContainerRestarting.WithArgs(containerID)
980
+	}
978 981
 	return c, nil
979 982
 }
980 983
 
... ...
@@ -989,6 +992,9 @@ func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID st
989 989
 	if !nc.IsRunning() {
990 990
 		return nil, derr.ErrorCodeJoinRunning.WithArgs(connectedContainerID)
991 991
 	}
992
+	if nc.IsRestarting() {
993
+		return nil, derr.ErrorCodeContainerRestarting.WithArgs(connectedContainerID)
994
+	}
992 995
 	return nc, nil
993 996
 }
994 997
 
... ...
@@ -226,12 +226,12 @@ var (
226 226
 	})
227 227
 
228 228
 	// ErrorCodeIPCRunning is generated when we try to join a container's
229
-	// IPC but its not running.
229
+	// IPC but it's not running.
230 230
 	ErrorCodeIPCRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{
231 231
 		Value:          "IPCRUNNING",
232 232
 		Message:        "cannot join IPC of a non running container: %s",
233 233
 		Description:    "An attempt was made to join the IPC of a container, but the container is not running",
234
-		HTTPStatusCode: http.StatusInternalServerError,
234
+		HTTPStatusCode: http.StatusConflict,
235 235
 	})
236 236
 
237 237
 	// ErrorCodeNotADir is generated when we try to create a directory
... ...
@@ -265,7 +265,7 @@ var (
265 265
 		Value:          "JOINRUNNING",
266 266
 		Message:        "cannot join network of a non running container: %s",
267 267
 		Description:    "An attempt to join the network of a container, but that container isn't running",
268
-		HTTPStatusCode: http.StatusInternalServerError,
268
+		HTTPStatusCode: http.StatusConflict,
269 269
 	})
270 270
 
271 271
 	// ErrorCodeModeNotContainer is generated when we try to network to