Skip to content

Commit 1141041

Browse files
committed
Fix up bazel-buildfarm to pass all tests
1 parent d6c1859 commit 1141041

File tree

6 files changed

+16
-67
lines changed

6 files changed

+16
-67
lines changed

deps.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ buildfarm dependencies that can be imported into other WORKSPACE files
55
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar")
66
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
77

8+
RULES_JVM_EXTERNAL_TAG = "4.2"
9+
RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"
10+
811
def archive_dependencies(third_party):
912
return [
13+
{
14+
"name": "rules_jvm_external",
15+
"strip_prefix": "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
16+
"sha256": RULES_JVM_EXTERNAL_SHA,
17+
"url": "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
18+
},
1019
{
1120
"name": "rules_pkg",
1221
"sha256": "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2",

src/main/java/build/buildfarm/worker/shard/CFCExecFileSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import build.buildfarm.cas.ContentAddressableStorage;
4141
import build.buildfarm.cas.cfc.CASFileCache;
4242
import build.buildfarm.common.BuildfarmExecutors;
43+
import build.buildfarm.common.DigestUtil;
4344
import build.buildfarm.common.io.Directories;
4445
import build.buildfarm.common.io.Dirent;
4546
import build.buildfarm.worker.ExecDirException;

src/main/java/build/buildfarm/worker/shard/RemoteCasWriter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ private void insertFileToCasMember(Digest digest, DigestFunction.Value digestFun
8181
}
8282
}
8383

84-
private long writeToCasMember(Digest digest, InputStream in)
85-
throws IOException, InterruptedException {
8684
private long writeToCasMember(Digest digest, DigestFunction.Value digestFunction, InputStream in)
8785
throws IOException, InterruptedException {
8886
// create a write for inserting into another CAS member.

src/main/java/build/buildfarm/worker/shard/Worker.java

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static com.google.common.base.Preconditions.checkArgument;
2222
import static com.google.common.base.Preconditions.checkState;
2323
import static java.util.concurrent.Executors.newSingleThreadExecutor;
24-
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
2524
import static java.util.concurrent.TimeUnit.SECONDS;
2625
import static java.util.logging.Level.INFO;
2726
import static java.util.logging.Level.SEVERE;
@@ -63,8 +62,6 @@
6362
import build.buildfarm.worker.resources.LocalResourceSetUtils;
6463
import com.google.common.cache.LoadingCache;
6564
import com.google.common.collect.Lists;
66-
import com.google.common.util.concurrent.SettableFuture;
67-
import com.google.devtools.common.options.OptionsParsingException;
6865
import com.google.longrunning.Operation;
6966
import com.google.protobuf.ByteString;
7067
import com.google.protobuf.Duration;
@@ -90,18 +87,11 @@
9087
import java.util.UUID;
9188
import java.util.concurrent.Executor;
9289
import java.util.concurrent.ExecutorService;
93-
import java.util.concurrent.ScheduledExecutorService;
94-
import java.util.concurrent.ScheduledFuture;
9590
import java.util.concurrent.atomic.AtomicBoolean;
9691
import java.util.logging.Level;
9792
import javax.annotation.Nullable;
9893
import javax.naming.ConfigurationException;
9994
import lombok.extern.java.Log;
100-
import org.springframework.beans.factory.annotation.Autowired;
101-
import org.springframework.boot.SpringApplication;
102-
import org.springframework.boot.autoconfigure.SpringBootApplication;
103-
import org.springframework.context.ApplicationContext;
104-
import org.springframework.context.annotation.ComponentScan;
10595

10696
@Log
10797
public final class Worker extends LoggingMain {
@@ -146,7 +136,6 @@ public final class Worker extends LoggingMain {
146136
private LoadingCache<String, Instance> workerStubs;
147137
private AtomicBoolean released = new AtomicBoolean(true);
148138

149-
@Autowired private ApplicationContext springContext;
150139
/**
151140
* The method will prepare the worker for graceful shutdown when the worker is ready. Note on
152141
* using stderr here instead of log. By the time this is called in PreDestroy, the log is no
@@ -196,43 +185,6 @@ private Worker() {
196185
super("BuildFarmShardWorker");
197186
}
198187

199-
private void exitPostPipelineFailure() {
200-
// Shutdown the worker if a pipeline fails. By means of the spring lifecycle
201-
// hooks - e.g. the `PreDestroy` hook here - it will attempt to gracefully
202-
// spin down the pipeline
203-
204-
// By calling these spring shutdown facilities; we're open to the risk that
205-
// a subsystem may be hanging a criticial thread indeffinitly. Deadline the
206-
// shutdown workflow to ensure we don't leave a zombie worker in this
207-
// situation
208-
ScheduledExecutorService shutdownDeadlineExecutor = newSingleThreadScheduledExecutor();
209-
210-
// This may be shorter than the action timeout; assume we have interrupted
211-
// actions in a fatal uncaught exception.
212-
int forceShutdownDeadline = 60;
213-
ScheduledFuture<?> termFuture =
214-
shutdownDeadlineExecutor.schedule(
215-
new Runnable() {
216-
public void run() {
217-
log.log(
218-
Level.SEVERE,
219-
String.format(
220-
"Force terminating due to shutdown deadline exceeded (%d seconds)",
221-
forceShutdownDeadline));
222-
System.exit(1);
223-
}
224-
},
225-
forceShutdownDeadline,
226-
SECONDS);
227-
228-
// Consider defining exit codes to better afford out of band instance
229-
// recovery
230-
int code = SpringApplication.exit(springContext, () -> 1);
231-
termFuture.cancel(false);
232-
shutdownDeadlineExecutor.shutdown();
233-
System.exit(code);
234-
}
235-
236188
private Operation stripOperation(Operation operation) {
237189
return instance.stripOperation(operation);
238190
}
@@ -674,22 +626,9 @@ public void start() throws ConfigurationException, InterruptedException, IOExcep
674626
healthStatusManager.setStatus(
675627
HealthStatusManager.SERVICE_NAME_ALL_SERVICES, ServingStatus.SERVING);
676628
PrometheusPublisher.startHttpServer(configs.getPrometheusPort());
629+
startFailsafeRegistration();
677630

678-
// An executor can also be used as storage worker as scheduler treats all new workers as storage workers
679-
// TODO (Congt) Fix it upstream and revert it.
680-
if (configs.getWorker().getCapabilities().isCas()) {
681-
startFailsafeRegistration();
682-
} else {
683-
log.log(INFO, "Skipping worker registration");
684-
}
685-
686-
// Listen for pipeline unhandled exceptions
687-
ExecutorService pipelineExceptionExecutor = newSingleThreadExecutor();
688-
SettableFuture<Void> pipelineExceptionFuture = SettableFuture.create();
689-
pipelineExceptionFuture.addListener(this::exitPostPipelineFailure, pipelineExceptionExecutor);
690-
691-
pipeline.start(pipelineExceptionFuture);
692-
631+
pipeline.start(null);
693632
healthCheckMetric.labels("start").inc();
694633
executionSlotsTotal.set(configs.getWorker().getExecuteStageWidth());
695634
inputFetchSlotsTotal.set(configs.getWorker().getInputFetchStageWidth());

src/test/java/build/buildfarm/common/services/WriteStreamObserverTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public void noErrorWhenContextCancelled() throws Exception {
115115
when(instance.getBlobWrite(
116116
eq(Compressor.Value.IDENTITY),
117117
eq(cancelledDigest),
118+
eq(DigestFunction.Value.UNKNOWN),
118119
eq(uuid),
119120
any(RequestMetadata.class)))
120121
.thenReturn(write);
@@ -137,6 +138,7 @@ public void noErrorWhenContextCancelled() throws Exception {
137138
.getBlobWrite(
138139
eq(Compressor.Value.IDENTITY),
139140
eq(cancelledDigest),
141+
eq(DigestFunction.Value.UNKNOWN),
140142
eq(uuid),
141143
any(RequestMetadata.class));
142144
verifyNoInteractions(responseObserver);

src/test/java/build/buildfarm/worker/PipelineTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void stageExitsOnInterrupt() throws InterruptedException {
110110
Pipeline pipeline = new Pipeline();
111111
TestStage stage = new TestStage("test");
112112
pipeline.add(stage, 1);
113-
pipeline.start();
113+
pipeline.start(null);
114114
pipeline.join();
115115
}
116116

@@ -147,7 +147,7 @@ public void stageContinuesOnException() throws InterruptedException {
147147
Pipeline pipeline = new Pipeline();
148148
ContinueStage stage = new ContinueStage("test");
149149
pipeline.add(stage, 1);
150-
pipeline.start();
150+
pipeline.start(null);
151151

152152
boolean didNotThrow = false;
153153
try {

0 commit comments

Comments
 (0)