Skip to content

Commit 0eebca1

Browse files
committed
fix(storage): do not enforce DirectPath for Rapid buckets
1 parent c18c912 commit 0eebca1

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

internal/storage/storage_handle.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func setRetryConfig(ctx context.Context, sc *storage.Client, clientConfig *stora
188188
}
189189

190190
// Followed https://pkg.go.dev/cloud.google.com/go/storage#hdr-Experimental_gRPC_API to create the gRPC client.
191-
func createGRPCClientHandle(ctx context.Context, clientConfig *storageutil.StorageClientConfig, isbucketRapid bool, enableBidiConfig bool, bucketName string, billingProject string) (*storage.Client, error) {
191+
func createGRPCClientHandle(ctx context.Context, clientConfig *storageutil.StorageClientConfig, isBucketRapid bool, enableBidiConfig bool, bucketName string, billingProject string) (*storage.Client, error) {
192192
if err := os.Setenv("GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS", "true"); err != nil {
193193
return nil, fmt.Errorf("error setting direct path env var: %w", err)
194194
}
@@ -202,7 +202,7 @@ func createGRPCClientHandle(ctx context.Context, clientConfig *storageutil.Stora
202202

203203
// Add DirectPath enforcement - client creation will fail if DirectPath is not available.
204204
// Rapid buckets do not support DirectPath enforcement headers.
205-
if !isbucketRapid {
205+
if !isBucketRapid {
206206
clientOpts = append(clientOpts, experimental.WithDirectConnectivityEnforced())
207207
}
208208

@@ -217,14 +217,15 @@ func createGRPCClientHandle(ctx context.Context, clientConfig *storageutil.Stora
217217
setRetryConfig(ctx, sc, clientConfig)
218218
}()
219219

220-
// Direct-path verification is fatal for regional. Todo(b/503624405): Make it fatal for all after making the dummy-stat reliable.
221-
if verifyErr := verifyDirectPathConnectivity(ctx, clientConfig, bucketName, sc, billingProject); verifyErr != nil {
222-
logger.Warnf("DirectPath verification failed with error: %v", verifyErr)
223-
if !isbucketRapid {
220+
// Skip DirectPath verification for Rapid buckets as DirectPath is not supported/enforced.
221+
if !isBucketRapid {
222+
// DirectPath verification is fatal for regional. Todo(b/503624405): Make it fatal for all after making the dummy-stat reliable.
223+
if verifyErr := verifyDirectPathConnectivity(ctx, clientConfig, bucketName, sc, billingProject); verifyErr != nil {
224+
logger.Warnf("DirectPath verification failed with error: %v", verifyErr)
224225
return nil, verifyErr
226+
} else {
227+
logger.Infof("DirectPath verification succeeded, continuing with DirectPath.")
225228
}
226-
} else {
227-
logger.Infof("DirectPath verification succeeded, continuing with DirectPath.")
228229
}
229230

230231
return sc, nil

internal/storage/storage_handle_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,11 +1129,12 @@ func (testSuite *StorageHandleTest) TestControlClientForBucketHandle_NonZonalBuc
11291129

11301130
func (testSuite *StorageHandleTest) TestCreateGRPCClientHandle_RapidBucket() {
11311131
sc := storageutil.GetDefaultStorageClientConfig(keyFile)
1132-
// For rapid buckets (isbucketRapid = true), createGRPCClientHandle should omit WithDirectConnectivityEnforced
1133-
// and should not return an error when verifyDirectPathConnectivity fails.
1132+
// For rapid buckets (isBucketRapid = true), createGRPCClientHandle should omit WithDirectConnectivityEnforced
1133+
// and skip verifyDirectPathConnectivity entirely.
11341134
client, err := createGRPCClientHandle(testSuite.ctx, &sc, true, true, TestBucketName, "")
1135-
assert.NoError(testSuite.T(), err)
1136-
assert.NotNil(testSuite.T(), client)
1135+
require.NoError(testSuite.T(), err)
1136+
require.NotNil(testSuite.T(), client)
1137+
defer client.Close()
11371138
}
11381139

11391140
func (testSuite *StorageHandleTest) TestCreateGRPCClientHandle_NonRapidBucket() {
@@ -1144,4 +1145,3 @@ func (testSuite *StorageHandleTest) TestCreateGRPCClientHandle_NonRapidBucket()
11441145
assert.Error(testSuite.T(), err)
11451146
assert.Nil(testSuite.T(), client)
11461147
}
1147-

0 commit comments

Comments
 (0)