ningyougang commented on a change in pull request #4790: Add administrative
interface to invoker and controller to reconfigure runtimes
URL: https://github.com/apache/openwhisk/pull/4790#discussion_r385019331
##########
File path:
core/controller/src/main/scala/org/apache/openwhisk/core/controller/Controller.scala
##########
@@ -163,6 +171,61 @@ class Controller(val instance: ControllerInstanceId,
LogLimit.config,
runtimes,
List(apiV1.basepath()))
+
+ private val controllerCredentials =
loadConfigOrThrow[ControllerCredentials](ConfigKeys.controllerCredentials)
+
+ /**
+ * config runtime
+ */
+ private val configRuntime = {
+ implicit val executionContext = actorSystem.dispatcher
+ (path("config" / "runtime") & post) {
+ extractCredentials {
+ case Some(BasicHttpCredentials(username, password)) =>
+ if (username == controllerCredentials.username && password ==
controllerCredentials.password) {
+ entity(as[String]) { runtime =>
+ val execManifest = ExecManifest.initialize(runtime)
+ if (execManifest.isFailure) {
+ logging.info(this, s"received invalid runtimes manifest")
+ complete(StatusCodes.BadRequest)
+ } else {
+ parameter('limit.?) { limit =>
+ limit match {
+ case Some(targetValue) =>
+ val pattern = """\d+:\d"""
+ if (targetValue.matches(pattern)) {
+ val invokerArray = targetValue.split(":")
+ val beginIndex = invokerArray(0).toInt
+ val finishIndex = invokerArray(1).toInt
+ if (finishIndex < beginIndex) {
+ logging.info(this, "finishIndex can't be less than
beginIndex")
+ complete(StatusCodes.BadRequest)
+ } else {
+ val targetInvokers = (beginIndex to
finishIndex).toList
+ loadBalancer.sendRuntimeToInvokers(runtime,
Some(targetInvokers))
+ logging.info(this, "config runtime request is
already sent to target invokers")
+ complete(StatusCodes.BadRequest)
+ }
+ } else {
+ logging.info(this, "limit value can't match
[beginIndex:finishIndex]")
+ complete(StatusCodes.BadRequest)
+ }
+ case None =>
+ loadBalancer.sendRuntimeToInvokers(runtime, None)
+ logging.info(this, "config runtime request is already
sent to all managed invokers")
+ complete(StatusCodes.Accepted)
Review comment:
I changed to `complete(StatusCodes.Accepted)`, because it is a async
operation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services