Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the AC correctly tracks the output blobs associated with an action #33

Closed
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: 1 addition & 1 deletion cmd/bb_storage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func main() {
grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
grpc.StatsHandler(&ocgrpc.ServerHandler{}),
)
remoteexecution.RegisterActionCacheServer(s, ac.NewActionCacheServer(actionCache, allowActionCacheUpdatesForInstances))
remoteexecution.RegisterActionCacheServer(s, ac.NewActionCacheServer(actionCache, contentAddressableStorageBlobAccess, allowActionCacheUpdatesForInstances))
remoteexecution.RegisterContentAddressableStorageServer(s, cas.NewContentAddressableStorageServer(contentAddressableStorageBlobAccess))
bytestream.RegisterByteStreamServer(s, cas.NewByteStreamServer(contentAddressableStorageBlobAccess, 1<<16))
remoteexecution.RegisterCapabilitiesServer(s, buildQueue)
Expand Down
30 changes: 29 additions & 1 deletion pkg/ac/action_cache_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package ac

import (
"context"
"fmt"

remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
"github.com/buildbarn/bb-storage/pkg/blobstore"
"github.com/buildbarn/bb-storage/pkg/util"

"google.golang.org/grpc/codes"
Expand All @@ -12,14 +14,16 @@ import (

type actionCacheServer struct {
actionCache ActionCache
blobAccess blobstore.BlobAccess
allowUpdatesForInstances map[string]bool
}

// NewActionCacheServer creates a GRPC service for serving the contents
// of a Bazel Action Cache (AC) to Bazel.
func NewActionCacheServer(actionCache ActionCache, allowUpdatesForInstances map[string]bool) remoteexecution.ActionCacheServer {
func NewActionCacheServer(actionCache ActionCache, blobAccess blobstore.BlobAccess, allowUpdatesForInstances map[string]bool) remoteexecution.ActionCacheServer {
return &actionCacheServer{
actionCache: actionCache,
blobAccess: blobAccess,
allowUpdatesForInstances: allowUpdatesForInstances,
}
}
Expand All @@ -29,6 +33,30 @@ func (s *actionCacheServer) GetActionResult(ctx context.Context, in *remoteexecu
if err != nil {
return nil, err
}

actionResult, err := s.actionCache.GetActionResult(ctx, digest)
if err != nil {
return nil, err
}

var digests []*util.Digest
for _, output := range actionResult.OutputFiles {
if output.Digest != nil {
OutputDigest, err := util.NewDigest(in.InstanceName, output.Digest)

if err != nil {
fmt.Println(err)
} else {
digests = append(digests, OutputDigest)
}
}
}

// Check that we have no missing blobs
if missing, err := s.blobAccess.FindMissing(ctx, digests); missing != nil {
return nil, status.Errorf(codes.NotFound, "Blob not found")
}

return s.actionCache.GetActionResult(ctx, digest)
}

Expand Down