Repository navigation
refactor(docker): share repeated env keys through group files - #21862
devashish2203 wants to merge 4 commits into
Conversation
Moving the compose anchors into per-service env files turned each shared
group of keys into N identical copies. Put each group in one file that the
services needing it list in env_file, right before their own service file:
- env/docker/shared/{datastore,search,neo4j,indexing}.env
- env/docker/variants/<name>/shared.env for postgres, cassandra, neo4j,
localstack and onnx (their per-service files were identical)
Only identical lines move; the rendered compose model does not change.
datahub-upgrade.sh, the datahub-dev layer listing and env/README.md list
the group files too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR SummaryOverview Variant stacks consolidate identical per-service overrides into
Reviewed by Cursor Bugbot for commit 03b6144. Bugbot is set up for automated code reviews on this repo. Configure here. |
Smart test selectionpytest smoke testsMode: active. Only the selection below runs for the pytest smoke tests on this PR (applied:
Medium confidence: a wrong tag means tests are skipped, so check the tags above against what this PR touches. Selected scopes (19 files or classes, 112 tests)
Add the Playwright E2E testsThis run:
Add the commit |
There was a problem hiding this comment.
2 issues found across 31 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docker/datahub-upgrade/README.md">
<violation number="1" location="docker/datahub-upgrade/README.md:69">
P3: This says `system-update.env` "lists" the shared files, but it does not; the Compose `env_file` lists do. Reword to name the shared files as loaded before `system-update.env`, so readers don't look for an include directive that isn't there.</violation>
</file>
<file name="docker/datahub-upgrade/datahub-upgrade.sh">
<violation number="1" location="docker/datahub-upgrade/datahub-upgrade.sh:10">
P2: The readability guard only checks `system-update.env`, but the script now also reads four shared group files. If one is missing, perl warns and continues, and system-update starts without its datastore or search settings. Check every entry in `ENV_FILES` before running.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| cd $DIR && test -r ../../env/docker/system-update.env && docker pull ${IMAGE} && docker run --env-file <(perl -pe 's/\$\{(\w+):-([^}]*)\}/length($ENV{$1}) ? $ENV{$1} : $2/ge; s/\$\{(\w+)\}/$ENV{$1} \/\/ ""/ge' ../../env/docker/system-update.env) --network="datahub_network" ${IMAGE} "$@" | ||
| # Same files, in the same order, as the system-update env_file list in docker/profiles/. | ||
| ENV_FILES=(../../env/docker/shared/{datastore,search,neo4j,indexing}.env ../../env/docker/system-update.env) | ||
| cd $DIR && test -r ../../env/docker/system-update.env && docker pull ${IMAGE} && docker run --env-file <(perl -pe 's/\$\{(\w+):-([^}]*)\}/length($ENV{$1}) ? $ENV{$1} : $2/ge; s/\$\{(\w+)\}/$ENV{$1} \/\/ ""/ge' "${ENV_FILES[@]}") --network="datahub_network" ${IMAGE} "$@" |
There was a problem hiding this comment.
P2: The readability guard only checks system-update.env, but the script now also reads four shared group files. If one is missing, perl warns and continues, and system-update starts without its datastore or search settings. Check every entry in ENV_FILES before running.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docker/datahub-upgrade/datahub-upgrade.sh, line 10:
<comment>The readability guard only checks `system-update.env`, but the script now also reads four shared group files. If one is missing, perl warns and continues, and system-update starts without its datastore or search settings. Check every entry in `ENV_FILES` before running.</comment>
<file context>
@@ -5,4 +5,6 @@ VERSION=${DATAHUB_VERSION:-quickstart}
-cd $DIR && test -r ../../env/docker/system-update.env && docker pull ${IMAGE} && docker run --env-file <(perl -pe 's/\$\{(\w+):-([^}]*)\}/length($ENV{$1}) ? $ENV{$1} : $2/ge; s/\$\{(\w+)\}/$ENV{$1} \/\/ ""/ge' ../../env/docker/system-update.env) --network="datahub_network" ${IMAGE} "$@"
+# Same files, in the same order, as the system-update env_file list in docker/profiles/.
+ENV_FILES=(../../env/docker/shared/{datastore,search,neo4j,indexing}.env ../../env/docker/system-update.env)
+cd $DIR && test -r ../../env/docker/system-update.env && docker pull ${IMAGE} && docker run --env-file <(perl -pe 's/\$\{(\w+):-([^}]*)\}/length($ENV{$1}) ? $ENV{$1} : $2/ge; s/\$\{(\w+)\}/$ENV{$1} \/\/ ""/ge' "${ENV_FILES[@]}") --network="datahub_network" ${IMAGE} "$@"
</file context>
| cd $DIR && test -r ../../env/docker/system-update.env && docker pull ${IMAGE} && docker run --env-file <(perl -pe 's/\$\{(\w+):-([^}]*)\}/length($ENV{$1}) ? $ENV{$1} : $2/ge; s/\$\{(\w+)\}/$ENV{$1} \/\/ ""/ge' "${ENV_FILES[@]}") --network="datahub_network" ${IMAGE} "$@" | |
| cd $DIR && for f in "${ENV_FILES[@]}"; do test -r "$f" || { echo "datahub-upgrade.sh: missing env file $f" >&2; exit 1; }; done && docker pull ${IMAGE} && docker run --env-file <(perl -pe 's/\$\{(\w+):-([^}]*)\}/length($ENV{$1}) ? $ENV{$1} : $2/ge; s/\$\{(\w+)\}/$ENV{$1} \/\/ ""/ge' "${ENV_FILES[@]}") --network="datahub_network" ${IMAGE} "$@" |
| Below details the required configurations. By default, these configs are provided for local docker-compose deployments of | ||
| DataHub within `env/docker/system-update.env`. They assume that there is a Docker network called datahub_network | ||
| where the DataHub containers can be found. Some lines in that file use `${KEY:-default}` or `${KEY}`, which `docker run --env-file` does not resolve. `datahub-upgrade.sh` fills them in from your shell (an unset or empty key takes the default). The `docker run` examples below drop those lines (`grep -v '${'`), so those keys are not set; to set them, run the script or pass a copy with the values filled in. | ||
| DataHub within `env/docker/system-update.env` and the `env/docker/shared/` files it lists (`datastore`, `search`, `neo4j`, `indexing`). They assume that there is a Docker network called datahub_network |
There was a problem hiding this comment.
P3: This says system-update.env "lists" the shared files, but it does not; the Compose env_file lists do. Reword to name the shared files as loaded before system-update.env, so readers don't look for an include directive that isn't there.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docker/datahub-upgrade/README.md, line 69:
<comment>This says `system-update.env` "lists" the shared files, but it does not; the Compose `env_file` lists do. Reword to name the shared files as loaded before `system-update.env`, so readers don't look for an include directive that isn't there.</comment>
<file context>
@@ -66,8 +66,8 @@ To run the `datahub-upgrade` container, some environment variables must be provi
Below details the required configurations. By default, these configs are provided for local docker-compose deployments of
-DataHub within `env/docker/system-update.env`. They assume that there is a Docker network called datahub_network
-where the DataHub containers can be found. Some lines in that file use `${KEY:-default}` or `${KEY}`, which `docker run --env-file` does not resolve. `datahub-upgrade.sh` fills them in from your shell (an unset or empty key takes the default). The `docker run` examples below drop those lines (`grep -v '${'`), so those keys are not set; to set them, run the script or pass a copy with the values filled in.
+DataHub within `env/docker/system-update.env` and the `env/docker/shared/` files it lists (`datastore`, `search`, `neo4j`, `indexing`). They assume that there is a Docker network called datahub_network
+where the DataHub containers can be found. Some lines in those files use `${KEY:-default}` or `${KEY}`, which `docker run --env-file` does not resolve. `datahub-upgrade.sh` fills them in from your shell (an unset or empty key takes the default). The `docker run` examples below drop those lines (`grep -v '${'`), so those keys are not set; to set them, run the script or pass a copy with the values filled in.
</file context>
| DataHub within `env/docker/system-update.env` and the `env/docker/shared/` files it lists (`datastore`, `search`, `neo4j`, `indexing`). They assume that there is a Docker network called datahub_network | |
| DataHub within `env/docker/system-update.env` and the `env/docker/shared/` files loaded before it (`datastore`, `search`, `neo4j`, `indexing`). They assume that there is a Docker network called datahub_network |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Resolve datahub-upgrade.sh: keep the compose form and list the shared group files before system-update.env. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
david-leifker
left a comment
There was a problem hiding this comment.
Two things worth addressing, neither blocking.
-
The group-file list (
datastore,search,neo4j,indexing) is now spelled out by hand in several places: the composeenv_filelists,docker/mysql/docker-compose.mysql.yml,docker/datahub-upgrade/datahub-upgrade.shand_docker_layer_orderinscripts/dev/datahub_dev.py. The upgrade script's comment says "same files, same order" as the compose list, but nothing checks that. A check incompose_env_snapshot.pyor a unit test that compares the lists would stop them drifting. -
_docker_layer_orderonly models the GMS service, and not the variant files (postgres, cassandra, neo4j, onnx, debug). Sodatahub-dev env listshows an order that does not match what Compose uses for those profiles. If the list is meant to be informative, derive it fromdocker compose configinstead of rebuilding it by hand.
Stacked on #21839.
Why
Before this stack, a group of keys was one YAML anchor merged into several services. Moving the keys into per-service env files turned each group into N identical copies (134 redundant
KEY=valuelines underenv/docker/). This PR puts each group in one file that the services needing it list inenv_file.What
env/docker/shared/datastore.env_idhashing, Elasticsearch graphenv/docker/shared/search.envELASTICSEARCH_{HOST,PORT,PROTOCOL,USE_SSL}env/docker/shared/neo4j.envenv/docker/shared/indexing.envenv/docker/variants/{postgres,cassandra,neo4j,localstack,onnx}/shared.envLayer order per service:
env/docker/all.env, the service's group files,env/docker/<service>.env, mode files, then per variantvariants/<name>/shared.envandvariants/<name>/<service>.env. A group file loads before the service file, so the service file still wins. Only identical lines moved; no value changed.Other readers updated: every compose
env_filelist (incl. the legacydocker/mysqloverride),docker/datahub-upgrade/datahub-upgrade.sh(theenv_fileof its one-service compose file lists the four group files, thensystem-update.env) and its README, the GMS layer listing inscripts/dev/datahub_dev.py(+ test), andenv/README.md(layout, order, group table, where a new value goes).The GMS/system-update group list must stay in sync in three places: the compose lists,
_docker_layer_orderinscripts/dev/datahub_dev.py, anddatahub-upgrade.sh.Redundant copies: 134 before, 30 after. Left on purpose: the debug-variant telemetry keys and
DATAHUB_TELEMETRY_ENABLED(touched by a separate telemetry change),ZDU_STAGE_10/20(2-key pair),ES_BULK_REFRESH_POLICY+EXTRACT_JAR_ENABLED(unrelated pair), and single keys shared by odd service sets (DATAHUB_GMS_HOST,KAFKA_BOOTSTRAP_SERVER, ...).Verification
.github/scripts/check_quickstart_compose.sh: up to date;docker/quickstart/unchanged.smoke-test/check_env_parity.py: rc 0../gradlew :scripts:dev:test: 191 passed.datahub-upgrade.sh(compose-resolved one-service project,docker compose config) and the READMEgrepvariant produce the same 31 keys as before.Checklist
🤖 Generated with Claude Code
Summary by cubic
Restores the rendered compose model while replacing duplicated per-service env keys with shared group files: services list the groups they need in
env_file, and shared files load before service files so per-service and variant overrides still win.Group files
env/docker/shared/holds datastore, search, Neo4j, and indexing groups;datahub-upgrade.shand its README load the same group files in the same order as compose.variants/<name>/shared.envfor postgres, cassandra, neo4j, localstack, and onnx.Keep in sync
env_filelists,_docker_layer_orderinscripts/dev/datahub_dev.py, anddatahub-upgrade.sh.Written for commit b54889d. Summary will update on new commits.