Filter spawn strategies by execution platform
This PR implements part of the Execution Platform Scoped Spawn Strategies proposal.
It adds a new flag --allowed_strategies_by_exec_platform which permits filtering spawn strategies for spawns execution platform.
Example
# //.bazelrc
# Default strategies (order sensitive)
build --spawn_strategy=remote,worker,sandboxed,local
# Mnemonic targeted strategy override (order sensitive)
build --strategy=BAR=remote,sandboxed
# Host platform allowed strategies
build --allowed_strategies_by_exec_platform=@platforms//host:host=local,sandboxed,worker
# Remote platform allowed strategies
build --allowed_strategies_by_exec_platform=//:remote_platform=remote
For an action with mnemonic FOO configured for the host platform (@platforms//host:host), it will resolve worker,sandboxed,local as it's spawn strategy candidates.
remotewas eliminated as a candidate (not in allow list for platform).- Order from
--spawn_strategywas preserved.
For an action with mnemonic BAR configured for the host platform (@platforms//host:host), it will resolve sandboxed as it's spawn strategy candidate.
remotewas eliminated as a candidate (not in allow list for platform).- Mnemonic override applied, leaving
sandboxedas the final candidate.
For an action with mnemonic BAR configured for the remote platform (//:remote_platform), it will resolve remote as it's spawn strategy candidate.
sandboxedwas eliminated as a candidate (not in allow list for platform).- Mnemonic override applied, leaving
remoteas the final candidate.
If no spawn strategy candidate remains after filtering, the standard error will be logged.
ERROR: /workspaces/___/BUILD.bazel:3:22: _description_ [for tool] failed: _mnemonic_ spawn \
cannot be executed with any of the available strategies: []. Your --spawn_strategy, \
--genrule_strategy, --strategy and/or --allowed_strategies_by_exec_platform flags are probably \
too strict. Visit https://github.com/bazelbuild/bazel/issues/7480 for advice
cc @katre
@Silic0nS0ldier Can you please fix the test failures? (It looks like the execution platform is null in a bunch of places.)
@tjgq The null platform issue is fixed by https://github.com/bazelbuild/bazel/pull/23231 which this is dependent on.
What's the status of this PR?
I didn't have much time to focus on this recently, but I do now.
PR has been rebased and prior feedback implemented. This is now ready for review.
@gregestren This is ready for review.
@meteorcloudy Can you reassign this to @gregestren and ping him about it? Thanks.
@Silic0nS0ldier What's the status? Happy to help if you need any!
Waiting for review.
@gregestren I'll do a review pass soon. Let's try to get this into Bazel 9 as it nicely complements the new default test toolchain to finally make "what's executed where" work
@bazel-io fork 9.0.0
Checking in: I'll do a proper review Monday. Thanks for your ongoing patience @Silic0nS0ldier
Some internal tests are failing and blocking merging. I'll look into them and report back: keeping Bazel 9 cutoff timelines in mind.
Some internal tests are failing and blocking merging. I'll look into them and report back: keeping Bazel 9 cutoff timelines in mind.
Internal PR adjusted and now in the merge queue. Had to:
- register the filter values with Google's version of
BazelStrategyModule - add exec platforms to internal tests
- adjust
execution_strategies_testfor slightly different strategy names
Also applied a few code lints and BUILD dependency cleanups.
This'll get merged as soon as we get internal approvals.