Skip to content

Commit

Permalink
address code review comments from first PR attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
srago committed Mar 18, 2024
1 parent 1806717 commit 8d9e809
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 137 deletions.
1 change: 1 addition & 0 deletions pkg/blobstore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ go_library(
"@com_google_cloud_go_spanner//admin/database/apiv1",
"@com_google_cloud_go_storage//:storage",
"@org_golang_google_api//iterator",
"@org_golang_google_api//option",
"@org_golang_google_genproto//googleapis/spanner/admin/database/v1:database",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
Expand Down
1 change: 1 addition & 0 deletions pkg/blobstore/configuration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ go_library(
"@com_github_fxtlabs_primes//:primes",
"@com_github_google_uuid//:uuid",
"@com_google_cloud_go_storage//:storage",
"@org_golang_google_api//option",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
"@org_golang_x_sync//semaphore",
Expand Down
23 changes: 19 additions & 4 deletions pkg/blobstore/configuration/new_blob_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/buildbarn/bb-storage/pkg/blobstore/sharding"
"github.com/buildbarn/bb-storage/pkg/blockdevice"
"github.com/buildbarn/bb-storage/pkg/clock"
"github.com/buildbarn/bb-storage/pkg/cloud/gcp"
"github.com/buildbarn/bb-storage/pkg/digest"
"github.com/buildbarn/bb-storage/pkg/eviction"
"github.com/buildbarn/bb-storage/pkg/filesystem"
Expand All @@ -27,6 +28,7 @@ import (
"github.com/fxtlabs/primes"

"google.golang.org/grpc/codes"
"google.golang.org/api/option"
"google.golang.org/grpc/status"
)

Expand Down Expand Up @@ -356,19 +358,32 @@ func (nc *simpleNestedBlobAccessCreator) newNestedBlobAccessBare(configuration *
}, backendType, nil
case *pb.BlobAccessConfiguration_SpannerGcs:
var digestKeyFormat digest.KeyFormat
if backend.SpannerGcs.StorageType == pb.StorageType_ACTION_CACHE {
if storageTypeName == "AC" {
digestKeyFormat = digest.KeyWithInstance
} else if backend.SpannerGcs.StorageType == pb.StorageType_CASTORE {
} else if storageTypeName == "CAS" {
digestKeyFormat = digest.KeyWithoutInstance
} else {
return BlobAccessInfo{}, "", status.Errorf(codes.InvalidArgument, "Unknown SpannerGcs storage type")
}

var clientOptions []option.ClientOption
var err error
if gcpClientOpts := backend.SpannerGcs.GcpClientOptions; gcpClientOpts != nil {
// Unused currently, but here for future expansion
clientOptions, err = gcp.NewClientOptionsFromConfiguration(gcpClientOpts, "")
if err != nil {
return BlobAccessInfo{}, "", util.StatusWrap(err, "Failed to create GCP client options")
}
}

blobAccess, err := blobstore.NewSpannerGCSBlobAccess(
backend.SpannerGcs.SpannerDbName,
backend.SpannerGcs.GcsBucketName,
readBufferFactory,
backend.SpannerGcs.StorageType,
backend.SpannerGcs.ExpirationDays)
storageTypeName,
backend.SpannerGcs.ExpirationDays,
creator.GetDefaultCapabilitiesProvider(),
clientOptions)
if err != nil {
return BlobAccessInfo{}, "", util.StatusWrap(err, "Failed to create SpannerGcs blob access")
}
Expand Down
Loading

0 comments on commit 8d9e809

Please sign in to comment.