Skip to content

Add tags to invokers. #5289

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 4 commits into from
Jul 22, 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
1 change: 1 addition & 0 deletions ansible/roles/invoker/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
"CONFIG_whisk_invoker_https_keystorePassword": "{{ invoker.ssl.keystore.password }}"
"CONFIG_whisk_invoker_https_keystoreFlavor": "{{ invoker.ssl.storeFlavor }}"
"CONFIG_whisk_invoker_https_clientAuth": "{{ invoker.ssl.clientAuth }}"
"CONFIG_whisk_invoker_resource_tags": "{% if tags is defined %} '{{ tags | join(',') }}' {% else %} '' {% endif %}"
"CONFIG_whisk_containerProxy_timeouts_idleContainer": "{{ whisk.containerProxy.timeouts.idleContainer }}"
"CONFIG_whisk_containerProxy_timeouts_pauseGrace": "{{ whisk.containerProxy.timeouts.pauseGrace }}"
"CONFIG_whisk_containerProxy_timeouts_keepingDuration": "{{ whisk.containerProxy.timeouts.keepingDuration }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,6 @@ object ConfigKeys {

val whiskInvokerUsername = "whisk.invoker.username"
val whiskInvokerPassword = "whisk.invoker.password"

val invokerResourceTags = "whisk.invoker.resource.tags"
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ object Invoker {
implicit val logger = new AkkaLogging(akka.event.Logging.getLogger(actorSystem, this))
val poolConfig: ContainerPoolConfig = loadConfigOrThrow[ContainerPoolConfig](ConfigKeys.containerPool)
val limitConfig: ConcurrencyLimitConfig = loadConfigOrThrow[ConcurrencyLimitConfig](ConfigKeys.concurrencyLimit)
val tags: Seq[String] = Some(loadConfigOrThrow[String](ConfigKeys.invokerResourceTags))
.map(_.trim())
.filter(_ != "")
.map(_.split(",").toSeq)
.getOrElse(Seq.empty[String])

logger.info(this, s"invoker tags: (${tags.mkString(", ")})")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this.

[2022-07-21T11:00:02.599Z] [INFO] [#tid_sid_unknown] [Invoker] invoker tags: (v1, cpu)

// Prepare Kamon shutdown
CoordinatedShutdown(actorSystem).addTask(CoordinatedShutdown.PhaseActorSystemTerminate, "shutdownKamon") { () =>
logger.info(this, s"Shutting down Kamon with coordinated shutdown")
Expand Down Expand Up @@ -190,7 +196,13 @@ object Invoker {

val maxMessageBytes = Some(ActivationEntityLimit.MAX_ACTIVATION_LIMIT)
val invokerInstance =
InvokerInstanceId(assignedInvokerId, cmdLineArgs.uniqueName, cmdLineArgs.displayedName, poolConfig.userMemory)
InvokerInstanceId(
assignedInvokerId,
cmdLineArgs.uniqueName,
cmdLineArgs.displayedName,
poolConfig.userMemory,
None,
tags)

val msgProvider = SpiLoader.get[MessagingProvider]
if (msgProvider
Expand Down
57 changes: 57 additions & 0 deletions docs/tag-based-scheduling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-->

# Tag-based Scheduling

Invoker machines may have different resources such as GPU, high CPU, etc.
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.

## Tagging invokers

Operators can configure any tags for invokers.

```bash
invoker0 ansible_host=${INVOKER0} tags="['v1', 'gpu']"
invoker1 ansible_host=${INVOKER1} tags="['v1', 'cpu']"
invoker2 ansible_host=${INVOKER2} tags="['v2', 'gpu']"
invoker3 ansible_host=${INVOKER3} tags="['v2', 'cpu']"
invoker4 ansible_host=${INVOKER4} tags="['v1', 'mem']"
invoker5 ansible_host=${INVOKER5} tags="['v2', 'mem']"
invoker6 ansible_host=${INVOKER6} tags="['v2']"
invoker7 ansible_host=${INVOKER7} tags="['v2']"
invoker8 ansible_host=${INVOKER8}
invoker9 ansible_host=${INVOKER9}
```

Users can add the following annotations to their actions.

```
wsk action update params tests/dat/actions/params.js -i -a invoker-resources '["v2", "gpu"]'
```

Activation for this action will be delivered to invoker2.

The annotations and the corresponding target invokers are as follows.

* `["v1", "gpu"]` -> `invoker0`
* `["v2", "gpu"]` -> `invoker2`
* `["v1", "cpu"]` -> `invoker1`
* `["v2"]` -> One of `invoker2`, `invoker3`, `invoker5`, `invoker6`, and `invoker7`
* `["v1"]` -> One of `invoker0`, `invoker1`, `invoker4`
* `No annotation` -> One of `invoker8` and `invoker9` is chosen first. if they have no resource, choose one of the invokers with tags.