bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.21k stars 4.06k forks source link

--worker_extra_flag does not respect worker-key-mnemonic #24237

Open AlessandroPatti opened 4 hours ago

AlessandroPatti commented 4 hours ago

Description of the bug:

The worker-key-mnemonic execution info allows sharing the same worker across multiple actions using different mnemonics by overriding the mnemonic that identifies the worker. This allows avoiding spawning multiple, usually resource intensive, workers for different actions that use the same worker executable. However, this does not work with --worker_extra_flag=<mnemonic>=<flag> since the mnemonic in this syntax is not the worker mnemonic, but the action mnemonic. This results in spawning multiple worker, nullifying the effect of the execution info, unless the same flags are specified for all the mnemonic using the worker.

Which category does this issue belong to?

Rules API

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create a rule with two actions:

ctx.actions.run(
    mnemonic = "Foo",
    executable = ctx.executable._worker,
    execution_info = {"worker-key-mnemonic": "Foo"},
    ...
)
ctx.actions.run(
    mnemonic = "Bar",
    executable = ctx.executable._worker,
    execution_info = {"worker-key-mnemonic": "Foo"},
    ...
)

The build a target of that rule passing --worker_extra_flag=Foo=--bar and see two workers spawned.

Which operating system are you running Bazel on?

Ubuntu

What is the output of bazel info release?

release 6.5.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

tjgq commented 4 hours ago

@bazel-io fork 8.0.0