Skip to content

Take revision into consideration when choose warm container #5233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ContainerManager(jobManagerFactory: ActorRefFactory => ActorRef,
// Filter out messages which can use warmed container
private def filterWarmedCreations(msgs: List[ContainerCreationMessage]) = {
msgs.filter { msg =>
val warmedPrefix = containerPrefix(ContainerKeys.warmedPrefix, msg.invocationNamespace, msg.action)
val warmedPrefix = containerPrefix(ContainerKeys.warmedPrefix, msg.invocationNamespace, msg.action, Some(msg.revision))
val chosenInvoker = warmedContainers
.filter(!inProgressWarmedContainers.values.toSeq.contains(_))
.find { container =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class ContainerManagerTests
)
expectGetInvokers(mockEtcd, invokers)
expectGetInvokers(mockEtcd, invokers)
expectGetInvokers(mockEtcd, invokers) // this test case will run `getPrefix` twice
expectGetInvokers(mockEtcd, invokers) // this test case will run `getPrefix` twice, and another one for warmup

val mockJobManager = TestProbe()
val mockWatcher = TestProbe()
Expand Down Expand Up @@ -377,6 +377,65 @@ class ContainerManagerTests
receiver.expectMsg(s"invoker0-$msg1")
}

it should "not try warmed containers if revision is unmatched" in {
val mockEtcd = mock[EtcdClient]

// for test, only invoker2 is healthy, so that no-warmed creations can be only sent to invoker2
val invokers: List[InvokerHealth] = List(
InvokerHealth(InvokerInstanceId(0, userMemory = testMemory, tags = Seq.empty[String]), Unhealthy),
InvokerHealth(InvokerInstanceId(1, userMemory = testMemory, tags = Seq.empty[String]), Unhealthy),
InvokerHealth(InvokerInstanceId(2, userMemory = testMemory, tags = Seq.empty[String]), Healthy),
)
expectGetInvokers(mockEtcd, invokers)
expectGetInvokers(mockEtcd, invokers) // one for warmup

val mockJobManager = TestProbe()
val mockWatcher = TestProbe()
val receiver = TestProbe()

val manager =
system.actorOf(ContainerManager
.props(factory(mockJobManager), mockMessaging(Some(receiver.ref)), testsid, mockEtcd, config, mockWatcher.ref))

// there are 1 warmed container for `test-namespace/test-action` but with a different revision
manager ! WatchEndpointInserted(
ContainerKeys.warmedPrefix,
ContainerKeys.warmedContainers(
testInvocationNamespace,
testfqn,
DocRevision("2-testRev"),
InvokerInstanceId(0, userMemory = 0.bytes),
ContainerId("fake")),
"",
true)

val msg =
ContainerCreationMessage(
TransactionId.testing,
testInvocationNamespace,
testfqn,
testRevision,
actionMetadata,
testsid,
schedulerHost,
rpcPort)

// it should not reuse the warmed container
manager ! ContainerCreation(List(msg), 128.MB, testInvocationNamespace)

// ignore warmUp message
receiver.ignoreMsg {
case s: String => s.contains("warmUp")
}

// it should be scheduled to the sole health invoker: invoker2
receiver.expectMsg(s"invoker2-$msg")

mockJobManager.expectMsgPF() {
case RegisterCreationJob(`msg`) => true
}
}

it should "rescheduling container creation" in {
val mockEtcd = mock[EtcdClient]
(mockEtcd
Expand Down