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

Configuration of the proxied HTTP request version. #512

Merged
merged 15 commits into from
Nov 10, 2020

Conversation

ManickaP
Copy link
Member

@ManickaP ManickaP commented Nov 3, 2020

Adds configuration side to setting up Version and VersioningPolicy (for .NET 5 and higher) of an outbound HTTP Request.

Fixes #282


namespace Microsoft.ReverseProxy.RuntimeModel
{
public readonly struct ClusterProxyHttpRequestOptions
Copy link
Member

Choose a reason for hiding this comment

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

Discussed offline: we'll want to see how we can unify this with RequestProxyOptions so we don't have to allocate that per request. The big differences are:

  • RequestProxyOptions has Transforms on it which come from routeConfig.
  • RequestProxyOptions has the Timeout which should be easy to move/mirror.
  • struct vs class, readonly vs mutable
  • Naming

Some possibilities:

  • We come up with a type that works in both scenarios and use that on ClusterConfig.
  • RequestProxyOptions becomes a readonly struct so at least we don't have to allocate it. We'd still end up copying the paramters across.
  • Transforms get passed into IHttpProxy.ProxyAsync as a separate parameter, making the options types more compatible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@alnikola alnikola left a comment

Choose a reason for hiding this comment

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

Consider applying the request version settings to active health probes.

src/ReverseProxy/Service/Management/ProxyConfigManager.cs Outdated Show resolved Hide resolved
@@ -31,7 +31,7 @@ public void CreateRequest_HealthEndpointIsNotDefined_UseDestinationAddress(strin
private ClusterConfig GetClusterConfig(string id, ClusterActiveHealthCheckOptions healthCheckOptions)
{
return new ClusterConfig(
new Cluster { Id = id }, new ClusterHealthCheckOptions(default, healthCheckOptions), default, default, null, default, null);
new Cluster { Id = id }, new ClusterHealthCheckOptions(default, healthCheckOptions), default, default, null, default, default, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

If the request version settings are also applied to active health probes, it must be verified in this test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

Copy link
Contributor

@alnikola alnikola left a comment

Choose a reason for hiding this comment

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

Production code looks good now, only a couple test-related suggestions.

@ManickaP
Copy link
Member Author

ManickaP commented Nov 9, 2020

@Tratcher, @alnikola: I think I've addressed all comments except for the type-merging one, which I'd rather do separately if you're OK with it. I'll file an issue and look into it immediately. I'd just prefer to split the work.

Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

File an issue for the type merging.


Configuration settings:
- RequestTimeout - the timeout for the outgoing request sent by [HttpMessageInvoker.SendAsync](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpmessageinvoker.sendasync?view=netcore-3.1). If not specified, 100 seconds is used.
- Version - outgoing request [version](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=netcore-3.1). The supported values at the moment are 1.0, 1.1 and 2. Default value is 2.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Version - outgoing request [version](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=netcore-3.1). The supported values at the moment are 1.0, 1.1 and 2. Default value is 2.
- Version - outgoing request [version](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httprequestmessage.version?view=netcore-3.1). The supported values at the moment are `1.0`, `1.1` and `2`. Default value is `2`.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@davidfowl
Copy link
Contributor

davidfowl commented Nov 9, 2020

@ManickaP Hey, I'm working on this PR to change configuration reading #521. I'm going to wait until this PR is merged before reacting (since they conflict)

@ManickaP ManickaP marked this pull request as ready for review November 9, 2020 21:54
Comment on lines 20 to 26
#else
public ClusterProxyHttpRequestOptions(TimeSpan? requestTimeout, Version version)
{
RequestTimeout = requestTimeout;
Version = version;
}
#endif
Copy link
Member

Choose a reason for hiding this comment

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

This constructor should exist in both versions. We don't change/remove public API across versions if we can avoid it.

Suggested change
#else
public ClusterProxyHttpRequestOptions(TimeSpan? requestTimeout, Version version)
{
RequestTimeout = requestTimeout;
Version = version;
}
#endif
#endif
public ClusterProxyHttpRequestOptions(TimeSpan? requestTimeout, Version version)
{
RequestTimeout = requestTimeout;
Version = version;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@ManickaP
Copy link
Member Author

@alnikola : could you please give this another look? I cannot merge till you approve since you originally requested changes.

Copy link
Contributor

@alnikola alnikola left a comment

Choose a reason for hiding this comment

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

LGTM

@ManickaP ManickaP merged commit 6d04918 into microsoft:master Nov 10, 2020
RequestTimeout = requestTimeout;
Version = version;
#if NET
VersionPolicy = HttpVersionPolicy.RequestVersionOrLower;
Copy link
Member

Choose a reason for hiding this comment

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

VersionPolicy = null; The default is applied later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aaaa, you're right.

@ManickaP ManickaP mentioned this pull request Nov 10, 2020
@Tratcher Tratcher added this to the YARP 1.0.0-preview7 milestone Nov 10, 2020
@ManickaP ManickaP deleted the mapichov/282_configuration branch November 10, 2020 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outbound http connections to destinations are configurable
4 participants