New proxy server counting logic for agent and server#634
New proxy server counting logic for agent and server#634carreter wants to merge 6 commits intokubernetes-sigs:masterfrom
Conversation
|
Hi @carreter. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: carreter The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@avrittrohwer for visibility |
|
/ok-to-test |
|
@carreter: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
|
||
| syncForever bool // Continue syncing (support dynamic server count). | ||
|
|
||
| respectReceivedServerCount bool // Respect server count received from proxy server rather than relying on the agent's own server counter |
There was a problem hiding this comment.
Should chat on this. During certain events with multiple KASs/Konnectivity servers we can get different server counts from different servers.
There was a problem hiding this comment.
Yeah, @avrittrohwer also raised this issue. One potential solution would be to cache the last n received server counts and take the highest value. Ultimately this gets solved by having proxy agents count the leases themselves.
An initial pass at the groundwork for #358 and #273 (i.e. allowing a dynamic proxy server count on both the server and the agent in a backwards-compatible manner). Currently a draft, depends on #632. Design doc here.
Changes
New package:
pkg/servercounterThis package is structured around the
ServerCounterinterface:Currently provided are
StaticServerCounter, which simply returns a stored int, andCachedServerCounter, which wraps anotherServerCounterand provides catching functionality with a configurable cache expiry time.Proxy server
This PR wires the
ServerCounterinto the proxy server without changing its behavior by creating aStaticServerCounterwith the command-line provided count.Proxy agent
This PR wires the
ServerCounterinto the proxy agent without changing its behavior by creating aStaticServerCounterwith a default count of 0.This PR also adds the
respectReceivedServerCountfield to the agentClientSetstruct. This field toggles whether the server count received from the proxy server should overwrite the proxy agent's server counter. Since I didn't want to change the behavior of the agent yet, this is set totrueby default.Open questions
Should
CountServers()return anerror?Sometimes the
ServerCounterwill fail to get an updated server count. In this case, we could haveCountServers()return(int, error)instead.I opted against this because we can handle errors in the
ServerCounteritself. This simplifies things on the caller side and allows for including a fallback server count in theServerCounter.Should
ServerCounterinclude anUpdateCount(int)method?It might be useful for clients to (a) temporarily override the server count or (b) request an update to any cached server counts. They could do this by calling
UpdateCount()with a non-negative value to temporarily override the count or with -1 to reset the override and request a count update.I opted against this because the client can accomplish (a) using a
StaticServerCounter(downside: this overwrites the previousServerCounterif stored in the same field), and (b) seems like it would have limited use as theServerCountershould be completely responsible for managing the server count.A possible workaround is to add the
UpdateCount()method to justCachedServerCounterrather than the entire interface. This allows for finer control of caching while maintaining a simple API for the general case.Should
respectReceivedServerCountbetrueorfalseby default?My take: have it
trueby default unless an alternative server count method is provided in the commandline args to the proxy agent. This ensures backwards compatibility with old proxy servers.