Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow referencing env.sh vars in configs #6635

Merged
merged 2 commits into from
Feb 11, 2021

Conversation

nineinchnick
Copy link
Member

Allow referencing env vars from env.sh in configs.

Since this would allow users to add their custom vars to env.sh treat it as a config file so it won't be removed automatically on uninstall. Note that by default node.properties also won't be removed, as reported in #314

@cla-bot cla-bot bot added the cla-signed label Jan 18, 2021
@findepi
Copy link
Member

findepi commented Feb 1, 2021

@nineinchnick what about adding the -E switch conditionally (off by default)?
It could be configured by changing a variable in the init script, or by overriding it in env.sh script.

Or, maybe even better, we could ask the env.sh script to define an array variable (or comma-separated) with names of all env vars it intends to export.
Then the sudo invocation would export them to the subprocess, perhaps using --preserve-env=..., or by injecting additional env k="${k}" .. under sudo call.

wdyt?

@nineinchnick nineinchnick force-pushed the jwas/rpm-init-preserve-env branch 2 times, most recently from 7dafb43 to 1d3673d Compare February 1, 2021 13:36
@nineinchnick
Copy link
Member Author

@nineinchnick what about adding the -E switch conditionally (off by default)?
It could be configured by changing a variable in the init script, or by overriding it in env.sh script.

Or, maybe even better, we could ask the env.sh script to define an array variable (or comma-separated) with names of all env vars it intends to export.
Then the sudo invocation would export them to the subprocess, perhaps using --preserve-env=..., or by injecting additional env k="${k}" .. under sudo call.

wdyt?

It looks cool! Turns out I can declare -A CONFIG_ENV before sourcing env.sh! To avoid quoting issues I'm only passing names of exported vars to --preserve-env=.... I hope this will be clear enough to users, I added one example value in env.sh.

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

core/trino-server-rpm/src/main/rpm/postremove Show resolved Hide resolved
core/trino-server-rpm/src/main/rpm/preinstall Outdated Show resolved Hide resolved
"cat > /etc/trino/catalog/hive.properties <<\"EOT\"\n" +
"connector.name=hive-hadoop2\n" +
"hive.metastore.uri=thrift://localhost:9083\n" +
"hive.metastore.uri=thrift://localhost:${ENV:HMS_PORT}\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like local testing modification

it would be nice to have a test for that, but let's make it a dedicated one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a local testing modification. It extends the test coverage to ensure envs are passed properly. This is an integration test, not a unit test. I'm concerned that a dedicated test would increase the total duration. Are you sure it's worth putting in a separate test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much time we would add and how much time the job already takes today?

BTW the test is not very directly (there is no explicit assertion, so it could in theory become ignored by the server.)
Can we inject eg node.environment and verify what's the actual value of that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trino throws an error when configuration files reference an unset env var.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two tests in ServerIT run in the pipeline in slightly over a minute:

[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 70.948 s - in io.trino.server.rpm.ServerIT

so I'd expect a separate test to add ~30 seconds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the job total time is 20 minute. I think it's reasonable to have this as a separate test, but i think i am OK keeping this inline.

would it be possible to add an explicit assertion for the feature?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a custom node id and an assert for it.

core/trino-server-rpm/src/main/rpm/postinstall Outdated Show resolved Hide resolved
"cat > /etc/trino/catalog/hive.properties <<\"EOT\"\n" +
"connector.name=hive-hadoop2\n" +
"hive.metastore.uri=thrift://localhost:9083\n" +
"hive.metastore.uri=thrift://localhost:${ENV:HMS_PORT}\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much time we would add and how much time the job already takes today?

BTW the test is not very directly (there is no explicit assertion, so it could in theory become ignored by the server.)
Can we inject eg node.environment and verify what's the actual value of that?

@nineinchnick nineinchnick force-pushed the jwas/rpm-init-preserve-env branch 7 times, most recently from 58081b5 to c125c60 Compare February 4, 2021 18:30
@findepi findepi merged commit f600388 into trinodb:master Feb 11, 2021
@findepi findepi added this to the 353 milestone Feb 11, 2021
@findepi findepi mentioned this pull request Feb 11, 2021
10 tasks
@nineinchnick nineinchnick deleted the jwas/rpm-init-preserve-env branch June 5, 2021 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants