Skip to content

feat(bigtable): add CBT_ENABLE_DIRECTPATH=false in case user want to disable directpath#14160

Merged
sushanb merged 10 commits intogoogleapis:mainfrom
sushanb:fix_l
Mar 27, 2026
Merged

feat(bigtable): add CBT_ENABLE_DIRECTPATH=false in case user want to disable directpath#14160
sushanb merged 10 commits intogoogleapis:mainfrom
sushanb:fix_l

Conversation

@sushanb
Copy link
Copy Markdown
Contributor

@sushanb sushanb commented Mar 11, 2026

  1. Enable sending the same feature flags

@sushanb sushanb requested a review from nimf March 11, 2026 21:31
@sushanb sushanb requested review from a team as code owners March 11, 2026 21:31
@product-auto-label product-auto-label Bot added the api: bigtable Issues related to the Bigtable API. label Mar 11, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the DirectPath enablement logic, making it on-by-default and allowing it to be disabled via the CBT_ENABLE_DIRECTPATH environment variable. My review focuses on ensuring consistent behavior and improving code clarity. I've identified an inconsistency in how DirectPath is enabled across different connection pool configurations and suggested a fix. I also have some recommendations for improving comments and logging for better maintainability.

Comment thread bigtable/client.go
Comment thread bigtable/client.go Outdated
Comment thread bigtable/internal/transport/connpool.go Outdated
Copy link
Copy Markdown
Contributor

@nimf nimf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm confused. Why if we use bigtable channel pool we enable direct access by default and check if CBT_ENABLE_DIRECTPATH is false, while when we don't use bigtable channel pool we enable direct access only when CBT_ENABLE_DIRECTPATH is true?

var isDirectAccess bool
if firstConn, isDirectAccess = pool.checkIfDirectAccessCompatible(); isDirectAccess {
directAccessConn, isDirectAccess := pool.checkIfDirectAccessCompatible()
disableDirectAccess := os.Getenv("CBT_ENABLE_DIRECTPATH") == "false"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user disabled directpath we don't need to check if direct acccess compatible. I.e., check if directpath disabled first, if it is disabled, then directAccessConn is null and isDirectAccess is false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if user disabled, we still want to check and export the metrics.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it in a separate goroutine then, not to delay channel pool creation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think your idea is great. skipped the check if If user disabled directpath

Comment thread bigtable/client.go
btransport.WithInstanceName(fullInstanceName),
btransport.WithAppProfile(config.AppProfile),
btransport.WithFeatureFlagsMetadata(ffMD),
btransport.WithFeatureFlagsMetadata(directAccessMD),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we set both featureFlagsMetadata and directAccessFeatureFlagsMetadata to directAccessMD? We don't know if we will use directpath or not yet, because we check CBT_ENABLE_DIRECTPATH in the bigtable channel pool later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am making featureflags agnostic of transport. we will send the same feature flag now for both directpath and cloudpath.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm... But this means we will send DirectAccessRequested as true even if the user disables directpath?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I kept as it for now. I agree that it is not nice to send the featureflags if user explicitly disables direct access. I will do as a followup.

@sushanb
Copy link
Copy Markdown
Contributor Author

sushanb commented Mar 12, 2026

Sorry, I'm confused. Why if we use bigtable channel pool we enable direct access by default and check if CBT_ENABLE_DIRECTPATH is false, while when we don't use bigtable channel pool we enable direct access only when CBT_ENABLE_DIRECTPATH is true?

We are getting rid of legacy channel pool and will use the bigtable channel pool. that is the reason.

@sushanb sushanb requested a review from nimf March 12, 2026 00:31
Comment thread bigtable/internal/directaccess/gcp.go Outdated
Comment thread bigtable/internal/directaccess/metadata_server.go Outdated
Comment thread bigtable/internal/transport/connpool.go Outdated
Comment thread bigtable/internal/transport/connpool.go Outdated
Comment thread bigtable/client.go
directAccessDialerOptions := make([]option.ClientOption, len(o))
copy(directAccessDialerOptions, o)
directAccessDialerOptions = append(directAccessDialerOptions, directPathOptions...)
// enable hard bound tokens by default
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we don't need to check for CBT_DISABLE_DIRECTPATH_BOUND_TOKEN for BigtableConnPool but need to check it otherwise on line 242 below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question. @rockspore can we now enable the direct bound token by default?

@sushanb sushanb requested a review from nimf March 27, 2026 01:43
Copy link
Copy Markdown
Contributor

@nimf nimf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sushanb sushanb merged commit 2507934 into googleapis:main Mar 27, 2026
14 checks passed
@sushanb sushanb deleted the fix_l branch March 27, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants