Skip to content

Commit 0de5269

Browse files
Move filepool to its own package
1 parent 7204e07 commit 0de5269

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+145
-87
lines changed

cmd/bb_noop_worker/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ go_library(
1010
"//pkg/blobstore",
1111
"//pkg/builder",
1212
"//pkg/filesystem",
13+
"//pkg/filesystem/filepool",
1314
"//pkg/proto/configuration/bb_noop_worker",
1415
"//pkg/proto/remoteworker",
1516
"@com_github_buildbarn_bb_storage//pkg/blobstore/configuration",

cmd/bb_noop_worker/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
re_blobstore "github.com/buildbarn/bb-remote-execution/pkg/blobstore"
99
"github.com/buildbarn/bb-remote-execution/pkg/builder"
10-
re_filesystem "github.com/buildbarn/bb-remote-execution/pkg/filesystem"
10+
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/filepool"
1111
"github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/bb_noop_worker"
1212
"github.com/buildbarn/bb-remote-execution/pkg/proto/remoteworker"
1313
blobstore_configuration "github.com/buildbarn/bb-storage/pkg/blobstore/configuration"
@@ -76,7 +76,7 @@ func main() {
7676
contentAddressableStorage,
7777
int(configuration.MaximumMessageSizeBytes),
7878
browserURL),
79-
re_filesystem.EmptyFilePool,
79+
filepool.EmptyFilePool,
8080
clock.SystemClock,
8181
configuration.WorkerId,
8282
instanceNamePrefix,

cmd/bb_worker/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ go_library(
1717
"//pkg/cleaner",
1818
"//pkg/clock",
1919
"//pkg/filesystem",
20+
"//pkg/filesystem/filepool",
2021
"//pkg/filesystem/virtual",
2122
"//pkg/filesystem/virtual/configuration",
2223
"//pkg/proto/completedactionlogger",

cmd/bb_worker/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/buildbarn/bb-remote-execution/pkg/cas"
1919
"github.com/buildbarn/bb-remote-execution/pkg/cleaner"
2020
re_clock "github.com/buildbarn/bb-remote-execution/pkg/clock"
21-
re_filesystem "github.com/buildbarn/bb-remote-execution/pkg/filesystem"
21+
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/filepool"
2222
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/virtual"
2323
virtual_configuration "github.com/buildbarn/bb-remote-execution/pkg/filesystem/virtual/configuration"
2424
cal_proto "github.com/buildbarn/bb-remote-execution/pkg/proto/completedactionlogger"
@@ -76,7 +76,7 @@ func main() {
7676
// currently only used by the virtual file system to store
7777
// output files of build actions. Going forward, this may be
7878
// used to store core dumps generated by build actions as well.
79-
filePool, err := re_filesystem.NewFilePoolFromConfiguration(configuration.FilePool)
79+
filePool, err := filepool.NewFilePoolFromConfiguration(configuration.FilePool)
8080
if err != nil {
8181
return util.StatusWrap(err, "Failed to create file pool")
8282
}
@@ -218,7 +218,7 @@ func main() {
218218
virtualBuildDirectory = virtual.NewInMemoryPrepopulatedDirectory(
219219
virtual.NewHandleAllocatingFileAllocator(
220220
virtual.NewPoolBackedFileAllocator(
221-
re_filesystem.EmptyFilePool,
221+
filepool.EmptyFilePool,
222222
util.DefaultErrorLogger),
223223
handleAllocator),
224224
symlinkFactory,
@@ -466,7 +466,7 @@ func main() {
466466
buildClient := builder.NewBuildClient(
467467
schedulerClient,
468468
buildExecutor,
469-
re_filesystem.NewQuotaEnforcingFilePool(
469+
filepool.NewQuotaEnforcingFilePool(
470470
filePool,
471471
runnerConfiguration.MaximumFilePoolFileCount,
472472
runnerConfiguration.MaximumFilePoolSizeBytes),

internal/mock/BUILD.bazel

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ gomock(
172172
out = "filesystem_re.go",
173173
interfaces = [
174174
"DirectoryOpener",
175-
"FilePool",
176175
"SectorAllocator",
177176
],
178177
library = "//pkg/filesystem",
@@ -181,6 +180,18 @@ gomock(
181180
package = "mock",
182181
)
183182

183+
gomock(
184+
name = "filesystem_filepool",
185+
out = "filesystem_filepool.go",
186+
interfaces = [
187+
"FilePool"
188+
],
189+
library = "//pkg/filesystem/filepool",
190+
mockgen_model_library = "@org_uber_go_mock//mockgen/model",
191+
mockgen_tool = "@org_uber_go_mock//mockgen",
192+
package = "mock",
193+
)
194+
184195
gomock(
185196
name = "filesystem_virtual",
186197
out = "filesystem_virtual.go",
@@ -411,6 +422,7 @@ go_library(
411422
":completedactionlogger.go",
412423
":filesystem.go",
413424
":filesystem_access.go",
425+
":filesystem_filepool.go",
414426
":filesystem_re.go",
415427
":filesystem_virtual.go",
416428
":grpc_go.go",
@@ -445,6 +457,7 @@ go_library(
445457
"//pkg/cleaner",
446458
"//pkg/filesystem",
447459
"//pkg/filesystem/access",
460+
"//pkg/filesystem/filepool",
448461
"//pkg/filesystem/virtual",
449462
"//pkg/proto/bazeloutputservice",
450463
"//pkg/proto/buildqueuestate",

pkg/builder/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ go_library(
3838
"//pkg/clock",
3939
"//pkg/filesystem",
4040
"//pkg/filesystem/access",
41+
"//pkg/filesystem/filepool",
4142
"//pkg/filesystem/virtual",
4243
"//pkg/proto/cas",
4344
"//pkg/proto/completedactionlogger",
@@ -106,6 +107,7 @@ go_test(
106107
"//pkg/clock",
107108
"//pkg/filesystem",
108109
"//pkg/filesystem/access",
110+
"//pkg/filesystem/filepool",
109111
"//pkg/proto/cas",
110112
"//pkg/proto/completedactionlogger",
111113
"//pkg/proto/remoteworker",

pkg/builder/build_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"time"
77

88
remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
9-
"github.com/buildbarn/bb-remote-execution/pkg/filesystem"
9+
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/filepool"
1010
"github.com/buildbarn/bb-remote-execution/pkg/proto/remoteworker"
1111
"github.com/buildbarn/bb-storage/pkg/clock"
1212
"github.com/buildbarn/bb-storage/pkg/digest"
@@ -28,7 +28,7 @@ type BuildClient struct {
2828
// Constant fields.
2929
scheduler remoteworker.OperationQueueClient
3030
buildExecutor BuildExecutor
31-
filePool filesystem.FilePool
31+
filePool filepool.FilePool
3232
clock clock.Clock
3333
instanceNamePrefix digest.InstanceName
3434
instanceNamePatcher digest.InstanceNamePatcher
@@ -45,7 +45,7 @@ type BuildClient struct {
4545

4646
// NewBuildClient creates a new BuildClient instance that is set to the
4747
// initial state (i.e., being idle).
48-
func NewBuildClient(scheduler remoteworker.OperationQueueClient, buildExecutor BuildExecutor, filePool filesystem.FilePool, clock clock.Clock, workerID map[string]string, instanceNamePrefix digest.InstanceName, platform *remoteexecution.Platform, sizeClass uint32) *BuildClient {
48+
func NewBuildClient(scheduler remoteworker.OperationQueueClient, buildExecutor BuildExecutor, filePool filepool.FilePool, clock clock.Clock, workerID map[string]string, instanceNamePrefix digest.InstanceName, platform *remoteexecution.Platform, sizeClass uint32) *BuildClient {
4949
return &BuildClient{
5050
scheduler: scheduler,
5151
buildExecutor: buildExecutor,

pkg/builder/build_directory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"os"
66

7-
re_filesystem "github.com/buildbarn/bb-remote-execution/pkg/filesystem"
87
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/access"
8+
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/filepool"
99
"github.com/buildbarn/bb-storage/pkg/digest"
1010
"github.com/buildbarn/bb-storage/pkg/filesystem"
1111
"github.com/buildbarn/bb-storage/pkg/filesystem/path"
@@ -36,7 +36,7 @@ type BuildDirectory interface {
3636
// errors. Implementations of BuildDirectory are free to let
3737
// this be a no-op, with the disadvantage that they cannot apply
3838
// resource limits or provide rich I/O error messages.
39-
InstallHooks(filePool re_filesystem.FilePool, errorLogger util.ErrorLogger)
39+
InstallHooks(filePool filepool.FilePool, errorLogger util.ErrorLogger)
4040

4141
// Recursively merges the contents of a Directory stored in the
4242
// Content Addressable Storage into a local directory. If this

pkg/builder/build_executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55

66
remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
7-
"github.com/buildbarn/bb-remote-execution/pkg/filesystem"
87
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/access"
8+
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/filepool"
99
"github.com/buildbarn/bb-remote-execution/pkg/proto/remoteworker"
1010
"github.com/buildbarn/bb-storage/pkg/digest"
1111

@@ -67,5 +67,5 @@ func GetResultAndGRPCCodeFromExecuteResponse(response *remoteexecution.ExecuteRe
6767
// requests and yield an execute response.
6868
type BuildExecutor interface {
6969
CheckReadiness(ctx context.Context) error
70-
Execute(ctx context.Context, filePool filesystem.FilePool, monitor access.UnreadDirectoryMonitor, digestFunction digest.Function, request *remoteworker.DesiredState_Executing, executionStateUpdates chan<- *remoteworker.CurrentState_Executing) *remoteexecution.ExecuteResponse
70+
Execute(ctx context.Context, filePool filepool.FilePool, monitor access.UnreadDirectoryMonitor, digestFunction digest.Function, request *remoteworker.DesiredState_Executing, executionStateUpdates chan<- *remoteworker.CurrentState_Executing) *remoteexecution.ExecuteResponse
7171
}

pkg/builder/caching_build_executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"net/url"
66

77
remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
8-
"github.com/buildbarn/bb-remote-execution/pkg/filesystem"
98
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/access"
9+
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/filepool"
1010
cas_proto "github.com/buildbarn/bb-remote-execution/pkg/proto/cas"
1111
"github.com/buildbarn/bb-remote-execution/pkg/proto/remoteworker"
1212
re_util "github.com/buildbarn/bb-remote-execution/pkg/util"
@@ -42,7 +42,7 @@ func NewCachingBuildExecutor(base BuildExecutor, contentAddressableStorage, acti
4242
}
4343
}
4444

45-
func (be *cachingBuildExecutor) Execute(ctx context.Context, filePool filesystem.FilePool, monitor access.UnreadDirectoryMonitor, digestFunction digest.Function, request *remoteworker.DesiredState_Executing, executionStateUpdates chan<- *remoteworker.CurrentState_Executing) *remoteexecution.ExecuteResponse {
45+
func (be *cachingBuildExecutor) Execute(ctx context.Context, filePool filepool.FilePool, monitor access.UnreadDirectoryMonitor, digestFunction digest.Function, request *remoteworker.DesiredState_Executing, executionStateUpdates chan<- *remoteworker.CurrentState_Executing) *remoteexecution.ExecuteResponse {
4646
response := be.BuildExecutor.Execute(ctx, filePool, monitor, digestFunction, request, executionStateUpdates)
4747
if actionDigest, err := digestFunction.NewDigestFromProto(request.ActionDigest); err != nil {
4848
attachErrorToExecuteResponse(response, util.StatusWrap(err, "Failed to extract digest for action"))

0 commit comments

Comments
 (0)