Skip to content

Commit

Permalink
Add ZOOKEEPER_HOSTS as an optional property (#5435)
Browse files Browse the repository at this point in the history
* Add ZOOKEEPER_HOSTS as an optional property

* Check if zookeeper hosts are empty

* Apply scalaFmt
  • Loading branch information
style95 authored Sep 15, 2023
1 parent 20f7d98 commit 6375c96
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6375c96

Please sign in to comment.