Skip to content

Commit d55d8fe

Browse files
authored
Add tags to invokers. (#5289)
* Add tags to invokers. * Add a log to figure out invoker tags. * Update the invoker tag log. * Add documentation about the tag-based scheduling.
1 parent a03507c commit d55d8fe

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

ansible/roles/invoker/tasks/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@
282282
"CONFIG_whisk_invoker_https_keystorePassword": "{{ invoker.ssl.keystore.password }}"
283283
"CONFIG_whisk_invoker_https_keystoreFlavor": "{{ invoker.ssl.storeFlavor }}"
284284
"CONFIG_whisk_invoker_https_clientAuth": "{{ invoker.ssl.clientAuth }}"
285+
"CONFIG_whisk_invoker_resource_tags": "{% if tags is defined %} '{{ tags | join(',') }}' {% else %} '' {% endif %}"
285286
"CONFIG_whisk_containerProxy_timeouts_idleContainer": "{{ whisk.containerProxy.timeouts.idleContainer }}"
286287
"CONFIG_whisk_containerProxy_timeouts_pauseGrace": "{{ whisk.containerProxy.timeouts.pauseGrace }}"
287288
"CONFIG_whisk_containerProxy_timeouts_keepingDuration": "{{ whisk.containerProxy.timeouts.keepingDuration }}"

common/scala/src/main/scala/org/apache/openwhisk/core/WhiskConfig.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,6 @@ object ConfigKeys {
317317

318318
val whiskInvokerUsername = "whisk.invoker.username"
319319
val whiskInvokerPassword = "whisk.invoker.password"
320+
321+
val invokerResourceTags = "whisk.invoker.resource.tags"
320322
}

core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ object Invoker {
109109
implicit val logger = new AkkaLogging(akka.event.Logging.getLogger(actorSystem, this))
110110
val poolConfig: ContainerPoolConfig = loadConfigOrThrow[ContainerPoolConfig](ConfigKeys.containerPool)
111111
val limitConfig: ConcurrencyLimitConfig = loadConfigOrThrow[ConcurrencyLimitConfig](ConfigKeys.concurrencyLimit)
112+
val tags: Seq[String] = Some(loadConfigOrThrow[String](ConfigKeys.invokerResourceTags))
113+
.map(_.trim())
114+
.filter(_ != "")
115+
.map(_.split(",").toSeq)
116+
.getOrElse(Seq.empty[String])
112117

118+
logger.info(this, s"invoker tags: (${tags.mkString(", ")})")
113119
// Prepare Kamon shutdown
114120
CoordinatedShutdown(actorSystem).addTask(CoordinatedShutdown.PhaseActorSystemTerminate, "shutdownKamon") { () =>
115121
logger.info(this, s"Shutting down Kamon with coordinated shutdown")
@@ -190,7 +196,13 @@ object Invoker {
190196

191197
val maxMessageBytes = Some(ActivationEntityLimit.MAX_ACTIVATION_LIMIT)
192198
val invokerInstance =
193-
InvokerInstanceId(assignedInvokerId, cmdLineArgs.uniqueName, cmdLineArgs.displayedName, poolConfig.userMemory)
199+
InvokerInstanceId(
200+
assignedInvokerId,
201+
cmdLineArgs.uniqueName,
202+
cmdLineArgs.displayedName,
203+
poolConfig.userMemory,
204+
None,
205+
tags)
194206

195207
val msgProvider = SpiLoader.get[MessagingProvider]
196208
if (msgProvider

docs/tag-based-scheduling.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!--
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
-->
19+
20+
# Tag-based Scheduling
21+
22+
Invoker machines may have different resources such as GPU, high CPU, etc.
23+
For those who want to take advantage of such resources, the system should be able to schedule activations to a certain invoker with the resources.
24+
25+
## Tagging invokers
26+
27+
Operators can configure any tags for invokers.
28+
29+
```bash
30+
invoker0 ansible_host=${INVOKER0} tags="['v1', 'gpu']"
31+
invoker1 ansible_host=${INVOKER1} tags="['v1', 'cpu']"
32+
invoker2 ansible_host=${INVOKER2} tags="['v2', 'gpu']"
33+
invoker3 ansible_host=${INVOKER3} tags="['v2', 'cpu']"
34+
invoker4 ansible_host=${INVOKER4} tags="['v1', 'mem']"
35+
invoker5 ansible_host=${INVOKER5} tags="['v2', 'mem']"
36+
invoker6 ansible_host=${INVOKER6} tags="['v2']"
37+
invoker7 ansible_host=${INVOKER7} tags="['v2']"
38+
invoker8 ansible_host=${INVOKER8}
39+
invoker9 ansible_host=${INVOKER9}
40+
```
41+
42+
Users can add the following annotations to their actions.
43+
44+
```
45+
wsk action update params tests/dat/actions/params.js -i -a invoker-resources '["v2", "gpu"]'
46+
```
47+
48+
Activation for this action will be delivered to invoker2.
49+
50+
The annotations and the corresponding target invokers are as follows.
51+
52+
* `["v1", "gpu"]` -> `invoker0`
53+
* `["v2", "gpu"]` -> `invoker2`
54+
* `["v1", "cpu"]` -> `invoker1`
55+
* `["v2"]` -> One of `invoker2`, `invoker3`, `invoker5`, `invoker6`, and `invoker7`
56+
* `["v1"]` -> One of `invoker0`, `invoker1`, `invoker4`
57+
* `No annotation` -> One of `invoker8` and `invoker9` is chosen first. if they have no resource, choose one of the invokers with tags.

0 commit comments

Comments
 (0)