Skip to content

Commit 347ff1f

Browse files
authored
Prepare to integrate new scheduler into apache/openwhisk-deploy-kube (#5278)
* Kubernetes Akka bootstrap for controller * Update cluster management for the scheduler to help with k8s deployment * Made changes to tools to try to integrate scheduler into travis/CI build process * Added scheduler Dockerfile.cov * Use consistent ordering of components * remove canonical.port setting in scheduler, controller * Remove unneeded dependency from controller, scheduler * Remove cluster creation from ShardingContainerPoolBalancer * Remove trailing whitespace Signed-off-by: Erika Hunhoff <[email protected]> * Revert akka cluster changes to controller Signed-off-by: Erika Hunhoff <[email protected]> Signed-off-by: Erika Hunhoff <[email protected]>
1 parent 20a7b1c commit 347ff1f

File tree

13 files changed

+65
-5
lines changed

13 files changed

+65
-5
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ timeout(time: 12, unit: 'HOURS') {
4949
sh "docker run -d --restart=always --name registry -v \"$HOME\"/certs:/certs \
5050
-e REGISTRY_HTTP_ADDR=0.0.0.0:${port} -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/${cert} \
5151
-e REGISTRY_HTTP_TLS_KEY=/certs/${key} -p ${port}:${port} registry:2"
52-
// Build the controller and invoker images.
52+
// Build the controller, scheduler, and invoker images.
5353
sh "./gradlew distDocker -PdockerRegistry=${domainName}:${port}"
5454
//Install the various modules like standalone
5555
sh "./gradlew install"

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ subprojects {
4242
def cons = project.getDependencies().getConstraints()
4343
def akka = ['akka-actor', 'akka-cluster', 'akka-cluster-metrics', 'akka-cluster-tools', 'akka-coordination',
4444
'akka-discovery', 'akka-distributed-data', 'akka-protobuf', 'akka-remote', 'akka-slf4j',
45-
'akka-stream', 'akka-stream-testkit', 'akka-testkit']
45+
'akka-stream', 'akka-stream-testkit', 'akka-testkit', 'akka-persistence', 'akka-cluster-sharding']
4646
def akkaHttp = ['akka-http', 'akka-http-core', 'akka-http-spray-json', 'akka-http-testkit', 'akka-http-xml',
4747
'akka-parsing', 'akka-http2-support']
4848

core/controller/src/main/scala/org/apache/openwhisk/core/loadBalancer/ShardingContainerPoolBalancer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class ShardingContainerPoolBalancer(
158158
AkkaManagement(actorSystem).start()
159159
ClusterBootstrap(actorSystem).start()
160160
Some(Cluster(actorSystem))
161-
} else if (loadConfigOrThrow[Seq[String]]("akka.cluster.seed-nodes").nonEmpty) {
161+
} else if (loadConfigOrThrow[Seq[String]]("akka.cluster.seed-nodes").nonEmpty) {
162162
Some(Cluster(actorSystem))
163163
} else {
164164
None

core/scheduler/Dockerfile.cov

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
FROM scheduler
19+
20+
ARG OW_ROOT_DIR
21+
22+
USER root
23+
RUN mkdir -p /coverage/common && \
24+
mkdir -p /coverage/scheduler && \
25+
mkdir -p "${OW_ROOT_DIR}/common/scala/build" && \
26+
mkdir -p "${OW_ROOT_DIR}/core/scheduler/build" && \
27+
ln -s /coverage/common "${OW_ROOT_DIR}/common/scala/build/scoverage" && \
28+
ln -s /coverage/scheduler "${OW_ROOT_DIR}/core/scheduler/build/scoverage"
29+
30+
COPY build/tmp/docker-coverage /scheduler/

core/scheduler/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ dependencies {
6565
implementation "org.scala-lang:scala-library:${gradle.scala.version}"
6666
implementation project(':common:scala')
6767
implementation "io.altoo:akka-kryo-serialization_${gradle.scala.depVersion}:1.0.0"
68+
implementation "com.lightbend.akka.management:akka-management-cluster-bootstrap_${gradle.scala.depVersion}:${gradle.akka_management.version}"
69+
implementation "com.lightbend.akka.discovery:akka-discovery-kubernetes-api_${gradle.scala.depVersion}:${gradle.akka_management.version}"
6870
}
6971

7072
// workaround for akka-grpc

core/scheduler/src/main/resources/application.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,20 @@ akka {
4444
transport = tcp
4545
}
4646
}
47+
48+
cluster {
49+
shutdown-after-unsuccessful-join-seed-nodes = 60s
50+
51+
# Disable legacy metrics in akka-cluster.
52+
metrics.enabled = off
53+
}
4754
}
4855

4956
whisk {
57+
cluster {
58+
use-cluster-bootstrap: false
59+
}
60+
5061
# tracing configuration
5162
tracing {
5263
component = "Scheduler"

core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/Scheduler.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import akka.Done
2121
import akka.actor.{ActorRef, ActorRefFactory, ActorSelection, ActorSystem, CoordinatedShutdown, Props}
2222
import akka.http.scaladsl.Http
2323
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
24+
import akka.management.scaladsl.AkkaManagement
25+
import akka.management.cluster.bootstrap.ClusterBootstrap
2426
import akka.pattern.ask
2527
import akka.util.Timeout
2628
import com.typesafe.config.ConfigValueFactory
@@ -258,6 +260,7 @@ trait SchedulerCore {
258260
object Scheduler {
259261

260262
protected val protocol = loadConfigOrThrow[String]("whisk.scheduler.protocol")
263+
protected val useClusterBootstrap = loadConfigOrThrow[Boolean]("whisk.cluster.use-cluster-bootstrap")
261264

262265
val topicPrefix = loadConfigOrThrow[String](ConfigKeys.kafkaTopicsPrefix)
263266

@@ -289,6 +292,11 @@ object Scheduler {
289292

290293
implicit val logger = new AkkaLogging(akka.event.Logging.getLogger(actorSystem, this))
291294

295+
if (useClusterBootstrap) {
296+
AkkaManagement(actorSystem).start()
297+
ClusterBootstrap(actorSystem).start()
298+
}
299+
292300
// Prepare Kamon shutdown
293301
CoordinatedShutdown(actorSystem).addTask(CoordinatedShutdown.PhaseActorSystemTerminate, "shutdownKamon") { () =>
294302
logger.info(this, s"Shutting down Kamon with coordinated shutdown")

tools/admin/wskadmin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def parseArgs():
169169
subparser.required = True
170170

171171
subcmd = subparser.add_parser('get', help='get logs')
172-
subcmd.add_argument('components', help='components, one or more of [controllerN, invokerN] where N is the instance', nargs='*', default=['controller0', 'invoker0'])
172+
subcmd.add_argument('components', help='components, one or more of [controllerN, schedulerN, invokerN] where N is the instance', nargs='*', default=['controller0', 'scheduler0', 'invoker0'])
173173
subcmd.add_argument('-t', '--tid', help='retrieve logs for the transaction id')
174174
subcmd.add_argument('-g', '--grep', help='retrieve logs that match grep expression')
175175

tools/build/checkLogs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def colorize(code, string):
9696
("db-triggers.log", {"db"}, [ partial(database_has_at_most_x_entries, 0) ]),
9797
# Assert that stdout of the container is correctly piped and empty
9898
("controller0.log", {"system"}, [ partial(file_has_at_most_x_bytes, 0) ]),
99+
("scheduler0.log", {"system"}, [ partial(file_has_at_most_x_bytes, 0) ]),
99100
("invoker0.log", {"system"}, [ partial(file_has_at_most_x_bytes, 0) ])
100101
]
101102

tools/build/citool

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def parseArgs():
8787
subparser.add_argument('-s', '--sort', help='sort logs by timestamp', action='store_true')
8888
subparser.add_argument('-n', '--invokers', help='number of invokers', type=int, default=3)
8989
subparser.add_argument('-c', '--controllers', help='number of controllers', type=int, default=1)
90+
subparser.add_argument('-c', '--schedulers', help='number of schedulers', type=int, default=1)
9091

9192
return parser.parse_args()
9293

@@ -312,6 +313,7 @@ def cat(args):
312313
else:
313314
components = {
314315
'controller': args.controllers,
316+
'scheduler': args.schedulers,
315317
'invoker': args.invokers
316318
}
317319
logs = map(getComponentLogs, getComponentList(components))

0 commit comments

Comments
 (0)