This is an automated email from the ASF dual-hosted git repository.

bdoyle pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 138f3d902 add error handling to container manager when invoker query 
fails (#5320)
138f3d902 is described below

commit 138f3d9022610b9d00078db5226e3fd4ec67d64a
Author: Brendan Doyle <[email protected]>
AuthorDate: Wed Aug 31 16:43:15 2022 -0700

    add error handling to container manager when invoker query fails (#5320)
    
    * add error handling to container manager when invoker query fails
    
    * fix tests
    
    Co-authored-by: Brendan Doyle <[email protected]>
---
 .../scheduler/container/ContainerManager.scala     |  5 +++
 .../container/test/ContainerManagerTests.scala     | 46 +++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git 
a/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/container/ContainerManager.scala
 
b/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/container/ContainerManager.scala
index 050f4c8ad..8d684b2d3 100644
--- 
a/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/container/ContainerManager.scala
+++ 
b/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/container/ContainerManager.scala
@@ -144,6 +144,11 @@ class ContainerManager(jobManagerFactory: ActorRefFactory 
=> ActorRef,
     logging.info(this, s"received ${msgs.size} creation message 
[${msgs.head.invocationNamespace}:${msgs.head.action}]")
     ContainerManager
       .getAvailableInvokers(etcdClient, memory, invocationNamespace)
+      .recover({
+        case t: Throwable =>
+          logging.error(this, s"Unable to get available invokers: 
${t.getMessage}.")
+          List.empty[InvokerHealth]
+      })
       .foreach { invokers =>
         if (invokers.isEmpty) {
           logging.error(this, "there is no available invoker to schedule.")
diff --git 
a/tests/src/test/scala/org/apache/openwhisk/core/scheduler/container/test/ContainerManagerTests.scala
 
b/tests/src/test/scala/org/apache/openwhisk/core/scheduler/container/test/ContainerManagerTests.scala
index 1474cbdda..2581bcfef 100644
--- 
a/tests/src/test/scala/org/apache/openwhisk/core/scheduler/container/test/ContainerManagerTests.scala
+++ 
b/tests/src/test/scala/org/apache/openwhisk/core/scheduler/container/test/ContainerManagerTests.scala
@@ -864,7 +864,7 @@ class ContainerManagerTests
       ScheduledPair(msg4, None, Some(NoAvailableInvokersError)))
   }
 
-  it should "send FailedCreationJob to queue manager when no invokers are 
available" in {
+  it should "send FailedCreationJob to memory queue when no invokers are 
available" in {
     val mockEtcd = mock[EtcdClient]
     val probe = TestProbe()
     (mockEtcd
@@ -910,6 +910,50 @@ class ContainerManagerTests
         NoAvailableInvokersError))
   }
 
+  it should "send FailedCreationJob to memory queue when available invoker 
query fails" in {
+    val mockEtcd = mock[EtcdClient]
+    val probe = TestProbe()
+    (mockEtcd
+      .getPrefix(_: String))
+      .expects(InvokerKeys.prefix)
+      .returning(Future.failed(new Exception("etcd request failed.")))
+      .twice()
+
+    val fqn = FullyQualifiedEntityName(EntityPath("ns1"), 
EntityName(testAction))
+
+    QueuePool.put(
+      MemoryQueueKey(testInvocationNamespace, 
fqn.toDocId.asDocInfo(testRevision)),
+      MemoryQueueValue(probe.ref, true))
+
+    val mockJobManager = TestProbe()
+    val mockWatcher = TestProbe()
+
+    val manager =
+      system.actorOf(
+        ContainerManager.props(factory(mockJobManager), mockMessaging(), 
testsid, mockEtcd, config, mockWatcher.ref))
+
+    val msg =
+      ContainerCreationMessage(
+        TransactionId.testing,
+        testInvocationNamespace,
+        fqn,
+        testRevision,
+        actionMetadata,
+        testsid,
+        schedulerHost,
+        rpcPort)
+
+    manager ! ContainerCreation(List(msg), testMemory, testInvocationNamespace)
+    probe.expectMsg(
+      FailedCreationJob(
+        msg.creationId,
+        testInvocationNamespace,
+        msg.action,
+        testRevision,
+        NoAvailableInvokersError,
+        NoAvailableInvokersError))
+  }
+
   it should "schedule to the blackbox invoker when isBlackboxInvocation is 
true" in {
     stream.reset()
     val mockEtcd = mock[EtcdClient]

Reply via email to