Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/scripts/check_quickstart_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,23 @@ if [ "$ORIGINAL_CONTENT" != "$NEW_CONTENT" ]; then
exit 1
fi

# `docker compose config` freezes every ${VAR} it resolves, so the generator swaps
# placeholders back for the ones users may override. Fail if one of them is lost.
# datahub-ai-service's overrides (DATAHUB_MAPPED_AI_PORT, DATAHUB_AI_MCP_ENABLED,
# DATAHUB_AI_IMAGE) join this list when the service joins the `quickstart` profile.
MISSING=0
for expr in \
'${DATAHUB_MAPPED_GMS_PORT:-8080}' \
'${DATAHUB_MAPPED_FRONTEND_PORT:-9002}'; do
if ! grep -qF -- "$expr" "$OUTPUT_FILE"; then
echo "ERROR: $OUTPUT_FILE no longer contains $expr"
MISSING=1
fi
done
if [ "$MISSING" -ne 0 ]; then
echo "Keep its placeholder in generateQuickstartComposeConfig (docker/build.gradle)."
exit 1
fi

echo "quickstart docker-compose config is up-to-date"
exit 0
23 changes: 17 additions & 6 deletions .github/scripts/resolve_image_builds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ IMAGES=(
":metadata-jobs:mce-consumer-job|datahub-mce-consumer|DATAHUB_MCE_VERSION|"
":datahub-frontend|datahub-frontend-react|DATAHUB_FRONTEND_VERSION|"
":datahub-actions|datahub-actions|DATAHUB_ACTIONS_VERSION|-slim"
":packages:datahub-ai-service|datahub-ai-service|DATAHUB_AI_VERSION|"
)

ACTIONS=":datahub-actions"
EVERYTHING=":metadata-service:war :datahub-upgrade :metadata-jobs:mae-consumer-job :metadata-jobs:mce-consumer-job :datahub-frontend ${ACTIONS}"
AI_SERVICE=":packages:datahub-ai-service"
EVERYTHING=":metadata-service:war :datahub-upgrade :metadata-jobs:mae-consumer-job :metadata-jobs:mce-consumer-job :datahub-frontend ${ACTIONS} ${AI_SERVICE}"

# Which images a changed path can affect: "<prefix>|<space separated modules>".
# First matching prefix wins, so specific prefixes precede general ones. An
# empty module list means the path cannot change any image.
#
# There are deliberately only three outcomes: nothing, actions-only, or all six.
# There are deliberately few outcomes: nothing, the Python images alone
# (actions and/or datahub-ai-service), or the whole set.
# An earlier revision distinguished server / frontend / shared-library changes
# with a per-image map derived from the Gradle graph (see git history). Measured
# on CI, those distinctions saved nothing: any JVM image build spends ~90% of
Expand All @@ -59,7 +62,7 @@ EVERYTHING=":metadata-service:war :datahub-upgrade :metadata-jobs:mae-consumer-j
# requested targets in parallel, so a smaller set costs the same as the full
# set. server-only measured 3.8m vs full 3.9m; frontend-only 4.2m. The two
# outcomes that do pay, measured: nothing (0.7m, saves ~3.2m) and actions-only
# (2.4m, saves ~1.5m) -- the Python image is the one build that skips the shared
# (2.4m, saves ~1.5m) -- the Python images are the builds that skip the shared
# JVM chain entirely.
PATH_RULES=(
# Cannot end up inside any image.
Expand All @@ -81,16 +84,24 @@ PATH_RULES=(
#
# Two snippets feed JVM service images and map to the full set:
# setup_java_runtime.sh (gms, frontend, mae, mce, upgrade, actions) and
# wait_for_deps.sh (gms, mae, mce, upgrade, ingestion-base). The rest of
# docker/snippets/ feeds only the ingestion/actions images.
# wait_for_deps.sh (gms, mae, mce, upgrade, ingestion-base). datahub-ai-service
# uses openssl4_ssl_compat.py and uv/; the rest of docker/snippets/ feeds only
# the ingestion/actions images.
"docker/snippets/setup_java_runtime.sh|${EVERYTHING}"
"docker/snippets/wait_for_deps.sh|${EVERYTHING}"
"docker/snippets/openssl4_ssl_compat.py|${ACTIONS} ${AI_SERVICE}"
"docker/snippets/uv/|${ACTIONS} ${AI_SERVICE}"
"docker/snippets/|${ACTIONS}"
"datahub-actions/|${ACTIONS}"
"docker/datahub-actions/|${ACTIONS}"
"docker/datahub-ingestion/|${ACTIONS}"
"docker/datahub-ingestion-base/|${ACTIONS}"
"metadata-ingestion/|${ACTIONS}"
# datahub-ai-service is Python too: it installs ../metadata-ingestion and both
# packages from source.
"docker/datahub-ai-service/|${AI_SERVICE}"
"packages/datahub-ai-service/|${AI_SERVICE}"
"packages/datahub-core-mcp-tools/|${AI_SERVICE}"
"metadata-ingestion/|${ACTIONS} ${AI_SERVICE}"
"metadata-ingestion-modules/|${ACTIONS}"

# Everything below can alter a JVM image, and per the note above there is no
Expand Down
19 changes: 12 additions & 7 deletions .github/scripts/test_resolve_image_builds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ check_fails() {
printf ' ok %s\n' "${name}"
}

ALL=":metadata-service:war,:datahub-upgrade,:metadata-jobs:mae-consumer-job,:metadata-jobs:mce-consumer-job,:datahub-frontend,:datahub-actions"
ALL=":metadata-service:war,:datahub-upgrade,:metadata-jobs:mae-consumer-job,:metadata-jobs:mce-consumer-job,:datahub-frontend,:datahub-actions,:packages:datahub-ai-service"
PYTHON_IMAGES=":datahub-actions,:packages:datahub-ai-service"

echo "nothing that reaches an image"
check "smoke-test only" "" 'CHANGED_FILES=["smoke-test/tests/a_test.py"]'
Expand All @@ -177,10 +178,13 @@ check "product-update json" "" 'CHANGED_FILES=["metadata-service/configuration/s
check "product-update saas json" "" 'CHANGED_FILES=["metadata-service/configuration/src/main/resources/product-update-saas.json"]'
check "productUpdateCiGate" "" 'CHANGED_FILES=["metadata-service/configuration/src/productUpdateCiGate/java/com/linkedin/metadata/config/productupdate/ProductUpdateReleaseSyncTest.java"]'

echo "ingestion only rebuilds actions"
check "metadata-ingestion" ":datahub-actions" 'CHANGED_FILES=["metadata-ingestion/src/datahub/emitter/rest_emitter.py"]'
echo "ingestion only rebuilds the Python images"
check "metadata-ingestion" "${PYTHON_IMAGES}" 'CHANGED_FILES=["metadata-ingestion/src/datahub/emitter/rest_emitter.py"]'
check "datahub-actions" ":datahub-actions" 'CHANGED_FILES=["datahub-actions/src/x.py"]'
check "actions readme (baked into image)" ":datahub-actions" 'CHANGED_FILES=["datahub-actions/README.md"]'
check "datahub-ai-service" ":packages:datahub-ai-service" 'CHANGED_FILES=["packages/datahub-ai-service/src/datahub_ai_service/app.py"]'
check "datahub-core-mcp-tools (bundled in the ai-service image)" ":packages:datahub-ai-service" 'CHANGED_FILES=["packages/datahub-core-mcp-tools/src/datahub_core_mcp_tools/mcp_server.py"]'
check "ai-service dockerfile" ":packages:datahub-ai-service" 'CHANGED_FILES=["docker/datahub-ai-service/requirements.lock"]'

echo "reused images are pinned to a digest, not the bare floating tag"
check_version_env "reused image pinned to quickstart@digest" \
Expand All @@ -189,7 +193,7 @@ check_version_env "reused image pinned to quickstart@digest" \
check_version_env "reused -slim image pinned to its own digest" \
"DATAHUB_ACTIONS_VERSION=quickstart-slim@sha256:0000000000000000000000000000000000000000000000000000004119348442" \
'CHANGED_FILES=["smoke-test/tests/a_test.py"]'
check "ingestion plus docs" ":datahub-actions" 'CHANGED_FILES=["metadata-ingestion/src/datahub/x.py","docs/a.md","smoke-test/tests/b_test.py"]'
check "ingestion plus docs" "${PYTHON_IMAGES}" 'CHANGED_FILES=["metadata-ingestion/src/datahub/x.py","docs/a.md","smoke-test/tests/b_test.py"]'

echo "any JVM-image path builds the full set (measured: narrowing saved nothing)"
check "datahub-web-react" "${ALL}" 'CHANGED_FILES=["datahub-web-react/src/App.tsx"]'
Expand All @@ -206,6 +210,7 @@ check "service dockerfile" "${ALL}" 'CHANGED_FILES=["docker/datahub-gms/Dockerfi
check "jvm-shared snippet" "${ALL}" 'CHANGED_FILES=["docker/snippets/setup_java_runtime.sh"]'
check "jvm-shared snippet (wait_for_deps)" "${ALL}" 'CHANGED_FILES=["docker/snippets/wait_for_deps.sh"]'
check "ingestion-only snippet" ":datahub-actions" 'CHANGED_FILES=["docker/snippets/ingestion_base.template"]'
check "uv snippet (both Python images)" "${PYTHON_IMAGES}" 'CHANGED_FILES=["docker/snippets/uv/uv.toml"]'
check "ingestion plus jvm" "${ALL}" 'CHANGED_FILES=["metadata-ingestion/src/datahub/x.py","metadata-io/src/main/java/A.java"]'

echo "unclassified paths force a full build"
Expand All @@ -232,9 +237,9 @@ check "publish label bakes every image even with a smoke profile" \
SMOKE_BUILD_TASK=:docker:buildImagesquickstartPg \
SMOKE_MODULES=":datahub-upgrade :metadata-service:war :datahub-frontend :datahub-actions" \
'CHANGED_FILES=["smoke-test/a.py"]'
QUICKSTART_PG_MODULES=":datahub-upgrade :metadata-service:war :datahub-frontend :datahub-actions"
QUICKSTART_PG_BUILT=":metadata-service:war,:datahub-upgrade,:datahub-frontend,:datahub-actions"
QUICKSTART_PG_CONSUMERS_MODULES=":datahub-upgrade :metadata-service:war :datahub-frontend :metadata-jobs:mce-consumer-job :metadata-jobs:mae-consumer-job :datahub-actions"
QUICKSTART_PG_MODULES=":datahub-upgrade :metadata-service:war :datahub-frontend :datahub-actions :packages:datahub-ai-service"
QUICKSTART_PG_BUILT=":metadata-service:war,:datahub-upgrade,:datahub-frontend,:datahub-actions,:packages:datahub-ai-service"
QUICKSTART_PG_CONSUMERS_MODULES=":datahub-upgrade :metadata-service:war :datahub-frontend :metadata-jobs:mce-consumer-job :metadata-jobs:mae-consumer-job :datahub-actions :packages:datahub-ai-service"
# Same fake digest the curl stub emits for the bare `quickstart` tag.
QUICKSTART_DIGEST="sha256:0000000000000000000000000000000000000000000000000000003571886052"
check "smoke: quickstartPg builds its modules only" \
Expand Down
3 changes: 2 additions & 1 deletion .github/security-scan-profiles.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"datahub-upgrade": {},
"datahub-actions": {
"variant_suffixes": ["", "-slim", "-locked"]
}
},
"datahub-ai-service": {}
}
}
},
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/datahub-ai-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,55 @@ jobs:
artifact-name: ${{ matrix.package }}-test-results
test-results-paths: "packages/${{ matrix.package }}/test-results/**"
junit-file-globs: "packages/${{ matrix.package }}/test-results/*.xml"

image:
# Builds the image the way the release does (single arch here; docker-unified
# publishes amd64 + arm64) and checks what a broken Dockerfile or a dependency
# bump would change silently: its size, its user, and that it becomes healthy.
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
IMAGE: acryldata/datahub-ai-service:debug
# Uncompressed size on the runner; the image was ~365 MB when this was set.
SIZE_BUDGET_MB: 450
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up toolchain
uses: ./.github/actions/setup-toolchain
- name: Build image
run: ./gradlew :packages:datahub-ai-service:docker
- name: Size budget
run: |
size_mb=$(( $(docker image inspect "$IMAGE" --format '{{.Size}}') / 1000000 ))
echo "datahub-ai-service image: ${size_mb} MB (budget ${SIZE_BUDGET_MB} MB)" | tee -a "$GITHUB_STEP_SUMMARY"
if (( size_mb > SIZE_BUDGET_MB )); then
echo "::error::datahub-ai-service image is ${size_mb} MB, over its ${SIZE_BUDGET_MB} MB budget"
exit 1
fi
- name: Runs as non-root, without curl
run: |
user=$(docker image inspect "$IMAGE" --format '{{.Config.User}}')
if [[ -z "$user" || "$user" == root || "$user" == 0 ]]; then
echo "::error::image runs as '${user:-root}'"
exit 1
fi
if docker run --rm --entrypoint sh "$IMAGE" -c 'command -v curl'; then
echo "::error::curl is installed in the image"
exit 1
fi
- name: Healthy without GMS
# The service must start, and report healthy, before GMS is reachable.
run: |
docker run -d --name ai -p 127.0.0.1:9005:9005 \
-e DATAHUB_GMS_URL=http://gms.invalid:8080 "$IMAGE"
for i in $(seq 1 30); do
health=$(docker inspect ai --format '{{.State.Health.Status}}')
[[ "$health" == healthy ]] && break
sleep 1
done
echo "health after ${i}s: ${health}"
curl -fsS http://127.0.0.1:9005/health
if [[ "$health" != healthy ]]; then
docker logs ai
exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Health failure hides container logs

Low Severity

The host curl to /health runs before docker logs, and GitHub Actions runs this step with set -e. When the container never listens, curl -fsS aborts the step, so the log dump in the unhealthy branch never runs. That is the usual failure mode this job exists to catch, and it leaves only a connection error instead of the process traceback.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 73dbb4b. Configure here.

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.

small one but valid, moving the unhealthy check + docker logs before the curl would keep the traceback when it never starts

fi
20 changes: 11 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,17 @@ See [scripts/dev/README.md](scripts/dev/README.md) for details and offline tests

### Module-to-Container Mapping

| Source directory | Container |
| --------------------------------- | --------------------------------------------- |
| `metadata-service/` | `datahub-gms` |
| `datahub-graphql-core/` | `datahub-gms` |
| `metadata-io/` | `datahub-gms` |
| `datahub-frontend/` | `datahub-frontend-react` |
| `metadata-jobs/mce-consumer-job/` | `datahub-mce-consumer` |
| `metadata-jobs/mae-consumer-job/` | `datahub-mae-consumer` |
| `metadata-models/` | All (triggers full rebuild + code generation) |
| Source directory | Container |
| ---------------------------------- | --------------------------------------------- |
| `metadata-service/` | `datahub-gms` |
| `datahub-graphql-core/` | `datahub-gms` |
| `metadata-io/` | `datahub-gms` |
| `datahub-frontend/` | `datahub-frontend-react` |
| `packages/datahub-ai-service/` | `datahub-ai-service` |
| `packages/datahub-core-mcp-tools/` | `datahub-ai-service` |
| `metadata-jobs/mce-consumer-job/` | `datahub-mce-consumer` |
| `metadata-jobs/mae-consumer-job/` | `datahub-mae-consumer` |
| `metadata-models/` | All (triggers full rebuild + code generation) |

### Environment Variables

Expand Down
22 changes: 16 additions & 6 deletions docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ext {
]

python_services_modules = [
':packages:datahub-ai-service',
]

// Load environment variables from file if DATAHUB_LOCAL_COMMON_ENV is set
Expand Down Expand Up @@ -167,7 +168,7 @@ ext {
],
'quickstartOS2': [
profile: 'quickstart-opensearch2',
modules: backend_profile_modules + [':datahub-frontend', ':datahub-actions'],
modules: python_services_modules + backend_profile_modules + [':datahub-frontend', ':datahub-actions'],
],
'quickstartOS2Debug': [
profile: 'debug-opensearch2',
Expand All @@ -179,7 +180,7 @@ ext {
],
'quickstartOS3': [
profile: 'quickstart-opensearch3',
modules: backend_profile_modules + [':datahub-frontend', ':datahub-actions'],
modules: python_services_modules + backend_profile_modules + [':datahub-frontend', ':datahub-actions'],
// Image-based CI stack still needs /openapi/operations/dev/featureFlags
// (smoke-test/tests/dev_tooling). Compose defaults DEV_TOOLING_ENABLED to false.
additionalEnv: [
Expand Down Expand Up @@ -232,7 +233,7 @@ ext {
],
'quickstartCDC': [
profile: 'quickstart-consumers-cdc',
modules: backend_profile_modules + [':datahub-frontend',
modules: python_services_modules + backend_profile_modules + [':datahub-frontend',
':metadata-jobs:mce-consumer-job',
':metadata-jobs:mae-consumer-job',
':datahub-actions',
Expand Down Expand Up @@ -262,14 +263,14 @@ ext {
],
'quickstartPg': [
profile: 'quickstart-postgres',
modules: backend_profile_modules + [
modules: python_services_modules + backend_profile_modules + [
':datahub-frontend',
':datahub-actions',
]
],
'quickstartPgConsumers': [
profile: 'quickstart-postgres-consumers',
modules: backend_profile_modules + [
modules: python_services_modules + backend_profile_modules + [
':datahub-frontend',
':metadata-jobs:mce-consumer-job',
':metadata-jobs:mae-consumer-job',
Expand All @@ -278,7 +279,7 @@ ext {
],
'quickstartPgCdc': [
profile: 'quickstart-postgres-cdc',
modules: backend_profile_modules + [
modules: python_services_modules + backend_profile_modules + [
':datahub-frontend',
':datahub-actions',
]
Expand Down Expand Up @@ -355,6 +356,7 @@ ext {
// Though these support hot reload, they need to be restarted if any ENVs have been modified and ReloadEnv is run.
moduleToContainerWithHotReload = [
':datahub-actions': 'datahub-actions',
':packages:datahub-ai-service': 'datahub-ai-service',
]

// Helper function to read the captured profile name from file
Expand Down Expand Up @@ -563,6 +565,10 @@ task generateQuickstartComposeConfig {
// Use unique high port numbers as placeholders that will be replaced later
composeExecutor.parameters.environment.put("DATAHUB_MAPPED_GMS_PORT", '58080')
composeExecutor.parameters.environment.put("DATAHUB_MAPPED_FRONTEND_PORT", '59002')
composeExecutor.parameters.environment.put("DATAHUB_MAPPED_AI_PORT", '59005')
composeExecutor.parameters.environment.put("DATAHUB_AI_MCP_ENABLED", '__AI_MCP_ENABLED__')
composeExecutor.parameters.environment.put("MCP_SERVER_ENABLED", '__MCP_SERVER_ENABLED__')
composeExecutor.parameters.environment.put("DATAHUB_AI_IMAGE", '__AI_IMAGE__')

def configOutput = composeExecutor.execute('config')

Expand All @@ -575,6 +581,9 @@ task generateQuickstartComposeConfig {
configOutput = configOutput.replace('__SALT__', '${DATAHUB_TOKEN_SERVICE_SALT}')
configOutput = configOutput.replace('__SYSTEM_CLIENT_SECRET__', '${DATAHUB_SYSTEM_CLIENT_SECRET:-JohnSnowKnowsNothing}')
configOutput = configOutput.replace(System.getenv('HOME'), '${HOME}')
configOutput = configOutput.replace('__AI_MCP_ENABLED__', '${DATAHUB_AI_MCP_ENABLED:-true}')
configOutput = configOutput.replace('__MCP_SERVER_ENABLED__', '${MCP_SERVER_ENABLED:-false}')
configOutput = configOutput.replace('__AI_IMAGE__', '${DATAHUB_AI_IMAGE:-acryldata/datahub-ai-service}')

// Parse configOutput as yaml and add UI_INGESTION_DEFAULT_CLI_VERSION as an env var under datahub-gms-quickstart.environment key
// This needs to be matched with the version of the CLI used to launch quickstart
Expand All @@ -593,6 +602,7 @@ task generateQuickstartComposeConfig {
// Replace port placeholders with environment variable syntax (after YAML processing)
configOutput = configOutput.replace("published: '58080'", 'published: ${DATAHUB_MAPPED_GMS_PORT:-8080}')
configOutput = configOutput.replace("published: '59002'", 'published: ${DATAHUB_MAPPED_FRONTEND_PORT:-9002}')
configOutput = configOutput.replace("published: '59005'", 'published: ${DATAHUB_MAPPED_AI_PORT:-9005}')

// Preserve create_host_path so host dirs (e.g. ~/.datahub/plugins) are created on first run
configOutput = configOutput.replace("bind: {}", "bind:\n create_host_path: true")
Expand Down
3 changes: 3 additions & 0 deletions docker/datahub-ai-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ RUN test -n "${RELEASE_VERSION}" && \
sed -i "s/__version__ = .*$/__version__ = \"${RELEASE_VERSION}\"/" "$f"; \
done

# Building these source trees fetches their build requirements (setuptools, wheel) from the
# same index as the lock install above, so it needs the same credentials.
RUN --mount=type=cache,target=/home/datahub/.cache/uv,uid=1000,gid=1000 \
--mount=type=secret,id=netrc,target=/home/datahub/.netrc,required=false,uid=1000,gid=1000 \
uv pip install --no-deps /src/metadata-ingestion /src/datahub-core-mcp-tools /src/datahub-ai-service && \
# The image scanner reads pip's vendored SBOM and reports packages that aren't installed.
find $VIRTUAL_ENV -path '*/pip/_vendor/bom.cdx.json' -delete && \
Expand Down
Loading
Loading