rabbah closed pull request #3159: Sanitize error message returned by a failed
container startup.
URL: https://github.com/apache/incubator-openwhisk/pull/3159
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
b/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
index c6ee4ae4cc..cd0b170eb8 100644
--- a/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
+++ b/common/scala/src/main/scala/whisk/http/ErrorResponse.scala
@@ -187,6 +187,12 @@ object Messages {
val actionRemovedWhileInvoking = "Action could not be found or may have been
deleted."
val actionMismatchWhileInvoking = "Action version is not compatible and
cannot be invoked."
val actionFetchErrorWhileInvoking = "Action could not be fetched."
+
+ /** Indicates that the image could not be pulled. */
+ def imagePullError(image: String) = s"Failed to pull container image
'$image'."
+
+ /** Indicates that the container for the action could not be started. */
+ val resourceProvisionError = "Failed to provision resources to run the
action."
}
/** Replaces rejections with Json object containing cause and transaction id.
*/
diff --git
a/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
b/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
index c3f89c59e3..b8212004bf 100644
--- a/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
+++ b/core/invoker/src/main/scala/whisk/core/containerpool/ContainerProxy.scala
@@ -148,7 +148,7 @@ class ContainerProxy(
val response = t match {
case WhiskContainerStartupError(msg) =>
ActivationResponse.whiskError(msg)
case BlackboxStartupError(msg) =>
ActivationResponse.applicationError(msg)
- case _ =>
ActivationResponse.whiskError(t.getMessage)
+ case _ =>
ActivationResponse.whiskError(Messages.resourceProvisionError)
}
// construct an appropriate activation and record it in the
datastore,
// also update the feed and active ack; the container cleanup is
queued
diff --git
a/core/invoker/src/main/scala/whisk/core/containerpool/docker/DockerContainer.scala
b/core/invoker/src/main/scala/whisk/core/containerpool/docker/DockerContainer.scala
index f24b35b81e..2fc5f758e8 100644
---
a/core/invoker/src/main/scala/whisk/core/containerpool/docker/DockerContainer.scala
+++
b/core/invoker/src/main/scala/whisk/core/containerpool/docker/DockerContainer.scala
@@ -104,7 +104,7 @@ object DockerContainer {
params
val pulled = if (userProvidedImage) {
docker.pull(image).recoverWith {
- case _ => Future.failed(BlackboxStartupError(s"Failed to pull
container image '${image}'."))
+ case _ =>
Future.failed(BlackboxStartupError(Messages.imagePullError(image)))
}
} else Future.successful(())
@@ -115,17 +115,16 @@ object DockerContainer {
// Remove the broken container - but don't wait or check for the
result.
// If the removal fails, there is nothing we could do to recover
from the recovery.
docker.rm(brokenId)
- Future.failed(
- WhiskContainerStartupError(s"Failed to run container with image
'${image}'. Removing broken container."))
+
Future.failed(WhiskContainerStartupError(Messages.resourceProvisionError))
case _ =>
- Future.failed(WhiskContainerStartupError(s"Failed to run container
with image '${image}'."))
+
Future.failed(WhiskContainerStartupError(Messages.resourceProvisionError))
}
ip <- docker.inspectIPAddress(id, network).recoverWith {
// remove the container immediately if inspect failed as
// we cannot recover that case automatically
case _ =>
docker.rm(id)
- Future.failed(WhiskContainerStartupError(s"Failed to obtain IP
address of container '${id.asString}'."))
+
Future.failed(WhiskContainerStartupError(Messages.resourceProvisionError))
}
} yield new DockerContainer(id, ip, useRunc)
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services