-
Notifications
You must be signed in to change notification settings - Fork 6
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
pavics compose.sh: overriding DATA_PERSIST_ROOT
in env.local
do not take effect and warn when a dir in EXTRA_CONF_DIRS
does not exist
#272
Conversation
Do not exit script immediately since this most probably due to a typo in a new conf_dir and exit immediately means the whole platform will be broken. If we just warn and continue, the new conf_dir will not be active but at least all the existing will work. It's not ideal but less bad in the context of unattended autodeploy where no human is available to take corrective action right away.
E2E Test ResultsDACCS-iac Pipeline ResultsBuild URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/1082/Result : failure BIRDHOUSE_DEPLOY_BRANCH : fix-bugs-in-pavics-compose.sh DACCS_CONFIGS_BRANCH : master PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master PAVICS_SDI_BRANCH : master DESTROY_INFRA_ON_EXIT : true PAVICS_HOST : https:// PAVICS-e2e-workflow-tests Pipeline ResultsTests URL :NOTEBOOK TEST RESULTS
|
@fmigneault I changed my mind and go ahead with single-quote and delayed evaluation instead. The impact on users is actually minimum since forgetting to use single-quote in |
E2E Test ResultsDACCS-iac Pipeline ResultsBuild URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/1083/Result : failure BIRDHOUSE_DEPLOY_BRANCH : fix-bugs-in-pavics-compose.sh DACCS_CONFIGS_BRANCH : master PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master PAVICS_SDI_BRANCH : master DESTROY_INFRA_ON_EXIT : true PAVICS_HOST : https:// PAVICS-e2e-workflow-tests Pipeline ResultsTests URL :NOTEBOOK TEST RESULTS
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU this looks nice and useful!
for i in ${DELAYED_EVAL}; do | ||
v="`eval "echo \\$${i}"`" | ||
eval 'export ${i}="`eval "echo ${v}"`"' | ||
echo "delayed eval '`env |grep ${i}=`'" | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand the need for the separate DELAYED_EVAL
definition.
Wouldn't developers forgetting to specify a new variable name in it be more prone to error?
Couldn't all variables in ${VARS}
do the v="`eval "echo \\$${i}"`"
step, and this way simply using the single quotes would be sufficient to achieve the same result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if you think for simplicity, all vars in default.env
should be delayed eval then VARS
do not contain all of them. VARS
currently do not contain the 3 broken vars in DELAYED_EVAL
.
Then it looks like delayed eval is an exception rather than the norm. So I'd rather not forced the single quote on more vars than needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So they should be defined in OPTIONAL_VARS
instead, and this loop should use OPTIONAL_VARS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me what is your reluctance to have a new var DELAYED_EVAL
. Let's say we go with OPTIONAL_VARS
, the person changing default.env
still have to remember to add any new vars that need delayed eval to OPTIONAL_VARS
again.
Basically, if the goal in simplicity, then having to remember to add to DELAYED_EVAL
vs OPTIONAL_VARS
is the same effort. With DELAYED_EVAL
at least the feature is specific and the dev will have to remember to use single-quote.
I am not sure what is the gain to overload OPTIONAL_VARS
with a new feature. Currently OPTIONAL_VARS
is only used for template substitution. I'd rather have one duty per var for simplicity sake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not reluctant to it if there's no way around it.
I'm rather trying to see if there's a way we could drop all these manual steps altogether.
Technically, we could generate the contents of OPTIONAL_VARS
using only a grep -E 'export [A-Z]='
, and then we would not have to worry about those steps ever again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, the grep trick might too magic for me. How do you get the name of each var after?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this:
cat birdhouse/default.env | grep -E "export [A-Z0-9_]+=" | cut -d ' ' -f 2 | cut -d '=' -f 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And an extra | sed -r -e 's/(.*)/\$\1/g'
at the end for adding the $
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, think I'll pass on this magic for now. We have to handle all the default.env
from components from any other external repos as well. I don't have time to think of all the corner cases with this magic for now.
Do you see anything blocking with the current approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Good to go with the current alternative.
DATA_PERSIST_ROOT
in env.local
do not take effect and warn when a dir in EXTRA_CONF_DIRS
do not existDATA_PERSIST_ROOT
in env.local
do not take effect and warn when a dir in EXTRA_CONF_DIRS
does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current method sufficient for now.
Alternative to avoid DELAYED_EVAL
to be considered as some other time as per #272 (comment).
For reference: #274
## Fixes There are other scripts sourcing `default.env` and `env.local` and all those scripts have to expand the vars in `DELAYED_EVAL` list to have their actual values. Only scripts using the 3 variables in `DELAYED_EVAL` list are broken. `DELAYED_EVAL` was previously introduced in PR #272. ### Sample errors `fix-geoserver-data-dir-perm` (called at the end of `pavics-compose.sh`): ``` fix GeoServer data dir permission on first run only, when data dir do not exist yet. + DATA_DIR='${DATA_PERSIST_ROOT}/geoserver' + '[' -n ] + docker run --rm --name fix-geoserver-data-dir-perm --volume '${DATA_PERSIST_ROOT}/geoserver:/datadir' --env FIRST_RUN_ONLY bash:5.1.4 bash -xc 'if [ -z "$FIRST_RUN_ONLY" -o ! -f /datadir/global.xml ]; \ then chown -R 1000:10001 /datadir; else echo "No execute."; fi' docker: Error response from daemon: create ${DATA_PERSIST_ROOT}/geoserver: "${DATA_PERSIST_ROOT}/geoserver" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path. ``` `trigger-deploy-notebook` (broke notebook deploy job): ``` + TMP_SCRIPT=/tmp/notebookdeploy/notebookdeploy.XXXXXXIfafFK/deploy-notebook + cat + chmod a+x /tmp/notebookdeploy/notebookdeploy.XXXXXXIfafFK/deploy-notebook + docker run --rm --name deploy_tutorial_notebooks -u root -v /tmp/notebookdeploy/notebookdeploy.XXXXXXIfafFK/deploy-notebook:/deploy-notebook:ro -v /tmp/notebookdeploy/notebookdeploy.XXXXXXIfafFK/tutorial-notebooks:/tutorial-notebooks:ro -v '${DATA_PERSIST_ROOT}/jupyterhub_user_data:/notebook_dir:rw' --entrypoint /deploy-notebook bash:5.1.4 docker: Error response from daemon: create ${DATA_PERSIST_ROOT}/jupyterhub_user_data: "${DATA_PERSIST_ROOT}/jupyterhub_user_data" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path. ``` ### Explanation of the fix All scripts have to remember to call function `process_delayed_eval` in order to obtain the real value of each vars in `DELAYED_EVAL` list. Centralized all logic about reading configs (config files reading order, remember to call `process_delayed_eval`) to avoid mistake and to ease updating logic in the future. Too many scripts were reading the configs themselves and some are not doing it properly, ex: forgot to hide password when reading `env.local`. ### All scripts should do this going forward ```sh # Set variable COMPOSE_DIR to the dir containing pavics-compose.sh and docker-compose.yml. # Source the script providing function read_configs. # read_configs uses COMPOSE_DIR to find default.env and env.local. . $COMPOSE_DIR/read-configs.include.sh # Call function read_configs to read the various config files in the appropriate order and process delayed eval vars properly. read_configs ```
Fixes:
Overriding
DATA_PERSIST_ROOT
inenv.local
do not take effect forJUPYTERHUB_USER_DATA_DIR
,MAGPIE_PERSIST_DIR
, andGEOSERVER_DATA_DIR
.These 3 vars will have to be delayed evaluated for override in
env.local
totake effect.
For a variable to be delayed evaluated, it has to be defined using
single-quote and be added to the list of
DELAYED_EVAL
indefault.env
.If those steps are forgotten in
env.local
, it will still work sinceenv.local
is the last file to be read. However those steps should not beforgotten in any
default.env
for all components.So the impact or burden is on the developpers to write their
default.env
file properly, not on the users that only modify the
env.local
file.All
default.env
files header have been updated with notice about this newdelayed evaluation feature.
Fixes 🐛 [BUG]: Regression handling
DATA_PERSIST_ROOT
setting #270Changes:
Warn when a dir in
EXTRA_CONF_DIRS
does not exist.Most likely a typo in a new dir. Just warn and not exit directly to avoid
leaving the entire platform down during an unattended autodeploy since no
one is around to take immediate action.
Fixes 🐛 [BUG]: Silent error when EXTRA_CONF_DIRS is invalid #266