Repository navigation
[Overload] Active downstream connections resource monitor - #23361
Conversation
Signed-off-by: Kateryna Nezdolii <[email protected]>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Kateryna Nezdolii <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: Kateryna Nezdolii <[email protected]>
Signed-off-by: Kateryna Nezdolii <[email protected]>
Signed-off-by: Kateryna Nezdolii <[email protected]>
Signed-off-by: Kateryna Nezdolii <[email protected]>
KBaichoo
left a comment
There was a problem hiding this comment.
Thanks for working on this! Here's a first pass
|
|
||
| // The downstream connections resource monitor tracks the global number of open downstream connections. | ||
| message DownstreamConnectionsConfig { | ||
| // Maximum threshold for global open active downstream connections, defaults to 0. |
There was a problem hiding this comment.
I suspect this is just for open downstream connections? e.g. if a connection is idle (not active) (no request, etc.) it will still be counted against this, right?
There was a problem hiding this comment.
Right, the monitor will only track open connections on socket accept (in tcp listener). Good catch.
| deps = [ | ||
| ":downstream_connections_monitor", | ||
| "//envoy/registry", | ||
| "//source/common/common:assert_lib", |
| #include "envoy/extensions/resource_monitors/downstream_connections/v3/downstream_connections.pb.h" | ||
| #include "envoy/server/proactive_resource_monitor.h" | ||
|
|
||
| #include "source/common/common/assert.h" |
There was a problem hiding this comment.
seems unused, here and in cc. If so can we also remove dependency in build?
| int64_t maxResourceUsage() const override; | ||
|
|
||
| protected: | ||
| int64_t max_; |
|
|
||
| bool ActiveDownstreamConnectionsResourceMonitor::tryAllocateResource(int64_t increment) { | ||
| auto current = current_.load(std::memory_order_relaxed); | ||
| while (current + increment <= max_) { |
There was a problem hiding this comment.
can we document the logic here of why this works? Since these primitives can be non-obvious, thanks
|
|
||
| bool ActiveDownstreamConnectionsResourceMonitor::tryDeallocateResource(int64_t decrement) { | ||
| auto current = current_.load(std::memory_order_relaxed); | ||
| while (current - decrement >= 0) { |
| auto factory = | ||
| Registry::FactoryRegistry<Server::Configuration::ProactiveResourceMonitorFactory>::getFactory( | ||
| "envoy.resource_monitors.downstream_connections"); | ||
| ASSERT(factory != nullptr); |
There was a problem hiding this comment.
prefer ASSERT_NE(factory,nullptr) here and below
| // The downstream connections resource monitor tracks the global number of open downstream connections. | ||
| message DownstreamConnectionsConfig { | ||
| // Maximum threshold for global open active downstream connections, defaults to 0. | ||
| // If monitor is configured via Overload manager api and has no value set, Envoy will reject all incoming connections. |
There was a problem hiding this comment.
Does this occur? from https://github.com/envoyproxy/envoy/pull/23361/files#diff-1fdfe762c6263d74ffc5365cd93a44ff14c64adac898bbf1e2de53a3a91e000bR61 seems like we'd reject this config?
| public: | ||
| void initialize(const envoy::extensions::resource_monitors::downstream_connections::v3:: | ||
| DownstreamConnectionsConfig& config) { | ||
| monitor_ = std::make_unique<ActiveDownstreamConnectionsResourceMonitor>(config); |
There was a problem hiding this comment.
what's the reason to not stamp it from the factory that creates these monitors, which better reflects how these would be created in practice? It would also remove edge case of default config (ie. 0 getting through)
There was a problem hiding this comment.
monitor creation through factory is covered by config_test. I followed the pattern of test layout for existing monitors, one test for config & factory and the other one for monitor itself.
| EXPECT_TRUE(monitor_->tryAllocateResource(1)); | ||
| EXPECT_FALSE(monitor_->tryAllocateResource(1)); | ||
| EXPECT_TRUE(monitor_->tryDeallocateResource(1)); | ||
| EXPECT_EQ(0, monitor_->currentResourceUsage()); |
There was a problem hiding this comment.
seems like we test alloc at max, but not dealloc while at min? Can we add that here -- seems like it'd fit what the test case name describes
|
/wait |
Signed-off-by: Kateryna Nezdolii <[email protected]>
|
@KBaichoo applied review comments. Still need to figure out how to fix failing doc check for hidden extension, it's unfortunate that it also blocks all the other checks from running. |
KBaichoo
left a comment
There was a problem hiding this comment.
Thanks for adding this, it looks great (pending CI). Can we get a release note?
|
/wait |
Signed-off-by: Kateryna Nezdolii <[email protected]>
Signed-off-by: Kateryna Nezdolii <[email protected]>
|
Thanks for the suggestion @adisuissa. I tried to replicate the configuration that linked above quic extension is using (comment out extension tag in extension proto+no entry in extensions_metadata.yaml), but CI check failed with: |
|
@KBaichoo should we add release notes & docs at this point, as they are user facing? The extension code is there but monitor is not yet wired with code of tcp listener. It would be wired in next PR. Adding docs/release notes may be confusing for users, they may try to enable the monitor and nothing will happen in terms of limiting the number of downstream conns. |
|
at this point its beyond my power and expertise to fix the failing docs check, all the variants don't work. @phlax do you have any suggestions on path forward? |
beyond noting that the |
almost certainly a good idea - i didnt get to looking at the check specifics yet - but i think we need some way at least for wip/alpha to skip these checks and/or not be included |
hmm, im wondering how that one does it |
|
@nezdolik , whoops you're right, makes sense to wait for it to be fully wired waiting for docs fix. /wait |
apologies for delay on my side - ill look at this first thing next week |
|
after discussion with @phlax on how to overcome CI issue, we agreed to add docs for extension and clearly state that extension is wip and not yet usable. |
|
in addition to any information about the status of the extension that you might want to add - dont forget to add: option (xds.annotations.v3.file_status).work_in_progress = true;... to the proto file - this will add a standard warning to the docs you might need to add: "@com_github_cncf_udpa//xds/annotations/v3:pkg",to the we should probably add to the docs somewhere about adding an extension with WIP code (and/or add to what is there already) |
Signed-off-by: Kateryna Nezdolii <[email protected]>
Signed-off-by: Kateryna Nezdolii <[email protected]>
|
@KBaichoo this is ready for review. |
KBaichoo
left a comment
There was a problem hiding this comment.
nice work, thank you for adding this!
|
ping @markdroth re api shepard review |
|
/lgtm api |

Signed-off-by: Kateryna Nezdolii [email protected]
Thread safe version of Active downstream connections resource monitor based on new proactive checks in overload manager framework. Continuation of work started in this #15707. After this PR is merged, we could replace existing global&per-listener connections tracking mechanism in TCP Listener and plug overload manager downstream connections resource monitor instead.
-->
Commit Message:
Additional Description:
Risk Level: Low (new extension not wired up with existing code)
Testing: Done
Docs Changes:
Release Notes:
Fixes #12419