-
Notifications
You must be signed in to change notification settings - Fork 84
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
network: implement initial heuristic for binding alternate interface #1858
Conversation
b4b79e5
to
4df0c17
Compare
0d2add8
to
e77667d
Compare
4df0c17
to
42da036
Compare
Signed-off-by: Mike Schore <mike.schore@gmail.com>
42da036
to
e3fee16
Compare
Marking ready for review, but with some caveats:
|
Is there somewhere I could read up on what issue this change is attempting to address/improve? |
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
library/common/extensions/retry/options/network_configuration/predicate.cc
Show resolved
Hide resolved
cc @Reflejo |
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.
Very nice to see this coming together and excited to see this land. Flushing out my first pass of comments, thanks.
library/common/extensions/filters/http/network_configuration/filter.cc
Outdated
Show resolved
Hide resolved
library/common/extensions/filters/http/network_configuration/filter.cc
Outdated
Show resolved
Hide resolved
library/common/extensions/filters/http/network_configuration/filter.cc
Outdated
Show resolved
Hide resolved
library/common/extensions/retry/options/network_configuration/predicate.cc
Show resolved
Hide resolved
library/common/extensions/retry/options/network_configuration/predicate.cc
Outdated
Show resolved
Hide resolved
library/common/extensions/retry/options/network_configuration/predicate.cc
Outdated
Show resolved
Hide resolved
library/common/extensions/retry/options/network_configuration/predicate.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
library/common/extensions/retry/options/network_configuration/predicate.cc
Show resolved
Hide resolved
library/common/extensions/filters/http/network_configuration/filter.h
Outdated
Show resolved
Hide resolved
library/common/extensions/retry/options/network_configuration/predicate.cc
Outdated
Show resolved
Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
@mattklein123 I resolved your comments as I addressed them (hopefully you don't mind), since I like to use the GH facility as a checklist of sorts during large updates. Feel free to re-open any of them though if you feel they need further discussion/work. |
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.
Thanks overall looks great. Flushing some more comments from another pass.
library/common/extensions/filters/http/network_configuration/filter.cc
Outdated
Show resolved
Hide resolved
library/common/extensions/retry/options/network_configuration/predicate.cc
Show resolved
Hide resolved
return Upstream::RetryOptionsPredicate::UpdateOptionsReturn{absl::nullopt}; | ||
} | ||
|
||
bool fault = !stream_info.firstUpstreamRxByteReceived().has_value(); |
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.
Perhaps move this and the filter fault calculation into a shared static utility so it's a bit easier to comment above why we are doing various things?
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 added comments to the two locations where we carry out this check (one in the filter, and one in the predicate), but opted not to factor into a shared utility just yet. If this check evolves to become more complicated, and/or we end up calling it from a third place, I'd definitely switch to a shared utility.
library/common/extensions/retry/options/network_configuration/predicate.cc
Show resolved
Hide resolved
* toggle the boolean. For the purpose of this heuristic, a fault is a request that terminates | ||
* having received 0 transmitted bytes, and a success is anything else. |
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.
nit: move this comment to wherever you put the shared calculation logic per my other comments.
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
@mattklein123 thanks for the feedback! Updated again. |
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.
Awesome LGTM to ship and iterate!
Thank you @mattklein123 |
* origin/main: [Apple] Guess string encoding when creating an NSString with UTF8 fails (envoyproxy#1891) Link android dev document in a doctree (envoyproxy#1892) bazel: Remove rules_jvm_external dep on JAVA_HOME (envoyproxy#1890) release: 0.4.3.20211020 (envoyproxy#1887) Add debug instructions and sample bazelproject (envoyproxy#1888) bazel: Use hermetic JDK 11 (envoyproxy#1863) envoy: bump upstream to c687308 (envoyproxy#1886) docs: how to test with local envoy (envoyproxy#1876) network: implement initial heuristic for binding alternate interface (envoyproxy#1858) Assign an int to each log level (envoyproxy#1885) envoy: bump upstream to a5b3af2 (envoyproxy#1884) android: stub out jni logging by default (envoyproxy#1879) CI: Add local JDK to asan/tsan builds (envoyproxy#1878) Make JniBridgeUtility public (envoyproxy#1880) swift: Fix Swift version in podspec (envoyproxy#1875) Signed-off-by: JP Simard <jp@jpsim.com>
Description: Introduces an initial heuristic for attempting a connection using a socket with a bound interface. The heuristic is entirely contained within reportNetworkUsage(...), and as such is straightforward to iterate and experiment upon. In support of the heuristic, current network/configuration state is identified with a configuration_key that prevents stale information from influencing internal tracking.
Current network state is stored and updated automatically.This allows static accessors to begin to report OS updates during Envoy's startup period, and ensures OS updates have a timely effect on new requests.The initial heuristic is as follows:
For both WiFi and cellular network types, there is a default socket configuration that does not use a bound socket, and an alternative "override" configuration that will attempt to use an interface associated with the opposite network type (a cellular-bound socket when the preferred network type is WiFi, and a WiFi-bound socket when network type is cellular).
A "network fault" is defined as a request that terminates in error while having received no upstream bytes.
If a connection has never handled a request without a fault, it is allowed only one fault before the alternative will be tried.
If a connection has ever handled a request without a fault, it is allowed up to three consecutive faults before the alternative will be tried.
The above behavior is disabled by default, and may be enabled by settings enableInterfaceBinding(true) on the public EngineBuilders.
Risk Level: Moderate
Testing: Manual and new/updated coverage
Signed-off-by: Mike Schore mike.schore@gmail.com