-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
core,okhttp,netty,alts,testing: Plumb proxy resolved addr to transports #4137
Conversation
final ProxyParameters proxy; | ||
try { | ||
proxy = proxyDetector.proxyFor(destination); | ||
} catch (Exception e) { |
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.
Just catch IOException?
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.
done
if (proxy != null) { | ||
EquivalentAddressGroup server = new EquivalentAddressGroup(destination); | ||
EquivalentAddressGroup server = | ||
new EquivalentAddressGroup(new ProxiedInetSocketAddress(destination, proxy)); |
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.
ProxiedInetSocketAddress is weird, and it can't be internal long-term. Any NR should be able to support proxies.
The discussion about it should probably include @zhangkun83. (IIRC, the problem here is how should flattening by pick-first impact the attributes of the EquivalentAddressGroup
.)
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.
ProxiedInetSocketAddress was my suggestion. I don't see a problem making it public if we need to. Can you elaborate your concerns?
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.
@zhangkun83 and I talked at length about this offline. It seems we're going to be mucking with how NameResolvers and LBs communicate again. That will need some other requirements to be gathered. But in the short term we want some sort of PairSocketAddress
(I'm saying that name because it is obviously bad; we need a different name) that would contain (SocketAddress, Attr)
. It basically shoe-horns something similar to the deleted ResolvedServerInfo
without a full redesign of the APIs.
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.
Does this imply EquivalentAddressGroup::getAddresses()
would return a list of PairSocketAddress
? Sounds like we will just commit to making this class public now, and reusing it later for NameResolvers+LBs.
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.
It would continue to return a list of SocketAddress
. No, we're not ready to make this public. There needs to be a longer-term design and that needs some investigation into requirements.
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.
ack, changed it to PairSocketAddress
@@ -205,6 +202,21 @@ public void run() { | |||
} | |||
} | |||
} | |||
|
|||
private void rescheduleWithCause(Listener savedListener, Exception cause) { |
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.
Note that this will cause some git conflicts with #4105. (It looks like it'll be unnecessary after that other PR.)
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.
Rebased and removed unnecessary rescheduling
@@ -147,8 +147,6 @@ void handleUncaughtThrowable(Throwable t) { | |||
// Only null after channel is terminated. Must be assigned from the channelExecutor. | |||
private NameResolver nameResolver; | |||
|
|||
private final ProxyDetector proxyDetector; |
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.
Note that we should plumb the proxyDetector
eventually through here to the Name Resolver. We shouldn't pass the proxyDetector
is the constructor like we do now. We could pass it in as Attributes params
.
(CC @zhangkun83, I wonder if we should revisit that params
argument to the NameResolver and do something more similar to Params/Helper from LB. That can be later though.)
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 application provide ProxyDetector? Do we want NameResolvers to decide whether to use proxy or not?
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 want proxies to make the final determination, but we should provide the detector. We shouldn't assume such information is global. There's #3957 for example.
ProxyDetector is now responsible for resolving the proxy's `InetSocketAddress`, and `ProxyParameters` asserts that the address is resolved. The results are plumbed through using a special subclass of `SocketAddress`. If a proxy should be used but the proxy can not be resolved, we the `DnsNameResolver` will re-attempt the resolution later. Remove the unit test testing for unresolved proxy addresses, since it's no longer applicable.
Do not extract the `ProxyParameters` field and pass it into `ClientTransportFactory.newClientTransport`.
This reverts commit 37a5ac4.
This reverts commit 08a904d.
This reverts commit 1c3cfc9.
- PairSocketAddress - use correct DnsNameResolver error handling - let ProxyDetector be passed in as getNameResolverParams
37a5ac4
to
2ac1eea
Compare
@@ -47,12 +49,17 @@ public DnsNameResolver newNameResolver(URI targetUri, Attributes params) { | |||
Preconditions.checkArgument(targetPath.startsWith("/"), | |||
"the path component (%s) of the target (%s) must start with '/'", targetPath, targetUri); | |||
String name = targetPath.substring(1); | |||
// We want to eventually let the ProxyDetector be passed in from ManagedChannel |
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.
I don't see the point of this change until ManagedChannelImpl is actually passing the value. It's small and it's more complex to do it half-way. It also makes an awkward test with testProxyDetectorSpecified. Do this change all-at-once (either now or later).
|
||
@VisibleForTesting | ||
PairSocketAddress(SocketAddress address, Attributes attributes) { | ||
this.address = address; |
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.
checkNotNull for both arguments?
Yes, this PR fixes the unresolved address issue and allows you to use -Dhttps.proxyHost and optionally with a password via |
This PR has two commits, and the second commit has a lot of low
impact code churn due to an internal API cleanup.
First commit:
ProxyDetector should resolve proxy address and plumb results
Second commit:
Plumb
ProxiedInetSocketAddress
down to transportsfixes #4029