From 0aa7483b432b65efd1d544449d651b7803e705ba Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 24 Jun 2021 12:10:41 -0700 Subject: [PATCH] Remove --experimental_worker_allow_json_protocol Closes https://github.com/bazelbuild/bazel/issues/13599 --- site/docs/creating-workers.md | 4 +--- site/docs/persistent-workers.md | 18 ++++++------------ .../build/lib/worker/WorkerOptions.java | 10 ---------- .../build/lib/worker/WorkerSpawnRunner.java | 11 +---------- .../shell/integration/bazel_worker_test.sh | 1 - 5 files changed, 8 insertions(+), 36 deletions(-) diff --git a/site/docs/creating-workers.md b/site/docs/creating-workers.md index 6e8eaa2995c1a3..d31786308df030 100644 --- a/site/docs/creating-workers.md +++ b/site/docs/creating-workers.md @@ -12,9 +12,7 @@ would benefit from cross-action caching, you may want to implement your own persistent worker to perform these actions. The Bazel server communicates with the worker using `stdin`/`stdout`. It -supports the use of protocol buffers or JSON strings. Support for JSON is -experimental and thus subject to change. It is guarded behind the -`--experimental_worker_allow_json_protocol` flag. +supports the use of protocol buffers or JSON strings. The worker implementation has two parts: diff --git a/site/docs/persistent-workers.md b/site/docs/persistent-workers.md index c93162970eb873..149f02452663da 100644 --- a/site/docs/persistent-workers.md +++ b/site/docs/persistent-workers.md @@ -137,11 +137,6 @@ flag makes each worker request use a separate sandbox directory for all its inputs. Setting up the [sandbox](sandboxing.md) takes some extra time, especially on macOS, but gives a better correctness guarantee. -You can use the `--experimental_worker_allow_json_protocol` flag to allow -workers to communicate with Bazel through JSON instead of protocol buffers -(protobuf). The worker and the rule that consumes it can then be modified to -support JSON. - The [`--worker_quit_after_build`](command-line-reference.html#flag--worker_quit_after_build) flag is mainly useful for debugging and profiling. This flag forces all workers @@ -195,13 +190,12 @@ inputs: [ ``` The worker receives this on `stdin` in JSON format (because -`requires-worker-protocol` is set to JSON, and -`--experimental_worker_allow_json_protocol` is passed to the build to enable -this option). The worker then performs the action, and sends a JSON-formatted -`WorkResponse` to Bazel on its stdout. Bazel then parses this response and -manually converts it to a `WorkResponse` proto. To communicate -with the associated worker using binary-encoded protobuf instead of JSON, -`requires-worker-protocol` would be set to `proto`, like this: +`requires-worker-protocol` is set to JSON). The worker then performs the +action, and sends a JSON-formatted `WorkResponse` to Bazel on its +stdout. Bazel then parses this response and manually converts it to a +`WorkResponse` proto. To communicate with the associated worker using +binary-encoded protobuf instead of JSON, `requires-worker-protocol` +would be set to `proto`, like this: ``` execution_requirements = { diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java index 6a2b9b9e8721c5..1e87fce5c9f406 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java @@ -46,16 +46,6 @@ public class WorkerOptions extends OptionsBase { }) public Void experimentalPersistentJavac; - @Option( - name = "experimental_worker_allow_json_protocol", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, - effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS}, - help = - "Allows workers to use the JSON worker protocol until it is determined to be" - + " stable.") - public boolean experimentalJsonWorkerProtocol; - /** * Defines a resource converter for named values in the form [name=]value, where the value is * {@link ResourceConverter.FLAG_SYNTAX}. If no name is provided (used when setting a default), diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java index 7beaee3df7bc7b..17b1fc28c87766 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java @@ -187,15 +187,6 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) execRoot); SandboxOutputs outputs = helpers.getOutputs(spawn); - WorkerProtocolFormat protocolFormat = Spawns.getWorkerProtocolFormat(spawn); - if (!workerOptions.experimentalJsonWorkerProtocol) { - if (protocolFormat == WorkerProtocolFormat.JSON) { - throw new IOException( - "Persistent worker protocol format must be set to proto unless" - + " --experimental_worker_allow_json_protocol is used"); - } - } - WorkerKey key = new WorkerKey( workerArgs, @@ -207,7 +198,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) context.speculating(), multiplex && Spawns.supportsMultiplexWorkers(spawn), Spawns.supportsWorkerCancellation(spawn), - protocolFormat); + Spawns.getWorkerProtocolFormat(spawn)); SpawnMetrics.Builder spawnMetrics = SpawnMetrics.Builder.forWorkerExec() diff --git a/src/test/shell/integration/bazel_worker_test.sh b/src/test/shell/integration/bazel_worker_test.sh index 157d88d007e74e..17b21ec1a2b533 100755 --- a/src/test/shell/integration/bazel_worker_test.sh +++ b/src/test/shell/integration/bazel_worker_test.sh @@ -35,7 +35,6 @@ example_worker=$(find $BAZEL_RUNFILES -name ExampleWorker_deploy.jar) add_to_bazelrc "build -s" add_to_bazelrc "build --spawn_strategy=worker,standalone" -add_to_bazelrc "build --experimental_worker_allow_json_protocol" add_to_bazelrc "build --worker_verbose --worker_max_instances=1" add_to_bazelrc "build --debug_print_action_contexts" add_to_bazelrc "build --noexperimental_worker_multiplex"