Skip to content

Commit 9e1cc33

Browse files
bdoyle0182Brendan Doyle
authored andcommitted
add error handling to container manager when invoker query fails (apache#5320)
* add error handling to container manager when invoker query fails * fix tests Co-authored-by: Brendan Doyle <[email protected]>
1 parent 571bba1 commit 9e1cc33

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/container/ContainerManager.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ class ContainerManager(jobManagerFactory: ActorRefFactory => ActorRef,
144144
logging.info(this, s"received ${msgs.size} creation message [${msgs.head.invocationNamespace}:${msgs.head.action}]")
145145
ContainerManager
146146
.getAvailableInvokers(etcdClient, memory, invocationNamespace)
147+
.recover({
148+
case t: Throwable =>
149+
logging.error(this, s"Unable to get available invokers: ${t.getMessage}.")
150+
List.empty[InvokerHealth]
151+
})
147152
.foreach { invokers =>
148153
if (invokers.isEmpty) {
149154
logging.error(this, "there is no available invoker to schedule.")

tests/src/test/scala/org/apache/openwhisk/core/scheduler/container/test/ContainerManagerTests.scala

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ class ContainerManagerTests
864864
ScheduledPair(msg4, None, Some(NoAvailableInvokersError)))
865865
}
866866

867-
it should "send FailedCreationJob to queue manager when no invokers are available" in {
867+
it should "send FailedCreationJob to memory queue when no invokers are available" in {
868868
val mockEtcd = mock[EtcdClient]
869869
val probe = TestProbe()
870870
(mockEtcd
@@ -910,6 +910,50 @@ class ContainerManagerTests
910910
NoAvailableInvokersError))
911911
}
912912

913+
it should "send FailedCreationJob to memory queue when available invoker query fails" in {
914+
val mockEtcd = mock[EtcdClient]
915+
val probe = TestProbe()
916+
(mockEtcd
917+
.getPrefix(_: String))
918+
.expects(InvokerKeys.prefix)
919+
.returning(Future.failed(new Exception("etcd request failed.")))
920+
.twice()
921+
922+
val fqn = FullyQualifiedEntityName(EntityPath("ns1"), EntityName(testAction))
923+
924+
QueuePool.put(
925+
MemoryQueueKey(testInvocationNamespace, fqn.toDocId.asDocInfo(testRevision)),
926+
MemoryQueueValue(probe.ref, true))
927+
928+
val mockJobManager = TestProbe()
929+
val mockWatcher = TestProbe()
930+
931+
val manager =
932+
system.actorOf(
933+
ContainerManager.props(factory(mockJobManager), mockMessaging(), testsid, mockEtcd, config, mockWatcher.ref))
934+
935+
val msg =
936+
ContainerCreationMessage(
937+
TransactionId.testing,
938+
testInvocationNamespace,
939+
fqn,
940+
testRevision,
941+
actionMetadata,
942+
testsid,
943+
schedulerHost,
944+
rpcPort)
945+
946+
manager ! ContainerCreation(List(msg), testMemory, testInvocationNamespace)
947+
probe.expectMsg(
948+
FailedCreationJob(
949+
msg.creationId,
950+
testInvocationNamespace,
951+
msg.action,
952+
testRevision,
953+
NoAvailableInvokersError,
954+
NoAvailableInvokersError))
955+
}
956+
913957
it should "schedule to the blackbox invoker when isBlackboxInvocation is true" in {
914958
stream.reset()
915959
val mockEtcd = mock[EtcdClient]

0 commit comments

Comments
 (0)