balena-io-modules / open-balena-base

16 stars 12 forks source link

Prefer using local env var values before falling back to defaults #322

Closed thgreasi closed 11 months ago

thgreasi commented 11 months ago

316 changed the behavior and configure-balena.sh no longer uses the local envs when defined while populating /etc/docker.env.

Found once the API started complaining about REDIS_HOST being in an invalid format, which while we defined it in the docker-compose.yml as <host>:<port>, at the end on runtime it had the default redis.<tld> as its value.

Change-type: patch See: https://github.com/balena-io-modules/open-balena-base/pull/316/files#diff-95ccd7ac2401d4f914cf825fabd8648b9db8a1f5436aafcedf3a640e9a1b73b6R376-R378 See: https://balena.zulipchat.com/#narrow/stream/346007-balena-io.2FbalenaCloud/topic/BoB.20REDIS_HOST.20error.20on.20livepush

ab77 commented 11 months ago

@thgreasi so this isn't working?

thgreasi commented 11 months ago

@ab77 I didn't face any issue with that part, so I guess it works. That part seems to be only applied for API keys, and is clearly doing the "local env prioritization" which is missing for the HOSTS. For the hosts we just need the last part afaict [[ -n ${!varname} ]]; then API_KEYS[${varname}]="${!varname}" . So what I did in this PR is a rephrase of the above (which I hadn't seen) with an added [[ -n $VARNAME ]] check to avoid any unexpected invalid indirect expansion error.