Skip to content

Commit

Permalink
[Issue 9867][scripts] Fixes issue (apache#9884)
Browse files Browse the repository at this point in the history
Fixes apache#9867 

### Motivation

As described in the issue the script to modify configuration yaml file (used by functions worker) did not work with array type variables. 

This fix allows specifying same values for array properties like `authenticationProviders` in environment variables (with `PF_` prefix) as the ones used by `apply-config-from-env.py` for conf files, i.e. a comma separated list of values.

E.g. You can define environment variable `PF_authenticationProviders` taking value `org.apache.pulsar.broker.authentication.AuthenticationProviderTls,org.apache.pulsar.broker.authentication.AuthenticationProviderAthenz` to specify two values or `org.apache.pulsar.broker.authentication.AuthenticationProviderTls` to specify only one. In both cases value will be correctly set in final yaml file as an array:

```yaml
authenticationProviders:
- org.apache.pulsar.broker.authentication.AuthenticationProviderTls
- org.apache.pulsar.broker.authentication.AuthenticationProviderAthenz
```

### Modifications

We have just added a check on the variable names that have type `Set<String>` in `WorkerConfig` the same way it is done for  `int` variables. We then split the value using ",", which already produces an array type.
  • Loading branch information
fmiguelez authored Mar 23, 2021
1 parent 647c2dc commit c2d52f1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docker/pulsar/scripts/gen-yml-from-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
'instanceLivenessCheckFreqMs'
]

SET_KEYS = [
'brokerInterceptors',
'messagingProtocols',
'tlsProtocols',
'tlsCiphers',
'authenticationProviders',
'superUserRoles',
'proxyRoles',
'schemaRegistryCompatibilityCheckers',
'brokerClientTlsCiphers',
'brokerClientTlsProtocols'
]

PF_ENV_PREFIX = 'PF_'

if len(sys.argv) < 2:
Expand Down Expand Up @@ -66,6 +79,8 @@
if i == (len(key_parts) - 1):
if key_part in INT_KEYS:
conf_to_modify[key_part] = int(v)
elif key_part in SET_KEYS:
conf_to_modify[key_part] = v.split(',')
else:
conf_to_modify[key_part] = v
modified = True
Expand Down

0 comments on commit c2d52f1

Please sign in to comment.