Skip to content

Commit

Permalink
Upgrade to the latest version of bb-storage and bb-remote-execution
Browse files Browse the repository at this point in the history
This requires us to make some minor code changes to account for the
change to path.Resolve() to take a path.Parser.
  • Loading branch information
EdSchouten committed Mar 8, 2024
1 parent 077b947 commit 19e35d0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 35 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
"name": "Check out source code",
"uses": "actions/checkout@v1"
},
{
"name": "Restore Bazel cache",
"uses": "actions/cache@v1",
"with": {
"key": "bazel",
"path": "~/.cache/bazel"
}
},
{
"name": "Gazelle",
"run": "bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro go_dependencies.bzl%go_dependencies -prune && bazel run //:gazelle"
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/pull-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
"name": "Check out source code",
"uses": "actions/checkout@v1"
},
{
"name": "Restore Bazel cache",
"uses": "actions/cache@v1",
"with": {
"key": "bazel",
"path": "~/.cache/bazel"
}
},
{
"name": "Gazelle",
"run": "bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro go_dependencies.bzl%go_dependencies -prune && bazel run //:gazelle"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ replace github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/g

require (
github.com/bazelbuild/remote-apis v0.0.0-20240215191509-9ff14cecffe5
github.com/buildbarn/bb-remote-execution v0.0.0-20240306174844-94b3776d5dba
github.com/buildbarn/bb-storage v0.0.0-20240227100204-0aa40dfdbead
github.com/buildbarn/bb-remote-execution v0.0.0-20240307211444-6879a90a1d00
github.com/buildbarn/bb-storage v0.0.0-20240307194821-4d0d7a3d85b5
golang.org/x/sync v0.6.0
google.golang.org/genproto/googleapis/bytestream v0.0.0-20240228224816-df926f6c8641
google.golang.org/grpc v1.62.0
Expand Down Expand Up @@ -86,7 +86,7 @@ require (
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.162.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ github.com/buildbarn/bb-remote-execution v0.0.0-20240222085313-f5b199467dd6 h1:d
github.com/buildbarn/bb-remote-execution v0.0.0-20240222085313-f5b199467dd6/go.mod h1:qwNvc1PxPWzRzcKiQ/Hq1MQmxB8fjWQ+Lv0h9r8aysU=
github.com/buildbarn/bb-remote-execution v0.0.0-20240306174844-94b3776d5dba h1:pe9k/EHyywQK/OYEQkmHY7cYycG41kDEd6Ae+lHynkM=
github.com/buildbarn/bb-remote-execution v0.0.0-20240306174844-94b3776d5dba/go.mod h1:qwNvc1PxPWzRzcKiQ/Hq1MQmxB8fjWQ+Lv0h9r8aysU=
github.com/buildbarn/bb-remote-execution v0.0.0-20240307211444-6879a90a1d00 h1:Pz2SMTPFEbrxvfpGt2f0VMj6ZooIW5GMDH0MaIk6tIU=
github.com/buildbarn/bb-remote-execution v0.0.0-20240307211444-6879a90a1d00/go.mod h1:R/PblhgyLNtqYySF5xvpjbMzfmGYW1HWrPvwN6q0FQU=
github.com/buildbarn/bb-storage v0.0.0-20240227100204-0aa40dfdbead h1:fHapKnQQLgJaMxGiBAUCPVHNfD5vV1LDfXqmyClJ6Lc=
github.com/buildbarn/bb-storage v0.0.0-20240227100204-0aa40dfdbead/go.mod h1:gHT0PInDFOV/JZjeeNwvqmn33MKHHyk3V18e4/Cs/jM=
github.com/buildbarn/bb-storage v0.0.0-20240307194821-4d0d7a3d85b5 h1:tBbub4L03HT0PNKToki245kaXjwb+AOzyhfy8oosL6w=
github.com/buildbarn/bb-storage v0.0.0-20240307194821-4d0d7a3d85b5/go.mod h1:0uISGKJD6Owt29w2sUlK0TeLtYdLWtBiC43yVHdgMAY=
github.com/buildbarn/go-xdr v0.0.0-20231115101217-a9e2aa4cf64b h1:/sKWC0Fs5fXNo/t72BRZRLERg4v2gFoEeg2Mk+a8xak=
github.com/buildbarn/go-xdr v0.0.0-20231115101217-a9e2aa4cf64b/go.mod h1:VwInghBSUyPtNBhl7o2oCUnxOCTGgySJnRTO1Kh7XuI=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -280,6 +284,7 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
13 changes: 6 additions & 7 deletions go_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ def go_dependencies():
go_repository(
name = "com_github_buildbarn_bb_remote_execution",
importpath = "github.com/buildbarn/bb-remote-execution",
sum = "h1:pe9k/EHyywQK/OYEQkmHY7cYycG41kDEd6Ae+lHynkM=",
version = "v0.0.0-20240306174844-94b3776d5dba",
sum = "h1:Pz2SMTPFEbrxvfpGt2f0VMj6ZooIW5GMDH0MaIk6tIU=",
version = "v0.0.0-20240307211444-6879a90a1d00",
)
go_repository(
name = "com_github_buildbarn_bb_storage",
importpath = "github.com/buildbarn/bb-storage",
sum = "h1:fHapKnQQLgJaMxGiBAUCPVHNfD5vV1LDfXqmyClJ6Lc=",
version = "v0.0.0-20240227100204-0aa40dfdbead",
sum = "h1:tBbub4L03HT0PNKToki245kaXjwb+AOzyhfy8oosL6w=",
version = "v0.0.0-20240307194821-4d0d7a3d85b5",
)
go_repository(
name = "com_github_buildbarn_go_xdr",
Expand Down Expand Up @@ -1567,9 +1567,8 @@ def go_dependencies():
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
patches = ["@com_github_buildbarn_bb_storage//:patches/org_golang_x_sys/golang-issue-59357.diff"],
sum = "h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=",
version = "v0.17.0",
sum = "h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=",
version = "v0.18.0",
)
go_repository(
name = "org_golang_x_term",
Expand Down
36 changes: 27 additions & 9 deletions pkg/filesystem/virtual/bazel_output_service_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ func (d *BazelOutputServiceDirectory) StartBuild(ctx context.Context, request *b
// Compute the full output path and the output path suffix. The
// former needs to be used by us, while the latter is
// communicated back to the client.
outputPathPrefixParser, err := path.NewUNIXParser(request.OutputPathPrefix)
if err != nil {
return nil, util.StatusWrap(err, "Invalid output path prefix")
}
outputPath, scopeWalker := path.EmptyBuilder.Join(path.NewAbsoluteScopeWalker(path.VoidComponentWalker))
if err := path.Resolve(request.OutputPathPrefix, scopeWalker); err != nil {
if err := path.Resolve(outputPathPrefixParser, scopeWalker); err != nil {
return nil, util.StatusWrap(err, "Failed to resolve output path prefix")
}
outputPathSuffix, scopeWalker := path.EmptyBuilder.Join(path.VoidScopeWalker)
Expand All @@ -258,7 +262,7 @@ func (d *BazelOutputServiceDirectory) StartBuild(ctx context.Context, request *b
if !ok {
return nil, status.Error(codes.InvalidArgument, "Output base ID is not a valid filename")
}
componentWalker, err := scopeWalker.OnScope(false)
componentWalker, err := scopeWalker.OnRelative()
if err != nil {
return nil, util.StatusWrap(err, "Failed to resolve output path")
}
Expand Down Expand Up @@ -406,10 +410,14 @@ func (cw *parentDirectoryCreatingComponentWalker) OnUp() (path.ComponentWalker,

func (d *BazelOutputServiceDirectory) stageSingleArtifact(ctx context.Context, artifact *bazeloutputservice.StageArtifactsRequest_Artifact, outputPathState *outputPathState, buildState *buildState) error {
// Resolve the parent directory and filename of the artifact to create.
pathParser, err := path.NewUNIXParser(artifact.Path)
if err != nil {
return util.StatusWrap(err, "Invalid path")
}
outputParentCreator := parentDirectoryCreatingComponentWalker{
stack: util.NewNonEmptyStack[virtual.PrepopulatedDirectory](outputPathState.rootDirectory),
}
if err := path.Resolve(artifact.Path, path.NewRelativeScopeWalker(&outputParentCreator)); err != nil {
if err := path.Resolve(pathParser, path.NewRelativeScopeWalker(&outputParentCreator)); err != nil {
return util.StatusWrap(err, "Failed to resolve path")
}
name := outputParentCreator.TerminalName
Expand Down Expand Up @@ -515,10 +523,12 @@ type statWalker struct {
stat *bazeloutputservice.BatchStatResponse_Stat
}

func (cw *statWalker) OnScope(absolute bool) (path.ComponentWalker, error) {
if absolute {
cw.stack.PopAll()
}
func (cw *statWalker) OnAbsolute() (path.ComponentWalker, error) {
cw.stack.PopAll()
return cw.OnRelative()
}

func (cw *statWalker) OnRelative() (path.ComponentWalker, error) {
// Currently in a known directory.
cw.stat = &bazeloutputservice.BatchStatResponse_Stat{
Type: &bazeloutputservice.BatchStatResponse_Stat_Directory_{},
Expand Down Expand Up @@ -548,13 +558,17 @@ func (cw *statWalker) OnDirectory(name path.Component) (path.GotDirectoryOrSymli
} else if err != nil {
return nil, err
}
targetParser, err := path.NewUNIXParser(target)
if err != nil {
return nil, err
}

// Got a symbolic link in the middle of a path. Those should
// always be followed.
cw.stat = &bazeloutputservice.BatchStatResponse_Stat{}
return path.GotSymlink{
Parent: cw,
Target: target,
Target: targetParser,
}, nil
}

Expand Down Expand Up @@ -605,14 +619,18 @@ func (d *BazelOutputServiceDirectory) BatchStat(ctx context.Context, request *ba
Responses: make([]*bazeloutputservice.BatchStatResponse_StatResponse, 0, len(request.Paths)),
}
for _, statPath := range request.Paths {
statPathParser, err := path.NewUNIXParser(statPath)
if err != nil {
return nil, util.StatusWrapf(err, "Invalid path %#v", statPath)
}
statWalker := statWalker{
digestFunction: &buildState.digestFunction,
stack: util.NewNonEmptyStack[virtual.PrepopulatedDirectory](outputPathState.rootDirectory),
stat: &bazeloutputservice.BatchStatResponse_Stat{},
}
resolvedPath, scopeWalker := path.EmptyBuilder.Join(
buildState.scopeWalkerFactory.New(path.NewLoopDetectingScopeWalker(&statWalker)))
if err := path.Resolve(statPath, scopeWalker); err == syscall.ENOENT {
if err := path.Resolve(statPathParser, scopeWalker); err == syscall.ENOENT {
// Path does not exist.
response.Responses = append(response.Responses, &bazeloutputservice.BatchStatResponse_StatResponse{})
} else if err != nil {
Expand Down

0 comments on commit 19e35d0

Please sign in to comment.