Fix build slowdown when OpenTelemetry Exporter env variables are present #13163
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.
Closes #13157
Fixes a 10s slowdown on
docker compose build, including cached builds, whenOTEL_EXPORTER_*orOTEL_*_EXPORTERenv variables are present. Scrubs OpenTelemetry env variables when shelling out to bake.Bake was called with the full project environment. When a user's .env file include OpenTelemetry exporter env variables (eg.
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318), these were passed to buildx, which attempted to init its OTLP exporter and connect to an unreachable collector, making the process wait for a network timeout. For the user, this was during the "resolving provenance for metadata file" step visually.This is a short-term hotfix for the immediate issue, before more projects opt-out of Compose bake with
COMPOSE_BAKE=false. A better long term solution might be to sanitize the bake env with a minimal allowlist (eg. DOCKER_, BUILDX_, etc.) or update hasOtelEndpointInEnv detection in internal/tracing.Steps to reproduce