aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar dmarting <dmarting@google.com>2017-04-20 15:18:50 +0200
committerGravatar Klaus Aehlig <aehlig@google.com>2017-04-20 16:41:45 +0200
commitc040eb1e0346a21ebe3a3df0d0c122f61b569c42 (patch)
treea500fb9a65d1a23463c1d6f7d0a709f23aa5b00f
parent8989e19ab957a18f4937531dd55b5c30b207e6df (diff)
Remove the dash module
This module rely on an un-maintained codepath and is hardly used by anyone. We should also archive the code from dash until we can revive it with BEP RELNOTES[INC]: --use_dash, --dash_url and --dash_secret are removed. PiperOrigin-RevId: 153701824
-rw-r--r--site/blog/_posts/2015-07-29-dashboard-dogfood.md2
-rw-r--r--src/main/java/com/google/devtools/build/lib/BUILD2
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/BazelMain.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/dash/BUILD24
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java373
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/dash/DashOptions.java47
-rw-r--r--src/main/protobuf/BUILD1
-rw-r--r--src/main/protobuf/dash.proto63
8 files changed, 2 insertions, 511 deletions
diff --git a/site/blog/_posts/2015-07-29-dashboard-dogfood.md b/site/blog/_posts/2015-07-29-dashboard-dogfood.md
index 531817d31c..550266b750 100644
--- a/site/blog/_posts/2015-07-29-dashboard-dogfood.md
+++ b/site/blog/_posts/2015-07-29-dashboard-dogfood.md
@@ -3,6 +3,8 @@ layout: posts
title: Build dashboard dogfood
---
+__WARNING__: This feature has been removed (2017-04-19).
+
We've added a basic dashboard where you can see and share build and test
results. It's not ready for an official release yet, but if any adventurous
people would like to try it out (and please report any issues you find!), feel
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index 4c4a80e983..ac245168f7 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -17,7 +17,6 @@ filegroup(
srcs = glob(["**"]) + [
"//src/main/java/com/google/devtools/build/docgen:srcs",
"//src/main/java/com/google/devtools/build/lib/actions:srcs",
- "//src/main/java/com/google/devtools/build/lib/bazel/dash:srcs",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/cache:srcs",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/downloader:srcs",
"//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:srcs",
@@ -677,7 +676,6 @@ java_library(
":util",
":vfs",
"//src/main/java/com/google/devtools/build/lib/actions",
- "//src/main/java/com/google/devtools/build/lib/bazel/dash",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/cache",
"//src/main/java/com/google/devtools/build/lib/bazel/repository/downloader",
"//src/main/java/com/google/devtools/build/lib/remote",
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelMain.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelMain.java
index 336715a479..671c38dc71 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/BazelMain.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelMain.java
@@ -41,7 +41,6 @@ public final class BazelMain {
com.google.devtools.build.lib.bazel.BazelWorkspaceStatusModule.class,
com.google.devtools.build.lib.bazel.BazelDiffAwarenessModule.class,
com.google.devtools.build.lib.bazel.BazelRepositoryModule.class,
- com.google.devtools.build.lib.bazel.dash.DashModule.class,
com.google.devtools.build.lib.ssd.SsdModule.class,
com.google.devtools.build.lib.worker.WorkerModule.class,
com.google.devtools.build.lib.remote.RemoteModule.class,
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/dash/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/dash/BUILD
deleted file mode 100644
index 635b29a034..0000000000
--- a/src/main/java/com/google/devtools/build/lib/bazel/dash/BUILD
+++ /dev/null
@@ -1,24 +0,0 @@
-package(default_visibility = ["//src:__subpackages__"])
-
-java_library(
- name = "dash",
- srcs = glob(["*.java"]),
- deps = [
- "//src/main/java/com/google/devtools/build/lib:build-base",
- "//src/main/java/com/google/devtools/build/lib:events",
- "//src/main/java/com/google/devtools/build/lib:packages-internal",
- "//src/main/java/com/google/devtools/build/lib:runtime",
- "//src/main/java/com/google/devtools/common/options",
- "//src/main/protobuf:dash_java_proto",
- "//third_party:apache_httpclient",
- "//third_party:apache_httpcore",
- "//third_party:guava",
- "//third_party/protobuf:protobuf_java",
- ],
-)
-
-filegroup(
- name = "srcs",
- testonly = 0, # All srcs should be not test only, overwrite package default.
- srcs = glob(["**"]),
-)
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java b/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java
deleted file mode 100644
index 01e8830086..0000000000
--- a/src/main/java/com/google/devtools/build/lib/bazel/dash/DashModule.java
+++ /dev/null
@@ -1,373 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.bazel.dash;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.eventbus.Subscribe;
-import com.google.common.io.ByteStreams;
-import com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData;
-import com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData.CommandLine.Option;
-import com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData.EnvironmentVar;
-import com.google.devtools.build.lib.bazel.dash.DashProtos.BuildData.Target.TestData;
-import com.google.devtools.build.lib.bazel.dash.DashProtos.Log;
-import com.google.devtools.build.lib.events.Event;
-import com.google.devtools.build.lib.events.Reporter;
-import com.google.devtools.build.lib.packages.Target;
-import com.google.devtools.build.lib.pkgcache.TargetParsingCompleteEvent;
-import com.google.devtools.build.lib.rules.test.TestResult;
-import com.google.devtools.build.lib.runtime.BlazeModule;
-import com.google.devtools.build.lib.runtime.Command;
-import com.google.devtools.build.lib.runtime.CommandEnvironment;
-import com.google.devtools.build.lib.runtime.CommandStartEvent;
-import com.google.devtools.build.lib.runtime.GotOptionsEvent;
-import com.google.devtools.common.options.OptionsBase;
-import com.google.devtools.common.options.OptionsParser.UnparsedOptionValueDescription;
-import com.google.devtools.common.options.OptionsProvider;
-import com.google.protobuf.ByteString;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.attribute.PosixFilePermission;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpStatus;
-import org.apache.http.StatusLine;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * Dashboard for a build.
- */
-public class DashModule extends BlazeModule {
- private static final int ONE_MB = 1024 * 1024;
- private static final NoOpSender NO_OP_SENDER = new NoOpSender();
-
- private static final String DASH_SECRET_HEADER = "bazel-dash-secret";
-
- private final ExecutorService executorService;
-
- private Sendable sender;
- private CommandEnvironment env;
- private BuildData optionsBuildData;
-
- public DashModule() {
- // Make sure sender != null before we hop on the event bus.
- sender = NO_OP_SENDER;
- executorService = Executors.newFixedThreadPool(5,
- new ThreadFactory() {
- @Override
- public Thread newThread(Runnable runnable) {
- Thread thread = Executors.defaultThreadFactory().newThread(runnable);
- thread.setDaemon(true);
- return thread;
- }
- });
- }
-
- @Override
- public void beforeCommand(Command command, CommandEnvironment env) {
- this.env = env;
- env.getEventBus().register(this);
- }
-
- @Override
- public void afterCommand() {
- this.sender = NO_OP_SENDER;
- this.env = null;
- this.optionsBuildData = null;
- }
-
- @Override
- public Iterable<Class<? extends OptionsBase>> getCommandOptions(Command command) {
- return "build".equals(command.name())
- ? ImmutableList.<Class<? extends OptionsBase>>of(DashOptions.class)
- : ImmutableList.<Class<? extends OptionsBase>>of();
- }
-
- @Override
- public void handleOptions(OptionsProvider optionsProvider) {
- DashOptions options = optionsProvider.getOptions(DashOptions.class);
- try {
- sender = (options == null || !options.useDash)
- ? NO_OP_SENDER
- : new Sender(options.url, options.secret, env, executorService);
- } catch (SenderException e) {
- env.getReporter().handle(e.toEvent());
- sender = NO_OP_SENDER;
- }
- if (optionsBuildData != null) {
- sender.send("options", optionsBuildData);
- }
- optionsBuildData = null;
- }
-
- @Subscribe
- public void gotOptions(GotOptionsEvent event) {
- BuildData.Builder builder = BuildData.newBuilder();
- BuildData.CommandLine.Builder cmdLineBuilder = BuildData.CommandLine.newBuilder();
- for (UnparsedOptionValueDescription option :
- event.getStartupOptions().asListOfUnparsedOptions()) {
- cmdLineBuilder.addStartupOptions(getOption(option));
- }
-
- for (UnparsedOptionValueDescription option : event.getOptions().asListOfUnparsedOptions()) {
- if (option.getName().equals("client_env")) {
- String env[] = option.getUnparsedValue().split("=");
- if (env.length == 1) {
- builder.addClientEnv(
- EnvironmentVar.newBuilder().setName(env[0]).setValue("true").build());
- } else if (env.length == 2) {
- builder.addClientEnv(
- EnvironmentVar.newBuilder().setName(env[0]).setValue(env[1]).build());
- }
- } else {
- cmdLineBuilder.addOptions(getOption(option));
- }
- }
-
- for (String residue : event.getOptions().getResidue()) {
- cmdLineBuilder.addResidue(residue);
- }
- builder.setCommandLine(cmdLineBuilder.build());
-
- // This can be called before handleOptions, so the BuildData is stored until we know if it
- // should be sent somewhere.
- optionsBuildData = builder.build();
- }
-
- @Subscribe
- public void commandStartEvent(CommandStartEvent event) {
- BuildData.Builder builder = BuildData.newBuilder()
- .setBuildId(event.getCommandId().toString())
- .setCommandName(event.getCommandName())
- .setWorkingDir(event.getWorkingDirectory().getPathString());
- sender.send("start", builder.build());
- }
-
- @Subscribe
- public void parsingComplete(TargetParsingCompleteEvent event) {
- BuildData.Builder builder = BuildData.newBuilder();
- for (Target target : event.getTargets()) {
- builder.addTargetsBuilder()
- .setLabel(target.getLabel().toString())
- .setRuleKind(target.getTargetKind()).build();
- }
- sender.send("targets", builder.build());
- }
-
- @Subscribe
- public void testFinished(TestResult result) {
- BuildData.Builder builder = BuildData.newBuilder();
- BuildData.Target.Builder targetBuilder = BuildData.Target.newBuilder();
- targetBuilder.setLabel(result.getLabel());
- TestData.Builder testDataBuilder = TestData.newBuilder();
- testDataBuilder.setPassed(result.getData().getTestPassed());
- if (!result.getData().getTestPassed()) {
- testDataBuilder.setLog(getLog(result.getTestLogPath().toString()));
- }
- targetBuilder.setTestData(testDataBuilder);
- builder.addTargets(targetBuilder);
- sender.send("test", builder.build());
- }
-
- private Log getLog(String logPath) {
- Log.Builder builder = Log.newBuilder().setPath(logPath);
- File log = new File(logPath);
- try {
- long fileSize = Files.size(log.toPath());
- if (fileSize > ONE_MB) {
- fileSize = ONE_MB;
- builder.setTruncated(true);
- }
- byte buffer[] = new byte[(int) fileSize];
- try (FileInputStream in = new FileInputStream(log)) {
- ByteStreams.readFully(in, buffer);
- }
- builder.setContents(ByteString.copyFrom(buffer));
- } catch (IOException e) {
- env
- .getReporter()
- .getOutErr()
- .printOutLn("Error reading log file " + logPath + ": " + e.getMessage());
- // TODO(kchodorow): add this info to the proto and send.
- }
- return builder.build();
- }
-
- @Override
- public void blazeShutdown() {
- executorService.shutdownNow();
- }
-
- private BuildData.CommandLine.Option getOption(UnparsedOptionValueDescription option) {
- Option.Builder optionBuilder = Option.newBuilder();
- optionBuilder.setName(option.getName());
- if (option.getSource() != null) {
- optionBuilder.setSource(option.getSource());
- }
- Object value = option.getUnparsedValue();
- if (value != null) {
- if (value instanceof Iterable<?>) {
- for (Object v : ((Iterable<?>) value)) {
- if (v != null) {
- optionBuilder.addValue(v.toString());
- }
- }
- } else {
- optionBuilder.addValue(value.toString());
- }
- }
- return optionBuilder.build();
- }
-
- private interface Sendable {
- void send(final String suffix, final BuildData message);
- }
-
- private static class SenderException extends Exception {
- SenderException(String message, Throwable ex) {
- super(message, ex);
- }
-
- SenderException(String message) {
- super(message);
- }
-
- Event toEvent() {
- if (getCause() != null) {
- return Event.error(getMessage() + ": " + getCause().getMessage());
- } else {
- return Event.error(getMessage());
- }
- }
- }
-
- private static class Sender implements Sendable {
- private final URL url;
- private final String buildId;
- private final String secret;
- private final Reporter reporter;
- private final ExecutorService executorService;
-
- public Sender(String url, String secret,
- CommandEnvironment env, ExecutorService executorService) throws SenderException {
- this.reporter = env.getReporter();
- this.secret = readSecret(secret, reporter);
- try {
- this.url = new URL(url);
- if (!this.secret.isEmpty()) {
- if (!(this.url.getProtocol().equals("https") || this.url.getHost().equals("localhost")
- || this.url.getHost().matches("^127.0.0.[0-9]+$"))) {
- reporter.handle(Event.warn("Using authentication over unsecure channel, "
- + "consider using HTTPS."));
- }
- }
- } catch (MalformedURLException e) {
- throw new SenderException("Invalid server url " + url, e);
- }
- this.buildId = env.getCommandId().toString();
- this.executorService = executorService;
- sendMessage("test", null); // test connecting to the server.
- reporter.handle(Event.info("Results are being streamed to " + url + "/result/" + buildId));
- }
-
- private static String readSecret(String secretFile, Reporter reporter) throws SenderException {
- if (secretFile.isEmpty()) {
- return "";
- }
- Path secretPath = new File(secretFile).toPath();
- if (!Files.isReadable(secretPath)) {
- throw new SenderException("Secret file " + secretFile + " doesn't exists or is unreadable");
- }
- try {
- if (Files.getPosixFilePermissions(secretPath).contains(PosixFilePermission.OTHERS_READ)
- || Files.getPosixFilePermissions(secretPath).contains(PosixFilePermission.GROUP_READ)) {
- reporter.handle(Event.warn("Secret file " + secretFile + " is readable by non-owner. "
- + "It is recommended to set its permission to 0600 (read-write only by the owner)."));
- }
- return new String(Files.readAllBytes(secretPath), StandardCharsets.UTF_8).trim();
- } catch (IOException e) {
- throw new SenderException("Invalid secret file " + secretFile, e);
- }
- }
-
- private void sendMessage(final String suffix, final HttpEntity message)
- throws SenderException {
- HttpParams httpParams = new BasicHttpParams();
- HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
- HttpConnectionParams.setSoTimeout(httpParams, 5000);
- HttpClient httpClient = new DefaultHttpClient(httpParams);
-
- HttpPost httppost = new HttpPost(url + "/" + suffix + "/" + buildId);
- if (message != null) {
- httppost.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-protobuf");
- httppost.setEntity(message);
- }
- if (!secret.isEmpty()) {
- httppost.setHeader(DASH_SECRET_HEADER, secret);
- }
- StatusLine status;
- try {
- status = httpClient.execute(httppost).getStatusLine();
- } catch (IOException e) {
- throw new SenderException("Error sending results to " + url, e);
- }
- if (status.getStatusCode() == HttpStatus.SC_FORBIDDEN) {
- throw new SenderException("Permission denied while sending results to " + url
- + ". Did you specified --dash_secret?");
- }
- }
-
- @Override
- public void send(final String suffix, final BuildData message) {
- @SuppressWarnings("unused")
- Future<?> possiblyIgnoredError =
- executorService.submit(
- new Runnable() {
- @Override
- public void run() {
- try {
- sendMessage(suffix, new ByteArrayEntity(message.toByteArray()));
- } catch (SenderException ex) {
- reporter.handle(ex.toEvent());
- }
- }
- });
- }
- }
-
- private static class NoOpSender implements Sendable {
- public NoOpSender() {
- }
-
- @Override
- public void send(String suffix, BuildData message) {
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/dash/DashOptions.java b/src/main/java/com/google/devtools/build/lib/bazel/dash/DashOptions.java
deleted file mode 100644
index e1a3741653..0000000000
--- a/src/main/java/com/google/devtools/build/lib/bazel/dash/DashOptions.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.bazel.dash;
-
-import com.google.devtools.common.options.Option;
-import com.google.devtools.common.options.OptionsBase;
-
-/**
- * Options for sending build results to a dashboard.
- */
-public class DashOptions extends OptionsBase {
-
- @Option(
- name = "use_dash",
- defaultValue = "false",
- help = "If build/test results should be sent to a remote dashboard."
- )
- public boolean useDash;
-
- @Option(
- name = "dash_url",
- defaultValue = "",
- help = "The URL of the dashboard server."
- )
- public String url;
-
- @Option(
- name = "dash_secret",
- defaultValue = "",
- help = "The path to a file containing a secret shared with the dashboard server "
- + "for writing build results."
- )
- public String secret;
-
-}
diff --git a/src/main/protobuf/BUILD b/src/main/protobuf/BUILD
index 9b00966710..50af577aad 100644
--- a/src/main/protobuf/BUILD
+++ b/src/main/protobuf/BUILD
@@ -5,7 +5,6 @@ load("//third_party/protobuf/3.0.0:protobuf.bzl", "cc_proto_library", "py_proto_
FILES = [
"build",
- "dash",
"deps",
"java_compilation",
"crosstool_config",
diff --git a/src/main/protobuf/dash.proto b/src/main/protobuf/dash.proto
deleted file mode 100644
index a6a804489b..0000000000
--- a/src/main/protobuf/dash.proto
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-syntax = "proto2";
-
-package dash;
-
-option java_package = "com.google.devtools.build.lib.bazel.dash";
-option java_outer_classname = "DashProtos";
-
-message Log {
- // Local path to the log.
- optional string path = 1;
- optional bytes contents = 2;
- // Log is truncated after 1MB.
- optional bool truncated = 3;
-}
-
-message BuildData {
- optional string build_id = 1;
- optional string command_name = 2;
- optional string working_dir = 3;
-
- message CommandLine {
- message Option {
- optional string name = 1;
- repeated string value = 2;
- optional string source = 3;
- }
- repeated Option startup_options = 1;
- repeated Option options = 2;
- repeated string residue = 3;
- }
- optional CommandLine command_line = 4;
-
- message EnvironmentVar {
- optional string name = 1;
- optional string value = 2;
- }
- repeated EnvironmentVar client_env = 5;
-
- message Target {
- optional string label = 1;
- optional string rule_kind = 2;
- message TestData {
- optional bool passed = 1;
- optional Log log = 2;
- }
- optional TestData test_data = 3;
- }
- repeated Target targets = 6;
-}