Skip to content

refactor(docker): share repeated env keys through group files - #21862

Open
devashish2203 wants to merge 4 commits into
pfp-8979-mae-auth-layerfrom
env-shared-group-files
Open

devashish2203 wants to merge 4 commits into
pfp-8979-mae-auth-layerfrom
env-shared-group-files

Conversation

@devashish2203

@devashish2203 devashish2203 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

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=value lines under env/docker/). This PR puts each group in one file that the services needing it list in env_file.

What

File Keys Listed by
env/docker/shared/datastore.env MySQL datasource, schema registry type/URL, OpenSearch implementation + _id hashing, Elasticsearch graph gms, system-update, mae-consumer, mce-consumer
env/docker/shared/search.env ELASTICSEARCH_{HOST,PORT,PROTOCOL,USE_SSL} the four above + actions
env/docker/shared/neo4j.env Neo4j connection gms, system-update, mae-consumer
env/docker/shared/indexing.env reindex flags, timeseries refresh interval gms, system-update
env/docker/variants/{postgres,cassandra,neo4j,localstack,onnx}/shared.env the variant's values (the per-service files were identical) the services of that variant

Layer order per service: env/docker/all.env, the service's group files, env/docker/<service>.env, mode files, then per variant variants/<name>/shared.env and variants/<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_file list (incl. the legacy docker/mysql override), docker/datahub-upgrade/datahub-upgrade.sh (the env_file of its one-service compose file lists the four group files, then system-update.env) and its README, the GMS layer listing in scripts/dev/datahub_dev.py (+ test), and env/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_order in scripts/dev/datahub_dev.py, and datahub-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

  • Compose env snapshot (bare, shell, smoke, ai scenarios) base vs head: no differences in the rendered compose model. Gradle scenarios need a task not on this branch, so they were not compared.
  • .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 README grep variant produce the same 31 keys as before.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (PR Title Format)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes (not breaking: no rendered change)

🤖 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

  • New env/docker/shared/ holds datastore, search, Neo4j, and indexing groups; datahub-upgrade.sh and its README load the same group files in the same order as compose.
  • Variant values move from per-service files into variants/<name>/shared.env for postgres, cassandra, neo4j, localstack, and onnx.
  • Redundant lines drop from 134 to 30; remaining pairs and odd single keys stay duplicated deliberately.

Keep in sync

  • GMS and system-update group lists must match across the compose env_file lists, _docker_layer_order in scripts/dev/datahub_dev.py, and datahub-upgrade.sh.

Written for commit b54889d. Summary will update on new commits.

View guided diff Turn on auto-fix

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>
@github-actions github-actions Bot added the devops PR or Issue related to DataHub backend & deployment label Dec 3, 2026
@cursor

cursor Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Introduces env/docker/shared/ group files (datastore, search, neo4j, indexing) so MySQL, search, Neo4j, and index settings are defined once instead of duplicated across gms, system-update, and consumer env files. Compose, the legacy MySQL override, datahub-upgrade.sh, and env/README.md now load those groups in a fixed order before each service’s own .env.

Variant stacks consolidate identical per-service overrides into env/docker/variants/<name>/shared.env (postgres, cassandra, neo4j, localstack, onnx), and compose switches variant env_file anchors from per-service paths to each variant’s shared.env. Per-service variant files that only duplicated those keys are removed; service files keep only service-specific settings.

scripts/dev/datahub_dev.py _docker_layer_order and tests are updated so local dev env resolution matches compose.

Reviewed by Cursor Bugbot for commit 03b6144. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: active. Only the selection below runs for the pytest smoke tests on this PR (applied: smart).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 112 of 853 tests in 1 batch, predicted longest batch ~2 min
  • Tags: change-type: docs, test-infra, tooling; feature-dev: bootstrap, graph-index, search-indexing; technical-layer: ebean-mysql, elasticsearch, spring-config
  • Confidence: MEDIUM (31 changed files)
  • Classifier reasoning: Docker env files are regrouped into shared files that change GMS, system-update and consumer search, graph and index settings, while the dev script, its test and the READMEs are tooling, test-infra and docs.

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)
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/browse/browse_test.py
  • tests/e2e/datapack/test_datapack_smoke.py::TestDatapackCLI
  • tests/e2e/datapack/test_datapack_smoke.py::TestDemoDataBootstrap
  • tests/e2e/datapack/test_datapack_smoke.py::TestShowcaseData
  • tests/e2e/delete/delete_assertion_cascade_test.py
  • tests/e2e/entity_graph_cache/test_entity_graph_cache.py::TestContainer
  • tests/e2e/entity_graph_cache/test_entity_graph_cache.py::TestDomain
  • tests/e2e/entity_graph_cache/test_entity_graph_cache.py::TestGlossary
  • tests/e2e/entity_graph_cache/test_entity_graph_cache.py::TestMembership
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/graph/test_graph_client.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/openapi/v3/test_scroll_relationships.py
  • tests/e2e/query_projection/test_query_projection_smoke.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/search/test_lineage_search_index_fields.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection
  • tests/e2e/test_e2e.py

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

Playwright E2E tests

This run: p0

  • Selection: p0: no spec is tagged bootstrap, graph-index, search-indexing, so P0 tests plus the tests the change affects
  • Size: 145 tests in 79 spec files, ~32 min predicted on 4 shard(s)
  • Baseline: 79 spec files run for every PR (@p0)
  • No spec was selected because of this PR's changes.

Add the run-all-tests:playwright label to run the full Playwright suite on this PR.

commit b54889d · workflow run

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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} "$@"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
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

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 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 david-leifker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things worth addressing, neither blocking.

  1. The group-file list (datastore, search, neo4j, indexing) is now spelled out by hand in several places: the compose env_file lists, docker/mysql/docker-compose.mysql.yml, docker/datahub-upgrade/datahub-upgrade.sh and _docker_layer_order in scripts/dev/datahub_dev.py. The upgrade script's comment says "same files, same order" as the compose list, but nothing checks that. A check in compose_env_snapshot.py or a unit test that compares the lists would stop them drifting.

  2. _docker_layer_order only models the GMS service, and not the variant files (postgres, cassandra, neo4j, onnx, debug). So datahub-dev env list shows an order that does not match what Compose uses for those profiles. If the list is meant to be informative, derive it from docker compose config instead of rebuilding it by hand.

This branch was successfully deployed

1 active deployment
Preview — b54889d6 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops PR or Issue related to DataHub backend & deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants