-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Update azure service proxy configuration #24810
Update azure service proxy configuration #24810
Conversation
cc863ca
to
a7cc5ac
Compare
...nfigure/src/main/java/com/azure/spring/cloud/autoconfigure/cosmos/AzureCosmosProperties.java
Show resolved
Hide resolved
@@ -27,6 +30,9 @@ | |||
|
|||
public static final String PREFIX = "spring.cloud.azure.cosmos"; | |||
|
|||
@NestedConfigurationProperty | |||
protected final ProxyProperties proxy = new HttpProxyProperties(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why protected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change to private.
@Override | ||
public HttpClientProperties getClient() { | ||
return client; | ||
} | ||
|
||
@Override | ||
public ProxyProperties getProxy() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return HttpProxyProperties here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
...-core/src/main/java/com/azure/spring/core/factory/AbstractAzureAmqpClientBuilderFactory.java
Show resolved
Hide resolved
if (proxyOptions != null) { | ||
this.httpClientOptions.setProxyOptions(convertToProxyOptions(proxyProperties)); | ||
} else { | ||
LOGGER.warn("Invalid http proxyProperties configuration properties."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, will setting null throw exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same with AMQP factory.
There are some properties class attribute value null check, should we not judge the null situation, such as client, proxy, retry properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not use warning here
} | ||
} | ||
|
||
protected ProxyOptions convertToProxyOptions(ProxyProperties proxyProperties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is to allow a subclass to override this method so that a mock HttpClientOptions can be verified. I am looking for a better way.
3255e2f
to
73ea443
Compare
73ea443
to
ef99985
Compare
…re-sdk-for-java into feature-update/azure-service-proxy-configuration
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
@@ -34,8 +35,12 @@ public ProxyOptions convert(ProxyProperties proxyProperties) { | |||
if (StringUtils.hasText(proxyProperties.getUsername()) && StringUtils.hasText(proxyProperties.getPassword())) { | |||
proxyOptions.setCredentials(proxyProperties.getUsername(), proxyProperties.getPassword()); | |||
} | |||
// TODO (xiada) non proxy hosts | |||
if (proxyProperties instanceof HttpProxyProperties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this class is called AzureHttpProxyOptionsConverter.java
, should we change the method to pass in a HttpProxyProperties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
if (proxyOptions != null) { | ||
consumeProxyOptions().accept(builder, proxyOptions); | ||
} else { | ||
LOGGER.warn("Invalid AMQP proxy configuration properties."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't add waning here, it's okay not to set proxy.
...-core/src/main/java/com/azure/spring/core/factory/AbstractAzureAmqpClientBuilderFactory.java
Show resolved
Hide resolved
if (proxyProperties != null) { | ||
ProxyOptions proxyOptions = proxyOptionsConverter.convert(proxyProperties); | ||
if (proxyOptions != null) { | ||
this.httpClientOptions.setProxyOptions(proxyOptionsConverter.convert(proxyProperties)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why call proxyOptionsConverter.convert(proxyProperties)
twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake
if (proxyOptions != null) { | ||
this.httpClientOptions.setProxyOptions(convertToProxyOptions(proxyProperties)); | ||
} else { | ||
LOGGER.warn("Invalid http proxyProperties configuration properties."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not use warning here
...oud-azure-core/src/main/java/com/azure/spring/core/properties/proxy/HttpProxyProperties.java
Show resolved
Hide resolved
builder.gatewayMode(this.cosmosProperties.getGatewayConnection()); | ||
} else if (ConnectionMode.DIRECT.equals(this.cosmosProperties.getConnectionMode())) { | ||
// TODO (xiada): public CosmosClientBuilder directMode(DirectConnectionConfig directConnectionConfig, GatewayConnectionConfig gatewayConnectionConfig) { | ||
builder.gatewayMode(this.cosmosProperties.getGatewayConnection()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not add
if (ConnectionMode.GATEWAY.equals(this.cosmosProperties.getConnectionMode())) {
}
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direct mode will also use the proxy configuration which is from the gateconnection configuration, then the gateconnection will have the high priority to apply.
…re-sdk-for-java into feature-update/azure-service-proxy-configuration
if (proxy != null) { | ||
this.httpClientOptions.setProxyOptions(proxyOptionsConverter.convert(proxy)); | ||
final ProxyProperties proxyProperties = getAzureProperties().getProxy(); | ||
if (proxyProperties != null && proxyProperties instanceof HttpProxyProperties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we warn here if the proxy properties is not of type HttpProxyProperties?
…thod to apply direct mode connection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
...nfigure/src/main/java/com/azure/spring/cloud/autoconfigure/cosmos/AzureCosmosProperties.java
Show resolved
Hide resolved
/azp run java - spring - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes #21552
Update proxy configuration for Azure service client builder: