feat(worker): expand ${VAR} env references in startup-application config#142
Merged
Conversation
read_startup_applications now recursively runs os.path.expandvars over
each parsed startup-app config, so a startup app can reference the
worker's own environment — including secrets mounted via
valueFrom.secretKeyRef — as ${VAR}. This lets a startup app carry a
secret in its env (e.g. HF_READ_TOKEN for model-runner's gated
HuggingFace weight downloads) without the secret value living in
git-tracked helm values:
"application_env_vars": {"*": {"_HF_READ_TOKEN": "${HF_READ_TOKEN}"}}
Expansion runs only on operator-supplied --startup-applications CLI
config, never on tenant deploy_app calls, so sourcing from the worker
env is safe. An unset ${VAR} is left verbatim.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
nilsmechtel
marked this pull request as ready for review
July 15, 2026 17:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_startup_applicationsnow recursively runsos.path.expandvarsover each parsed startup-application config, so a startup app can reference the worker's own environment — including secrets mounted viavalueFrom.secretKeyRef— as${VAR}.Motivation
Startup apps can only receive env vars through
application_env_varsin their startup-app JSON, and that JSON lives in git-tracked helm values. There was no way to give a startup app a secret without writing the raw value into git. Concretely,model-runner(≥1.15.11) needsHF_READ_TOKENto download gated HuggingFace weight sources (e.g.facebook/sam3) during package preparation — and that token must not be committed.With this change the operator can wire a k8s secret through cleanly:
The token value lives only in
bioengine-secrets; git holds only thesecretKeyRefand the${HF_READ_TOKEN}placeholder.What changed
bioengine/worker/__main__.py: new_expand_env_in_config(recurses dict/list/str), called on each parsed startup-app config inread_startup_applications.--startup-applicationsCLI config, never on tenantdeploy_appcalls, so sourcing from the worker env is safe. An unset${VAR}is left verbatim.tests/worker/test_startup_app_env_expansion.py.Testing
read_startup_applicationsexpansion.🤖 Generated with Claude Code