From 96aa3de4acd6c2c8cbb2ed958d146d6462ed0b09 Mon Sep 17 00:00:00 2001 From: matthewavery Date: Sat, 24 Feb 2018 18:28:08 -0800 Subject: [PATCH] Separate out personality errors and address them in the tests Also force a build --- lib/apiservers/engine/backends/container_proxy.go | 4 ++-- lib/apiservers/engine/backends/errors.go | 8 ++++++++ .../Group1-Docker-Commands/1-38-Docker-Exec.robot | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/apiservers/engine/backends/container_proxy.go b/lib/apiservers/engine/backends/container_proxy.go index 7ae3c2a08e..d0156b7ac1 100644 --- a/lib/apiservers/engine/backends/container_proxy.go +++ b/lib/apiservers/engine/backends/container_proxy.go @@ -341,7 +341,7 @@ func (c *ContainerProxy) InspectTask(op trace.Operation, handle string, eid stri case *tasks.InspectNotFound: // These error types may need to be expanded. NotFoundError does not fit here. op.Errorf("received a TaskNotFound error during task inspect: %s", err.Payload.Message) - return nil, TaskNotFoundError(fmt.Sprintf("container (%s) has been stopped", cid)) + return nil, TaskPoweredOffError(cid) case *tasks.InspectInternalServerError: op.Errorf("received an internal server error during task inspect: %s", err.Payload.Message) return nil, InternalServerError(err.Payload.Message) @@ -368,7 +368,7 @@ func (c *ContainerProxy) BindTask(op trace.Operation, handle string, eid string) switch err := err.(type) { case *tasks.BindNotFound: op.Errorf("received TaskNotFound error during task bind: %s", err.Payload.Message) - return "", TaskNotFoundError("container (%s) has been stopped") + return "", TaskBindPowerError() case *tasks.BindInternalServerError: op.Errorf("received unexpected error attempting to bind task(%s) for handle(%s): %s", eid, handle, err.Payload.Message) return "", InternalServerError(err.Payload.Message) diff --git a/lib/apiservers/engine/backends/errors.go b/lib/apiservers/engine/backends/errors.go index 6ba45563cc..5238f5e5a0 100644 --- a/lib/apiservers/engine/backends/errors.go +++ b/lib/apiservers/engine/backends/errors.go @@ -76,6 +76,14 @@ func TaskInspectNotFoundError(msg string) error { return derr.NewRequestNotFoundError(fmt.Errorf("No container was found with exec id: %s", msg)) } +func TaskBindPowerError() error { + return derr.NewRequestNotFoundError(fmt.Errorf("the container has been stopped")) +} + +func TaskPoweredOffError(msg string) error { + return derr.NewRequestNotFoundError(fmt.Errorf("container (%s) has been stopped", msg)) +} + func ImageNotFoundError(image, tag string) error { return derr.NewRequestNotFoundError(fmt.Errorf("An image does not exist locally with the tag: %s", image)) } diff --git a/tests/test-cases/Group1-Docker-Commands/1-38-Docker-Exec.robot b/tests/test-cases/Group1-Docker-Commands/1-38-Docker-Exec.robot index ad6dc4a01b..b2dea76303 100644 --- a/tests/test-cases/Group1-Docker-Commands/1-38-Docker-Exec.robot +++ b/tests/test-cases/Group1-Docker-Commands/1-38-Docker-Exec.robot @@ -27,6 +27,8 @@ Verify Poweroff During Exec Error Message Set Test Variable ${msg3} Unable to wait for task when container ${containerID} is not running Set Test Variable ${msg4} the Container(${containerID}) has been shutdown during execution of the exec operation Set Test Variable ${msg5} container(${containerID}) must be powered on in order to perform the desired exec operation + Set Test Variable ${msg6} the container has been stopped + Should Contain Any ${error} ${msg1} ${msg2} ${msg3} ${msg4} ${msg5} Verify No Poweroff During Exec Error Message