Skip to content

bake: add execution mode - #4044

Draft
crazy-max wants to merge 4 commits into
docker:masterfrom
crazy-max:bake-execution
Draft

bake: add execution mode#4044
crazy-max wants to merge 4 commits into
docker:masterfrom
crazy-max:bake-execution

Conversation

@crazy-max

@crazy-max crazy-max commented Aug 31, 2026

Copy link
Copy Markdown
Member

This carries forward the syncable output work from #1197 and expands it into a general --execution option for Bake. The new option keeps the default behavior as fail-fast, adds sync-output so multi-target builds only write output after all selected targets reach the output boundary successfully, adds defer-error so independent targets can continue after another target fails, and supports parallel=N as a comma-separated execution option for limiting target concurrency.

This addresses the same class of partial-output and multi-target coordination problems discussed in #1089, #1668, #3297, #3428, and #3989. The sync-output mode is the piece needed for atomic-ish local output across targets, including failures during ref evaluation such as missing files. The defer-error mode covers workflows that need all independent targets to finish before reporting failure. The parallel option provides explicit target-level concurrency control without changing BuildKit internal parallelism.

@crazy-max crazy-max changed the title bake: add sync-output execution mode bake: add execution mode Aug 31, 2026
@crazy-max
crazy-max force-pushed the bake-execution branch 5 times, most recently from 7a76c27 to 1311cec Compare August 31, 2026 15:09
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Comment thread build/build.go
Comment on lines +641 to +643
if bh.Execution.Parallel > 0 && bh.Execution.Parallel < len(opts) {
return nil, errors.Errorf("sync-output execution requires parallelism to be unlimited or at least the number of targets")
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I kept sync-output compatible with parallel=N only when the limit is unlimited or at least the number of selected targets. A smaller limit can deadlock because sync-output waits for every target to reach the output boundary together.

Does it match what we want? Or should sync-output reject any explicit parallel limit for now?

Comment thread build/build.go
Comment on lines +652 to +654
if bh.Execution.Parallel < len(opts) && linkedTargets.hasLinks() {
return nil, errors.Errorf("limited parallelism is not supported with linked targets")
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I rejected limited target parallelism when linked targets are present because linked target evaluation can require parent and child targets to be alive together.

Does it make sense for this first version or should linked targets be allowed when the requested limit is high enough to cover each linked group?

Comment thread commands/bake.go
flags.StringArrayVar(&options.vars, "var", nil, `Set a variable value (e.g., "name=value")`)
flags.StringVar(&options.callFunc, "call", "build", `Set method for evaluating build ("check", "outline", "targets")`)
flags.StringArrayVar(&options.allow, "allow", nil, "Allow build to access specified resources")
flags.StringVar(&options.execution, "execution", "fail-fast", `Set target execution behavior (format: "mode[,parallel=N]")`)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I used --execution as the flag for target failure behavior, output synchronization, and target parallelism, but I'm not fully convinced this is the best name. Any ideas?

cc @dvdksn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

--jobs (also -j N), --strategy (Ansible).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants