Skip to content

Commit

Permalink
Add support for global configuration options
Browse files Browse the repository at this point in the history
The bb-storage repository now contains definitions for global
configuration options that we may want to enable, such as Jaeger support
and Prometheus push metrics. Let's tie these options into the
bb-remote-execution binaries as well.

This should make it easier to complete Jaeger support (#32).
  • Loading branch information
EdSchouten committed Apr 2, 2020
1 parent 9b7d663 commit e44cc90
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:resolve proto go pkg/proto/configuration/blobstore/blobstore.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore:go_default_library
# gazelle:resolve proto pkg/proto/configuration/eviction/eviction.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/eviction:eviction_proto
# gazelle:resolve proto go pkg/proto/configuration/eviction/eviction.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/eviction:go_default_library
# gazelle:resolve proto pkg/proto/configuration/global/global.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/global:global_proto
# gazelle:resolve proto go pkg/proto/configuration/global/global.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/global:go_default_library
# gazelle:resolve proto pkg/proto/configuration/grpc/grpc.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto
# gazelle:resolve proto go pkg/proto/configuration/grpc/grpc.proto @com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:go_default_library
gazelle(
Expand Down
1 change: 1 addition & 0 deletions cmd/bb_runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
"//pkg/proto/configuration/bb_runner:go_default_library",
"//pkg/proto/runner:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/filesystem:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/global:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/grpc:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/util:go_default_library",
"@org_golang_google_grpc//:go_default_library",
Expand Down
4 changes: 4 additions & 0 deletions cmd/bb_runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_runner"
"github.com/buildbarn/bb-remote-execution/pkg/proto/runner"
"github.com/buildbarn/bb-storage/pkg/filesystem"
"github.com/buildbarn/bb-storage/pkg/global"
bb_grpc "github.com/buildbarn/bb-storage/pkg/grpc"
"github.com/buildbarn/bb-storage/pkg/util"

Expand All @@ -22,6 +23,9 @@ func main() {
if err := util.UnmarshalConfigurationFromFile(os.Args[1], &configuration); err != nil {
log.Fatalf("Failed to read configuration from %s: %s", os.Args[1], err)
}
if err := global.ApplyConfiguration(configuration.Global); err != nil {
log.Fatal("Failed to apply global configuration options: ", err)
}

buildDirectory, err := filesystem.NewLocalDirectory(configuration.BuildDirectoryPath)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/bb_scheduler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_library(
"@com_github_buildbarn_bb_storage//pkg/cas:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/clock:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/digest:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/global:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/grpc:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/util:go_default_library",
"@com_github_golang_protobuf//jsonpb:go_default_library_gen",
Expand Down
4 changes: 4 additions & 0 deletions cmd/bb_scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
blobstore_configuration "github.com/buildbarn/bb-storage/pkg/blobstore/configuration"
"github.com/buildbarn/bb-storage/pkg/cas"
"github.com/buildbarn/bb-storage/pkg/clock"
"github.com/buildbarn/bb-storage/pkg/global"
bb_grpc "github.com/buildbarn/bb-storage/pkg/grpc"
"github.com/buildbarn/bb-storage/pkg/util"
"github.com/google/uuid"
Expand All @@ -32,6 +33,9 @@ func main() {
if err := util.UnmarshalConfigurationFromFile(os.Args[1], &configuration); err != nil {
log.Fatalf("Failed to read configuration from %s: %s", os.Args[1], err)
}
if err := global.ApplyConfiguration(configuration.Global); err != nil {
log.Fatal("Failed to apply global configuration options: ", err)
}

browserURL, err := url.Parse(configuration.BrowserUrl)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/bb_worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ go_library(
"@com_github_buildbarn_bb_storage//pkg/digest:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/eviction:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/filesystem:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/global:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/grpc:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/util:go_default_library",
"@com_github_golang_protobuf//ptypes:go_default_library_gen",
Expand Down
4 changes: 4 additions & 0 deletions cmd/bb_worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/buildbarn/bb-storage/pkg/digest"
"github.com/buildbarn/bb-storage/pkg/eviction"
"github.com/buildbarn/bb-storage/pkg/filesystem"
"github.com/buildbarn/bb-storage/pkg/global"
bb_grpc "github.com/buildbarn/bb-storage/pkg/grpc"
"github.com/buildbarn/bb-storage/pkg/util"
"github.com/golang/protobuf/ptypes"
Expand All @@ -42,6 +43,9 @@ func main() {
if err := util.UnmarshalConfigurationFromFile(os.Args[1], &configuration); err != nil {
log.Fatalf("Failed to read configuration from %s: %s", os.Args[1], err)
}
if err := global.ApplyConfiguration(configuration.Global); err != nil {
log.Fatal("Failed to apply global configuration options: ", err)
}

browserURL, err := url.Parse(configuration.BrowserUrl)
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions pkg/proto/configuration/bb_runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ proto_library(
name = "bb_runner_proto",
srcs = ["bb_runner.proto"],
visibility = ["//visibility:public"],
deps = ["@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto"],
deps = [
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/global:global_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto",
],
)

go_proto_library(
name = "bb_runner_go_proto",
importpath = "github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_runner",
proto = ":bb_runner_proto",
visibility = ["//visibility:public"],
deps = ["@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:go_default_library"],
deps = [
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/global:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:go_default_library",
],
)

go_library(
Expand Down
4 changes: 4 additions & 0 deletions pkg/proto/configuration/bb_runner/bb_runner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";

package buildbarn.configuration.bb_runner;

import "pkg/proto/configuration/global/global.proto";
import "pkg/proto/configuration/grpc/grpc.proto";

option go_package = "github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_runner";
Expand All @@ -16,4 +17,7 @@ message ApplicationConfiguration {
// Temporary directories that should be cleaned up after a build action
// (e.g. /tmp).
repeated string temporary_directories = 3;

// Common configuration options that apply to all Buildbarn binaries.
buildbarn.configuration.global.Configuration global = 4;
}
2 changes: 2 additions & 0 deletions pkg/proto/configuration/bb_scheduler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ proto_library(
visibility = ["//visibility:public"],
deps = [
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore:blobstore_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/global:global_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto",
],
)
Expand All @@ -19,6 +20,7 @@ go_proto_library(
visibility = ["//visibility:public"],
deps = [
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/global:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:go_default_library",
],
)
Expand Down
4 changes: 4 additions & 0 deletions pkg/proto/configuration/bb_scheduler/bb_scheduler.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package buildbarn.configuration.bb_scheduler;

import "pkg/proto/configuration/blobstore/blobstore.proto";
import "pkg/proto/configuration/global/global.proto";
import "pkg/proto/configuration/grpc/grpc.proto";

option go_package = "github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_scheduler";
Expand Down Expand Up @@ -30,4 +31,7 @@ message ApplicationConfiguration {

// Maximum Protobuf message size to unmarshal.
int64 maximum_message_size_bytes = 7;

// Common configuration options that apply to all Buildbarn binaries.
buildbarn.configuration.global.Configuration global = 8;
}
2 changes: 2 additions & 0 deletions pkg/proto/configuration/bb_worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ proto_library(
"@com_github_bazelbuild_remote_apis//build/bazel/remote/execution/v2:remote_execution_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore:blobstore_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/eviction:eviction_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/global:global_proto",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:grpc_proto",
"@com_google_protobuf//:duration_proto",
],
Expand All @@ -24,6 +25,7 @@ go_proto_library(
"@com_github_bazelbuild_remote_apis//build/bazel/remote/execution/v2:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/blobstore:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/eviction:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/global:go_default_library",
"@com_github_buildbarn_bb_storage//pkg/proto/configuration/grpc:go_default_library",
],
)
Expand Down
4 changes: 4 additions & 0 deletions pkg/proto/configuration/bb_worker/bb_worker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "build/bazel/remote/execution/v2/remote_execution.proto";
import "google/protobuf/duration.proto";
import "pkg/proto/configuration/blobstore/blobstore.proto";
import "pkg/proto/configuration/eviction/eviction.proto";
import "pkg/proto/configuration/global/global.proto";
import "pkg/proto/configuration/grpc/grpc.proto";

option go_package = "github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_worker";
Expand Down Expand Up @@ -46,6 +47,9 @@ message ApplicationConfiguration {
// Directory where temporary files generated by build actions may be
// stored. If left empty, temporary files are stored in memory.
string file_pool_directory_path = 18;

// Common configuration options that apply to all Buildbarn binaries.
buildbarn.configuration.global.Configuration global = 19;
}

message LocalBuildDirectoryConfiguration {
Expand Down

0 comments on commit e44cc90

Please sign in to comment.