refactor(docker): move datastore, graph, search and kafka env into env/docker

DE
15h ago
+546-130

Stacked on #21824 (step 3a). Moves the primary datastore, graph, search and Kafka values out of the docker/profiles/ compose anchors into env/docker layer files and new variant folders. The rendered compose config is unchanged in every scenario.

Moved keys

KeyFrom anchorTo file
EBEAN_DATASOURCE_{USERNAME,PASSWORD,HOST,URL,DRIVER} (MySQL)x-primary-datastore-mysql-envenv/docker/{system-update,gms,mae-consumer,mce-consumer}.env
EBEAN_DATASOURCE_* (Postgres), EBEAN_POSTGRES_USE_AWS_IAM_AUTH, DATAHUB_PGQUEUE_ENABLED, DATAHUB_PGQUEUE_MAINTENANCE_CRON_ENABLEDx-primary-datastore-postgres-envenv/docker/variants/postgres/{system-update,gms,mae-consumer,mce-consumer}.env
CASSANDRA_*, ENTITY_SERVICE_IMPL, plus the inline ZDU_STAGE_20: 'false'x-primary-datastore-cassandra-envenv/docker/variants/cassandra/{system-update,gms}.env
GRAPH_SERVICE_IMPL=elasticsearchx-graph-datastore-search-envthe four service files
GRAPH_SERVICE_IMPL=neo4j, NEO4J_*x-graph-datastore-neo4j-envenv/docker/variants/neo4j/{system-update,gms}.env
ELASTICSEARCH_{HOST,PORT,PROTOCOL,USE_SSL,IMPLEMENTATION,INDEX_DOC_IDS_SCHEMA_FIELD_HASH_ID_ENABLED}x-search-datastore-opensearch-envthe four service files
ELASTICSEARCH_{HOST,PORT,PROTOCOL,USE_SSL}x-search-datastore-elasticsearch-env (actions)env/docker/actions.env
KAFKA_BOOTSTRAP_SERVER, SCHEMA_REGISTRY_TYPEx-kafka-env, inline in system-update, frontend, actionsservice files (frontend and actions already had the same value)

The stale values the service files carried (ELASTICSEARCH_HOST=elasticsearch, GRAPH_SERVICE_IMPL=neo4j, older MySQL URLs) are replaced in place by the effective values. The unused x-search-datastore-search anchor in docker-compose.prerequisites.yml is deleted.

Variant folders

Order in each list: datastore, graph, debug. Compose does not merge lists, so docker-compose.gms.yml defines 12 anchored env_file lists (x-env-files-<service>-<variants>), one per service and variant set.

  • postgres: system-update, gms, mae-consumer and mce-consumer services of the quickstart-postgres* and debug-postgres* profiles.
  • cassandra: system-update and gms of quickstart-cassandra (with neo4j) and debug-cassandra.
  • neo4j: system-update and gms of quickstart-cassandra and debug-neo4j.

No mysql folder is needed. The datasource user and password read DATAHUB_EBEAN_DATASOURCE_ROOT_*, a name no env file sets, so the Postgres variant's default still applies after the MySQL one.

Kept in environment:

  • KAFKA_SCHEMAREGISTRY_URL and the actions SCHEMA_REGISTRY_URL: they interpolate DATAHUB_GMS_BASE_PATH, which stays in environment: too, so both read the same shell value.
  • Per-engine search overrides on the opensearch2, opensearch3 and elasticsearch services: there is no variant folder for search engines.
  • DATAHUB_MESSAGING_TRANSPORT: its default differs between postgres (pgqueue) and postgres with CDC (kafka). A later env file cannot change an opt-in default an earlier one set.
  • DATAHUB_SQL_SETUP_ENABLED: 'false' on the Cassandra system-update services: the base environment: value would beat a variant file.

Verification

The env snapshot tool (#21820) ran on this branch and on its base (#21824):

  • bare, shell, smoke, ai, zdu: 71 scenarios, no differences. That includes ad-hoc env files: none of them now wins over a moved key.
  • Gradle: all 27 quickstart_configs keys, including quickstart, quickstartDebug, quickstartPostgres and quickstartCassandra, rendered with the env and arguments that :docker:printComposeSettings (from #21820) reports. No differences. quickstartDebugSearchSplit does not render on either side, because its override file is not in the repo.
  • ./gradlew :docker:generateQuickstartComposeConfig produces no diff, and the generated file has no env_file key.
  • smoke-test/check_env_parity.py: exit 0.
  • datahub-upgrade.sh -u SystemUpdate against a running local stack: the upgrade job ran and succeeded.

Legacy consumers

These read the env files directly and now get the profile values instead of stale ones. The old values pointed at hosts the profile stacks do not run.

  • docker/datahub-upgrade/datahub-upgrade.sh (env/docker/system-update.env): the script no longer uses docker run --env-file, which passes ${...} literally. It pipes a one-service compose file, with env_file: ../../env/docker/system-update.env, into docker compose ... -f - run --rm -T upgrade. Compose resolves ${KEY:-default} and ${KEY} from the shell, as it does for the stack's own services, so those lines are no longer skipped. The README explains this; its plain docker run examples still drop those lines. Changed values:
    • EBEAN_DATASOURCE_USERNAME: datahub → root
    • EBEAN_DATASOURCE_URL: gains &rewriteBatchedStatements=true&enabledTLSProtocols=TLSv1.2
    • ELASTICSEARCH_HOST: elasticsearch → search
    • GRAPH_SERVICE_IMPL: neo4j → elasticsearch
    • New keys: ELASTICSEARCH_PROTOCOL=http, ELASTICSEARCH_USE_SSL=false, ELASTICSEARCH_IMPLEMENTATION=opensearch, ELASTICSEARCH_INDEX_DOC_IDS_SCHEMA_FIELD_HASH_ID_ENABLED=true, SCHEMA_REGISTRY_TYPE=INTERNAL
    • The ${...} lines from step 3a, which the script skipped before, are now passed with their resolved values.
    • Known limitations, older than this change and not fixed here: run on its own, the script still needs DATAHUB_SYSTEM_CLIENT_SECRET, DATAHUB_TOKEN_SERVICE_SIGNING_KEY and DATAHUB_TOKEN_SERVICE_SALT from the shell, because the env file never carried them; and the image tag uses DATAHUB_VERSION directly, so the script's VERSION default (quickstart) is not applied.
  • docker/mysql/docker-compose.mysql.yml (env/docker/gms.env through compose) gets the same changes: user root, host search, the Elasticsearch graph, and the new search and schema registry keys.

Deferred

  • CDC env: the CDC key sets differ from service to service. A later PR will make them uniform and then move them.
  • LocalStack env: it moves with the cloud keys. Its AWS_REGION only beats the bare AWS_REGION: pass-through through merge order.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (PR Title Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable): no new tests; verified with the snapshot tool above
  • Docs related to the changes have been added/updated (if applicable): env/README.md, docker/datahub-upgrade/README.md
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes: not needed

šŸ¤– Generated with Claude Code


Summary by cubic

Moves datastore, graph, search, and Kafka defaults from Compose anchors into env/docker service files and Postgres, Cassandra, and Neo4j variants, without changing the rendered Compose configuration.

  • datahub-upgrade.sh now runs the job through a one-service docker compose run so ${KEY} and ${KEY:-default} lines in system-update.env resolve from the shell environment; it no longer needs a host perl or drops the placeholders.
  • Schema-registry URLs and profile-specific overrides (search engine, messaging transport, Cassandra SQL setup) stay in environment: where moving them would change value resolution; CDC and LocalStack settings remain there for now.