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

Handle environment variable interpolation in compositions #2818

Open
ab77 opened this issue Aug 12, 2024 · 1 comment
Open

Handle environment variable interpolation in compositions #2818

ab77 opened this issue Aug 12, 2024 · 1 comment
Labels
good first issue https://help.github.com/articles/helping-new-contributors-find-your-project-with-labels/ help wanted https://help.github.com/articles/helping-new-contributors-find-your-project-with-labels/ low-hanging-fruit needs investigation openBalena type:feature

Comments

@ab77
Copy link
Contributor

ab77 commented Aug 12, 2024

See, balena-io/open-balena#271

balena-cli chokes when presented with a composition containing a valid compose syntax (e.g.):

...
    environment:
      <<: *default-environment
      VPN_PORT: ${VPN_PORT:-443}

.. instead it should parse this by checking if there is an override set for VPN_PORT in build-variables, substituting the interpolation syntax;

if no override is presented, use the default value

@ab77 ab77 added type:feature needs investigation low-hanging-fruit help wanted https://help.github.com/articles/helping-new-contributors-find-your-project-with-labels/ good first issue https://help.github.com/articles/helping-new-contributors-find-your-project-with-labels/ openBalena labels Aug 12, 2024
@ab77
Copy link
Contributor Author

ab77 commented Aug 26, 2024

Also blocks https://github.com/balena-io/balena-cloud/pull/3466 (e.g.):

x-default-healthcheck: &default-healthcheck
  test: /usr/src/app/docker-hc
  interval: ${INTERVAL:-45s}
  timeout: ${TIMEOUT:-15s}
  retries: ${RETRIES:-3}

In order to override composition variables like health-check timeouts in balena-compose, we would need to implement runtime resolution of these (if defined) and fall back to default values, if not. Since balena compositions are evaluated at runtime by balena-supervisor, the Supervisor would need to know where to look for these values. It may chose to do this from "device" env-vars (not application/fleet) i.e. same modelling as BALENA_SUPERVISOR_DELTA*, using an appropriate env-var naming scheme (e.g. BALENA_FLEET_200882_INTERVAL). So if a "device" env-var (not fleet override) is set, that value is used to interpolate interval: ${INTERVAL:-45s}.

Ref: https://docs.docker.com/reference/compose-file/interpolation/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue https://help.github.com/articles/helping-new-contributors-find-your-project-with-labels/ help wanted https://help.github.com/articles/helping-new-contributors-find-your-project-with-labels/ low-hanging-fruit needs investigation openBalena type:feature
Projects
None yet
Development

No branches or pull requests

1 participant