From 6375c96066ca0e24cb81996a877bdd7caecdb72b Mon Sep 17 00:00:00 2001 From: Dominic Kim Date: Fri, 15 Sep 2023 18:06:14 +0900 Subject: [PATCH] Add ZOOKEEPER_HOSTS as an optional property (#5435) * Add ZOOKEEPER_HOSTS as an optional property * Check if zookeeper hosts are empty * Apply scalaFmt --- .../scala/org/apache/openwhisk/core/invoker/Invoker.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala b/core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala index 1d31175c1eb..1eeb65c16a8 100644 --- a/core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala +++ b/core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/Invoker.scala @@ -93,6 +93,8 @@ object Invoker { kafkaHosts ++ wskApiHost + def optionalProperties = zookeeperHosts.keys.toSet + def initKamon(instance: Int): Unit = { // Replace the hostname of the invoker to the assigned id of the invoker. val newKamonConfig = Kamon.config @@ -128,7 +130,7 @@ object Invoker { } // load values for the required properties from the environment - implicit val config = new WhiskConfig(requiredProperties) + implicit val config = new WhiskConfig(requiredProperties, optionalProperties) def abort(message: String) = { logger.error(this, message)(TransactionId.invoker) @@ -186,7 +188,8 @@ object Invoker { // --uniqueName is defined with a valid value, id is empty, assign an id via zookeeper case CmdLineArgs(Some(unique), None, _, overwriteId) => - if (config.zookeeperHosts.startsWith(":") || config.zookeeperHosts.endsWith(":")) { + if (config.zookeeperHosts.startsWith(":") || config.zookeeperHosts.endsWith(":") || + config.zookeeperHosts.equals("")) { abort(s"Must provide valid zookeeper host and port to use dynamicId assignment (${config.zookeeperHosts})") } new InstanceIdAssigner(config.zookeeperHosts).setAndGetId(unique, overwriteId)