Today submitting an unbatched `ClusterStateUpdateTask` to the `MasterService` is deprecated, and devs are encouraged to write their own batching executor instead. In principle this makes it possible to combine updates without incurring the costs of building a whole new `ClusterState` on each iteration, but in practice most implementations don't work at a lower level and just iteratively update a `ClusterState`. Moreover creating new `ClusterState` instances is nothing like as expensive as once it was.

We should accept this and provide some friendlier utilities for writing batched cluster state updates, ideally leaving the developer to express the desired per-task update as a `ClusterState -> ClusterState` operator.
server/src/main/java/org/elasticsearch/health/metadata/HealthMetadataService.java
@Override
            public ClusterState execute(BatchExecutionContext<UpsertHealthMetadataTask> batchExecutionContext) throws Exception {
                ClusterState updatedState = batchExecutionContext.initialState();
                for (TaskContext<UpsertHealthMetadataTask> taskContext : batchExecutionContext.taskContexts()) {
                    try (var ignored = taskContext.captureResponseHeaders()) {
                        updatedState = taskContext.getTask().execute(updatedState);
                    }
                    taskContext.success(() -> {});
                }
                return updatedState;
            }
        }
    }
    /**
     * A health metadata cluster state update task that updates a single setting with the new value.
     */
    static class UpdateHealthMetadata extends UpsertHealthMetadataTask {
        private final String setting;
        private final String value;
        UpdateHealthMetadata(String setting, String value) {
            this.setting = setting;
            this.value = value;
        }
        @Override
        ClusterState execute(ClusterState clusterState) {
            HealthMetadata initialHealthMetadata = HealthMetadata.getFromClusterState(clusterState);
            assert initialHealthMetadata != null : "health metadata should have been initialized";