Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

feat: add an option to enable DirectPath xDS #1968

Closed
wants to merge 3 commits into from

Conversation

mohanli-ml
Copy link
Contributor

@mohanli-ml mohanli-ml commented Apr 12, 2023

Currently DirectPath xDS is enabled by using env. We want to also provide an option for this.

Go PR: googleapis/google-api-go-client#1942

@veblush

@mohanli-ml mohanli-ml changed the title Add an option to enable DirectPath xDS feat: add an option to enable DirectPath xDS Apr 12, 2023
@mohanli-ml
Copy link
Contributor Author

@suztomo Hi Tomo, can you review this PR? Thanks!

@suztomo
Copy link
Member

suztomo commented Apr 18, 2023

I assigned Blake.

return true;
}
// Method 2: Enable DirectPath xDS by option.
if (Boolean.TRUE.equals(useDirectPathXds)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually an explicitly set value has higher priority than environment variable, otherwise the users of this public field could be confused why their explicitly set value does not work.
That being said, this class and the whole DirectPath feature is supposed to be use by internal users only, so I'm fine with it if it's a requirement that env takes precedence over options, at least we should document this behavior in Javadoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reversed the order and check the option first.

@@ -684,6 +702,13 @@ public Builder setAllowNonDefaultServiceAccount(boolean allowNonDefaultServiceAc
return this;
}

/** Use DirectPath xDS. Only valid if DirectPath is attempted. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Document that an environment variable could override this option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new API is used to enable DirectPath xDS, but not disable. So I removed the bool parameter. In this way, the environment can not override the option.

@@ -262,6 +264,20 @@ private boolean isDirectPathEnabled(String serviceAddress) {
return false;
}

private boolean isDirectPathXdsUsed() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we test this behavior in unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@blakeli0
Copy link
Contributor

@mohanli-ml, we recently moved this repo to gapic-generator-java, can you please close this PR and open a new PR in gapic-generator-java?

@suztomo
Copy link
Member

suztomo commented Apr 19, 2023

(I didn't notice this PR was created in an old repo. Thanks.)

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

25.0% 25.0% Coverage
0.0% 0.0% Duplication

codyoss pushed a commit to googleapis/google-api-go-client that referenced this pull request Apr 19, 2023
Currently DirectPath xDS is enabled by using env. We want to also provide an option for this.

Java PR: googleapis/gax-java#1968
@mohanli-ml
Copy link
Contributor Author

@blakeli0 The new PR: googleapis/sdk-platform-java#1643.
(I did not know the repo is moved. Thanks!)

@mohanli-ml mohanli-ml closed this Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants