Skip to content
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

Conversation

moarychan
Copy link
Member

Fixes #21552

Update proxy configuration for Azure service client builder:

  • HTTP-based Service builder proxy
  • AMQP-based service builder proxy
  • Cosmos Service builder proxy

@ghost ghost added the azure-spring All azure-spring related issues label Oct 15, 2021
@saragluna saragluna force-pushed the feature/azure-spring-cloud-4.0 branch from cc863ca to a7cc5ac Compare October 15, 2021 10:03
@@ -27,6 +30,9 @@

public static final String PREFIX = "spring.cloud.azure.cosmos";

@NestedConfigurationProperty
protected final ProxyProperties proxy = new HttpProxyProperties();
Copy link
Member

Choose a reason for hiding this comment

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

why protected?

Copy link
Member Author

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() {
Copy link
Member

Choose a reason for hiding this comment

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

should return HttpProxyProperties here

Copy link
Member Author

Choose a reason for hiding this comment

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

OK

if (proxyOptions != null) {
this.httpClientOptions.setProxyOptions(convertToProxyOptions(proxyProperties));
} else {
LOGGER.warn("Invalid http proxyProperties configuration properties.");
Copy link
Member

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?

Copy link
Member Author

@moarychan moarychan Oct 18, 2021

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

Copy link
Member

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) {
Copy link
Member

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

Copy link
Member Author

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.

@moarychan moarychan force-pushed the feature-update/azure-service-proxy-configuration branch from 3255e2f to 73ea443 Compare October 18, 2021 13:22
@moarychan moarychan force-pushed the feature-update/azure-service-proxy-configuration branch from 73ea443 to ef99985 Compare October 19, 2021 00:50
@moarychan moarychan linked an issue Oct 19, 2021 that may be closed by this pull request
@saragluna saragluna self-assigned this Oct 19, 2021
Moary Chen added 2 commits October 20, 2021 08:45
…re-sdk-for-java into feature-update/azure-service-proxy-configuration
@check-enforcer
Copy link

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:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

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:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run java - [service] - ci

@@ -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) {
Copy link
Member

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?

Copy link
Member Author

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.");
Copy link
Member

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.

if (proxyProperties != null) {
ProxyOptions proxyOptions = proxyOptionsConverter.convert(proxyProperties);
if (proxyOptions != null) {
this.httpClientOptions.setProxyOptions(proxyOptionsConverter.convert(proxyProperties));
Copy link
Member

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?

Copy link
Member Author

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.");
Copy link
Member

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

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());
Copy link
Member

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

Copy link
Member Author

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.

Moary Chen added 2 commits October 26, 2021 14:13
…re-sdk-for-java into feature-update/azure-service-proxy-configuration
@saragluna saragluna marked this pull request as ready for review October 28, 2021 07:05
if (proxy != null) {
this.httpClientOptions.setProxyOptions(proxyOptionsConverter.convert(proxy));
final ProxyProperties proxyProperties = getAzureProperties().getProxy();
if (proxyProperties != null && proxyProperties instanceof HttpProxyProperties) {
Copy link
Member

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?

Copy link
Member

@saragluna saragluna left a comment

Choose a reason for hiding this comment

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

LGTM.

@saragluna
Copy link
Member

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@moarychan moarychan merged commit 876e9af into Azure:feature/azure-spring-cloud-4.0 Oct 28, 2021
@moarychan moarychan deleted the feature-update/azure-service-proxy-configuration branch November 17, 2021 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support configure proxy
2 participants