Skip to content

[FLINK-39796] Fix snapshot bake by pinning bake-action to local source#261

Merged
RocMarshal merged 1 commit into
apache:masterfrom
confluentinc:FLINK-39796-fix-snapshot-bake-source
May 31, 2026
Merged

[FLINK-39796] Fix snapshot bake by pinning bake-action to local source#261
RocMarshal merged 1 commit into
apache:masterfrom
confluentinc:FLINK-39796-fix-snapshot-bake-source

Conversation

@lihaosky
Copy link
Copy Markdown
Contributor

Problem

The Publish SNAPSHOTs workflow has been failing on every run. Each matrix job dies at the Build and push Docker images step with:

ERROR: failed to find target docker-metadata-action
##[error]cannot parse bake definitions: ERROR: failed to find target docker-metadata-action

Root cause

docker-bake.hcl's bake-platform target does inherits = ["docker-metadata-action"]. That target is defined as an empty stub (target "docker-metadata-action" {}) on every dev-* branch, but not on master.

The regression was triggered by [FLINK-39796] bumping docker/bake-action from v4 to v7. v7 changed the default of an unset source input: instead of baking the local working tree, it now falls back to the workflow's own git context and bakes it as a remote ref, so buildx fetches docker-bake.hcl (and the build context) from the triggering commit on master:

docker buildx bake https://github.com/apache/flink-docker.git#<sha> --file .github/workflows/docker-bake.hcl ... bake-platform

Since the job checks out a dev-* branch but v7 reads master, two things break:

  1. master's docker-bake.hcl lacks the docker-metadata-action stub → inherits fails.
  2. The snapshot Dockerfile is generated at runtime by add-custom.sh into the local working tree and is never committed, so a remote bake context could not find $DOCKER_FILE anyway.

This is why the workflow was green on v4 (which baked the local dev-* checkout that has both the stub and the generated Dockerfile) and red on v7.

Fix

Set source: . on the bake step to restore the pre-v7 behavior of baking the local working tree. This resolves both issues at once: the checked-out dev-* tree contains both the generated Dockerfile and the docker-metadata-action stub.

Notes

  • An alternative/complementary change would be to add target "docker-metadata-action" {} to master's docker-bake.hcl to match the dev-* branches. That alone is not sufficient under v7's remote bake, because the runtime-generated Dockerfile still wouldn't exist in the remote context — hence pinning source: . is the actual fix.

bake-action v7 changed the default of an unset `source` input: it now
falls back to the workflow's git context and bakes it as a remote ref,
so buildx fetches docker-bake.hcl and the build context from the
triggering commit on master.

That breaks the snapshot workflow for two reasons:
  1. master's docker-bake.hcl lacks the `target "docker-metadata-action" {}`
     stub that every dev-* branch defines, so `inherits` fails with
     `failed to find target docker-metadata-action`.
  2. the snapshot Dockerfile is generated at runtime by add-custom.sh into
     the local working tree and is not committed, so a remote bake context
     could not find it anyway.

Setting `source: .` restores the pre-v7 behavior of baking the local
working tree (the checked-out dev-* branch), which has both the generated
Dockerfile and the docker-metadata-action stub.
@lihaosky lihaosky marked this pull request as ready for review May 29, 2026 18:21
Copy link
Copy Markdown

@RocMarshal RocMarshal left a comment

Choose a reason for hiding this comment

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

Thanks @lihaosky

@RocMarshal RocMarshal merged commit 2a96d70 into apache:master May 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants