Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/bb_noop_worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ go_library(
"//pkg/filesystem/pool",
"//pkg/proto/configuration/bb_noop_worker",
"//pkg/proto/remoteworker",
"@bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto",
"@com_github_buildbarn_bb_storage//pkg/blobstore",
"@com_github_buildbarn_bb_storage//pkg/blobstore/configuration",
"@com_github_buildbarn_bb_storage//pkg/clock",
"@com_github_buildbarn_bb_storage//pkg/digest",
Expand Down
8 changes: 6 additions & 2 deletions cmd/bb_noop_worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"net/url"
"os"

remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
re_blobstore "github.com/buildbarn/bb-remote-execution/pkg/blobstore"
"github.com/buildbarn/bb-remote-execution/pkg/builder"
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/pool"
"github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_noop_worker"
"github.com/buildbarn/bb-remote-execution/pkg/proto/remoteworker"
"github.com/buildbarn/bb-storage/pkg/blobstore"
blobstore_configuration "github.com/buildbarn/bb-storage/pkg/blobstore/configuration"
"github.com/buildbarn/bb-storage/pkg/clock"
"github.com/buildbarn/bb-storage/pkg/digest"
Expand Down Expand Up @@ -78,8 +80,10 @@ func main() {
buildClient := builder.NewBuildClient(
schedulerClient,
builder.NewNoopBuildExecutor(
contentAddressableStorage,
int(configuration.MaximumMessageSizeBytes),
blobstore.NewBlobAccessMessageReader[*remoteexecution.Command](
contentAddressableStorage,
int(configuration.MaximumMessageSizeBytes),
),
browserURL,
),
pool.EmptyFilePool,
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 @@ -39,6 +39,7 @@ go_library(
"//pkg/util",
"@bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto",
"@com_github_buildbarn_bb_storage//pkg/auth/configuration",
"@com_github_buildbarn_bb_storage//pkg/blobstore",
"@com_github_buildbarn_bb_storage//pkg/blobstore/configuration",
"@com_github_buildbarn_bb_storage//pkg/capabilities",
"@com_github_buildbarn_bb_storage//pkg/clock",
Expand Down
7 changes: 5 additions & 2 deletions cmd/bb_scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/buildbarn/bb-remote-execution/pkg/scheduler/initialsizeclass"
"github.com/buildbarn/bb-remote-execution/pkg/scheduler/routing"
auth_configuration "github.com/buildbarn/bb-storage/pkg/auth/configuration"
"github.com/buildbarn/bb-storage/pkg/blobstore"
blobstore_configuration "github.com/buildbarn/bb-storage/pkg/blobstore/configuration"
"github.com/buildbarn/bb-storage/pkg/capabilities"
"github.com/buildbarn/bb-storage/pkg/clock"
Expand Down Expand Up @@ -132,7 +133,10 @@ func main() {
// TODO: Make timeouts configurable.
generator := random.NewFastSingleThreadedGenerator()
buildQueue := scheduler.NewInMemoryBuildQueue(
contentAddressableStorage,
blobstore.NewBlobAccessMessageReader[*remoteexecution.Action](
contentAddressableStorage,
int(configuration.MaximumMessageSizeBytes),
),
clock.SystemClock,
uuid.NewRandom,
&scheduler.InMemoryBuildQueueConfiguration{
Expand All @@ -149,7 +153,6 @@ func main() {
WorkerTaskRetryCount: 9,
WorkerWithNoSynchronizationsTimeout: time.Minute,
},
int(configuration.MaximumMessageSizeBytes),
actionRouter,
executeAuthorizer,
modifyDrainsAuthorizer,
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(
"//pkg/proto/configuration/bb_worker",
"//pkg/proto/remoteworker",
"//pkg/proto/runner",
"@bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto",
"@com_github_buildbarn_bb_storage//pkg/blobstore",
"@com_github_buildbarn_bb_storage//pkg/blobstore/configuration",
"@com_github_buildbarn_bb_storage//pkg/clock",
Expand Down
3 changes: 2 additions & 1 deletion cmd/bb_worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"sync/atomic"
"time"

remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
re_blobstore "github.com/buildbarn/bb-remote-execution/pkg/blobstore"
"github.com/buildbarn/bb-remote-execution/pkg/builder"
"github.com/buildbarn/bb-remote-execution/pkg/cas"
Expand Down Expand Up @@ -462,12 +463,12 @@ func main() {

buildExecutor := builder.NewLocalBuildExecutor(
contentAddressableStorageWriter,
blobstore.NewBlobAccessMessageReader[*remoteexecution.Command](contentAddressableStorageWriter, int(configuration.MaximumMessageSizeBytes)),
buildDirectoryCreator,
runnerClient,
executionTimeoutClock,
maximumWritableFileUploadDelay,
inputRootCharacterDevices,
int(configuration.MaximumMessageSizeBytes),
runnerConfiguration.EnvironmentVariables,
configuration.ForceUploadTreesAndDirectories,
)
Expand Down
13 changes: 13 additions & 0 deletions internal/mock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ gomock(
package = "mock",
)

gomock(
name = "storage",
out = "storage.go",
interfaces = ["MessageReader"],
library = "@com_github_buildbarn_bb_storage//pkg/storage",
mockgen_tool = "@org_uber_go_mock//mockgen",
package = "mock",
source = "@com_github_buildbarn_bb_storage//pkg/storage:message_reader.go",
)

gomock(
name = "storage_builder",
out = "storage_builder.go",
Expand Down Expand Up @@ -457,6 +467,7 @@ go_library(
":routing.go",
":runner.go",
":runner_pb.go",
":storage.go",
":storage_builder.go",
":storage_util.go",
":sync.go",
Expand Down Expand Up @@ -506,6 +517,7 @@ go_library(
"@com_github_buildbarn_bb_storage//pkg/filesystem",
"@com_github_buildbarn_bb_storage//pkg/filesystem/path",
"@com_github_buildbarn_bb_storage//pkg/proto/iscc",
"@com_github_buildbarn_bb_storage//pkg/storage",
"@com_github_buildbarn_bb_storage//pkg/util",
"@com_github_google_uuid//:uuid",
"@com_google_cloud_go_longrunning//autogen/longrunningpb",
Expand All @@ -515,6 +527,7 @@ go_library(
"@io_opentelemetry_go_otel_trace//embedded",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//metadata",
"@org_golang_google_protobuf//proto",
"@org_golang_google_protobuf//types/known/anypb:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_uber_go_mock//gomock",
Expand Down
1 change: 1 addition & 0 deletions pkg/builder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ go_library(
"@com_github_buildbarn_bb_storage//pkg/program",
"@com_github_buildbarn_bb_storage//pkg/proto/fsac",
"@com_github_buildbarn_bb_storage//pkg/random",
"@com_github_buildbarn_bb_storage//pkg/storage",
"@com_github_buildbarn_bb_storage//pkg/util",
"@com_github_google_uuid//:uuid",
"@com_github_kballard_go_shellquote//:go-shellquote",
Expand Down
10 changes: 5 additions & 5 deletions pkg/builder/local_build_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/buildbarn/bb-storage/pkg/digest"
"github.com/buildbarn/bb-storage/pkg/filesystem"
"github.com/buildbarn/bb-storage/pkg/filesystem/path"
"github.com/buildbarn/bb-storage/pkg/storage"
"github.com/buildbarn/bb-storage/pkg/util"

"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -66,27 +67,27 @@ func (el *capturingErrorLogger) GetError() error {

type localBuildExecutor struct {
contentAddressableStorage blobstore.BlobAccess
commandReader storage.MessageReader[*remoteexecution.Command]
buildDirectoryCreator BuildDirectoryCreator
runner runner_pb.RunnerClient
clock clock.Clock
maximumWritableFileUploadDelay time.Duration
inputRootCharacterDevices map[path.Component]filesystem.DeviceNumber
maximumMessageSizeBytes int
environmentVariables map[string]string
forceUploadTreesAndDirectories bool
}

// NewLocalBuildExecutor returns a BuildExecutor that executes build
// steps on the local system.
func NewLocalBuildExecutor(contentAddressableStorage blobstore.BlobAccess, buildDirectoryCreator BuildDirectoryCreator, runner runner_pb.RunnerClient, clock clock.Clock, maximumWritableFileUploadDelay time.Duration, inputRootCharacterDevices map[path.Component]filesystem.DeviceNumber, maximumMessageSizeBytes int, environmentVariables map[string]string, forceUploadTreesAndDirectories bool) BuildExecutor {
func NewLocalBuildExecutor(contentAddressableStorage blobstore.BlobAccess, commandReader storage.MessageReader[*remoteexecution.Command], buildDirectoryCreator BuildDirectoryCreator, runner runner_pb.RunnerClient, clock clock.Clock, maximumWritableFileUploadDelay time.Duration, inputRootCharacterDevices map[path.Component]filesystem.DeviceNumber, environmentVariables map[string]string, forceUploadTreesAndDirectories bool) BuildExecutor {
return &localBuildExecutor{
contentAddressableStorage: contentAddressableStorage,
commandReader: commandReader,
buildDirectoryCreator: buildDirectoryCreator,
runner: runner,
clock: clock,
maximumWritableFileUploadDelay: maximumWritableFileUploadDelay,
inputRootCharacterDevices: inputRootCharacterDevices,
maximumMessageSizeBytes: maximumMessageSizeBytes,
environmentVariables: environmentVariables,
forceUploadTreesAndDirectories: forceUploadTreesAndDirectories,
}
Expand Down Expand Up @@ -231,12 +232,11 @@ func (be *localBuildExecutor) Execute(ctx context.Context, filePool pool.FilePoo
attachErrorToExecuteResponse(response, util.StatusWrap(err, "Failed to extract digest for command"))
return response
}
commandMessage, err := be.contentAddressableStorage.Get(ctx, commandDigest).ToProto(&remoteexecution.Command{}, be.maximumMessageSizeBytes)
command, err := be.commandReader.ReadMessage(ctx, commandDigest, &remoteexecution.Command{})
if err != nil {
attachErrorToExecuteResponse(response, util.StatusWrap(err, "Failed to obtain command"))
return response
}
command := commandMessage.(*remoteexecution.Command)
outputHierarchy, err := NewOutputHierarchy(command)
if err != nil {
attachErrorToExecuteResponse(response, err)
Expand Down
Loading
Loading