Repository navigation
[Server] Read server settings from UC_ environment variables - #2079
Conversation
|
Local AI review run The CI
Each finding was checked against the code before acting on it.
Reviewed heads: 2f4bb5a, 690745f, 8b8356b, c0bc199, d7bf525. Current heads: 81e48b4, eba9f92, 99ae5a0, b91905f, b19e7a5. |
81e48b4 to
b2cb578
Compare
|
Local AI review run (round 2) The CI
Verification on the current heads:
|
|
/review |
b2cb578 to
f5f1327
Compare
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] The env lookup looks right: the exact-name lookup is kept, the upper-case names apply only to secrets, and the Helm names match what the server reads. A few comments inline, mostly about tests.
77f1246 to
3f120f3
Compare
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Thanks for the rework, the single UC_ rule is much simpler than the secret list. My earlier comments are addressed; fine to skip the log-capture test for the warning.
nit: the title says "config secrets", but this now reads any setting from the environment. Something like "[Server] Read server settings from UC_ environment variables" would match the change.
Operators can now set any setting, including the OAuth client secret, the AWS secret key, and the per-bucket S3 and ADLS secrets, in an environment variable a shell can export: UC_, then the key in upper case with `_` for each other character, such as UC_S3_SECRETKEY_0. The prefix keeps variables that runtimes set for their own use, such as AWS_REGION, from changing settings. A variable named exactly as the key still comes first. At startup the server logs the name of each variable it uses, never the value. `bin/uc auth login` also reads UC_SERVER_CLIENT_SECRET. Secrets in server.properties keep working, but the server now logs a deprecation warning for each one it reads from the file, and the docs mark that way as deprecated. The Helm chart passes the S3 and ADLS secrets to the server container as environment variables instead of rendering them into server.properties, and no longer gives the server the OAuth client secret, which only the CLI reads. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The comment on reading UC_SERVER_CLIENT_SECRET repeated what the next lines do; keep the part that says why the name and trimming match the server. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The server never reads server.client-secret, but its deprecation warning told operators to set UC_SERVER_CLIENT_SECRET, and setting it in the server's environment silenced the warning. The warning now says only bin/uc auth login reads it, names the shell that runs that command, and is no longer silenced by the server's environment. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
timothyw553
left a comment
There was a problem hiding this comment.
first pass -- a question about CLI use case.
The CLI login tests pass --identity_token, so none reached the UC_SERVER_CLIENT_SECRET lookup in the OAuth flow. Move the lookup into Oauth2CliExchange.clientSecret and test it in CliAuthCrudTest: the variable wins over server.client-secret with a trailing line break dropped, and an absent, empty or line-break-only variable falls back to the file. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
3f120f3 to
476239b
Compare
|
@yili-db Good point on the title. Retitled to "[Server] Read server settings from |
timothyw553
left a comment
There was a problem hiding this comment.
Thanks for the change! One blocker.
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
…plates
A server.config.override or extraProperties template could use the init container's S3_SECRET_KEY_<n>, ADLS_CLIENT_SECRET_<n> or OAUTH_CLIENT_SECRET for any key, for example aws.secretKey=${S3_SECRET_KEY_0}. After the secrets moved to the server's environment, those lines rendered empty. The init container now gets these variables again when either setting is set, which is deprecated. OAUTH_CLIENT_SECRET is optional, and the auth Secret only needs clientId, since nothing else in the chart reads the client secret.
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
Say that the chart passes the S3 and ADLS secrets (not every secret) to the server as environment variables, when the server warns about secrets in server.properties, why the OAuth client secret ref is optional, and spell out the UC_ name rule instead of linking a private method. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Checkstyle failed the build on the get(Property) Javadoc line. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
… docs The server reads every property at startup, so UC_SERVER_CLIENT_SECRET in its environment logged that the variable was used, though only bin/uc auth login reads it. The upgrading note now says OAUTH_CLIENT_SECRET also needs auth.enabled. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The warnings are now built by secretsInFileWarnings, which the file constructor logs, and a package-private constructor takes the environment, so ServerPropertiesTest covers which secrets warn and that no value appears. The Helm render step now checks the UC_ variables, that server.properties holds no secrets, and when the deprecated init container variables are set. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
@yili-db Thanks for running Nit1 (deprecation warnings untested): added in c04f82f.
Nit2 (INFO line for Nit3 (Helm wiring only linted): added in c04f82f. The render step renders
Locally the checks pass on the chart and fail when a key name is wrong, when a gate is removed, and when a secret is put back into Nit4 (exact-name variable not normalized): keeping it as is.
Nit5 (
Nit6 (
Nit7 (Upgrading bullet): fixed the
|
|
/review |
The access key and the ADLS tenant and client IDs still came from the file the init container writes, and only the secrets from the server environment. After rotating a credential, a server container restart without a pod restart paired an old ID with a new secret. The chart now passes every part from the Secret. Also: a test that each kind of secret warns, the UC_ names in the Helm text, a note that an exact-name variable is used as is, and precompiled patterns. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
The default file still held the S3 access key and the ADLS tenant and client IDs. After clearing a credential in its Secret, a server container restart without a pod restart read the empty UC_ variables as unset and fell back to the stale ID in the file. The default template now renders none of them; the init container gets their variables only for a custom template. Also: a log test for the startup warnings and the INFO line, and the sample client-secret comment says only bin/uc auth login reads it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
|
/review |
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
The warnings method logs directly again, and one test in ServerPropertiesTest captures the log instead of two tests over a string-returning seam. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
unitycatalog#2079 landed as d31fa8b, whose tree is unitycatalog#2079's head, which this branch already holds. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedThis is part 1 of 4 in a stack; each PR handles one kind of secret end to end (server, Helm chart, docs, tests). Review only this PR's changes with its incremental link above.
Description of changes
Operators can now set any server setting, and so every secret, in an environment variable that a shell or a Kubernetes Secret can supply. Before, UC looked only for a variable named exactly like the key (
s3.secretKey.0), which no shell can export, so secrets lived inserver.propertiesin plaintext, and the Helm chart rendered them there.UC_, then the key in upper case, with_for every character that is not a letter or digit:UC_S3_SECRETKEY_<n>,UC_S3_SESSIONTOKEN_<n>,UC_ADLS_CLIENTSECRET_<n>,UC_AWS_SECRETKEY,UC_SERVER_CLIENT_SECRET. It takes precedence overserver.properties.server.propertiesstill work. The server logs a deprecation warning at startup for each one (key name only), and the docs mark that way as deprecated. The warning forserver.client-secretsays that onlybin/uc auth loginreads it and to setUC_SERVER_CLIENT_SECRETin the shell that runs that command; setting the variable for the server does not silence it.server.properties. Chart values are unchanged. The OAuth client secret is no longer passed to the server at all: onlybin/uc auth loginreads it.bin/uc auth loginreadsUC_SERVER_CLIENT_SECRETbeforeetc/conf/server.properties.docs/server/aws.mdalso gets the master user keys right: the server readsaws.masterRoleArn/aws.accessKey/aws.secretKey, not theaws.s3.*names the page showed.server.propertiesnow use the environment variables and mark the file deprecated: configuration, auth, AWS, Docker Compose, the Spark and XTable integrations, the integration-test setup, the sampleserver.propertiesfiles, and the Helmconfig.override/extraPropertiesvalues.📐 Design notes & details
Why this shape. Apache Polaris reads settings from environment variables under the property name in upper case (SmallRye config rules), and its chart passes Kubernetes Secrets in with
secretKeyRef. This PR follows the same model. No generic "read any secret from a file" option is added.Why the
UC_prefix, for every key. One rule for all keys is easier to use than a list of secret keys. Without a prefix, variables that runtimes set for their own use would change UC settings:aws.regionwould map toAWS_REGION, which AWS runtimes set, andserver.envtoSERVER_ENV. With the prefix, only variables meant for UC count.Details.
UC_name, thenserver.properties.UC_variable is ignored, like an empty value inserver.properties.UC_value is dropped. Before, the chart's envsubst wrote the value intoserver.properties, andProperties.loadended it at the line break; Secrets made from a file often end with one.server.client-secret: the server never reads it, so a variable in the server's environment is not a fix._SERVICE_HOST,_SERVICE_PORTor_PORT[...]. The only key whoseUC_name has that shape isserver.redirect-port, and only for a Service nameduc-server-redirect; the chart's Services are named<fullname>-serverand<fullname>-ui. A wrong value there fails startup validation.server.config.overrideorextraPropertiestemplate that uses the chart's old${OAUTH_CLIENT_SECRET},${S3_SECRET_KEY_<n>}or${ADLS_CLIENT_SECRET_<n>}keeps working, for any key (for exampleaws.secretKey=${S3_SECRET_KEY_0}): when either setting is set, the init container still gets those variables. That is deprecated, andvalues.yamlsays so.OAUTH_CLIENT_SECRETis an optional ref, since nothing else in the chart reads the client secret; the auth Secret only needsclientId.Compatibility. Users see these in the new Upgrading list under Secrets in
docs/server/configuration.md.UC_variable already set in the server's environment now takes precedence over the same key inserver.properties.server.propertieskeep working, with a warning.server.deployment.image.tagpinned to an older server image: that image doesn't read these variables, so S3 and ADLS lose their secrets. The image tag note invalues.yamlsays to use the server image from the chart's release (the default).server.propertiesno longer holds these secrets, and without a custom template the init container no longer hasOAUTH_CLIENT_SECRET,S3_SECRET_KEY_<n>orADLS_CLIENT_SECRET_<n>. A container added throughextraInitContainersorextraContainersthat needs them must read them from the Kubernetes Secret itself.Tests.
ServerPropertiesTest.testSettingsFromEnvironment:UC_variables for the client secret, S3 secret key and session token, ADLS client secret and a non-secret key (s3.region.0); a trailing CR/LF is dropped; an emptyUC_variable is ignored;AWS_REGIONdoes not changeaws.region; the exact-name variable wins over theUC_one.CliAuthCrudTest.testAuthLoginReadsTheClientSecretFromTheEnvironmentBeforeTheFile:bin/uc auth logintakesUC_SERVER_CLIENT_SECREToverserver.client-secret, drops a trailing line break, and falls back to the file when the variable is absent, empty or only a line break. The other CLI login tests pass--identity_token, so they skip this path.helm/ci/secrets-values.yamlrenders the S3 and ADLS secret variables in chart lint, plus the deprecated init container variables throughextraProperties;helm templaterenders with and without auth, S3 and ADLS, and with none of them noenv:block is emitted.server.propertieslogs the warning; withUC_S3_SECRETKEY_0set, the log names the variable and only the remaining file secrets warn; no value appears in the log.This pull request and its description were written by Isaac.