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

New proxy server counting logic for agent and server #634

Closed
wants to merge 6 commits into from

Conversation

carreter
Copy link
Contributor

@carreter carreter commented Jun 18, 2024

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/servercounter

This package is structured around the ServerCounter interface:

// A ServerCounter counts the number of available proxy servers.
type ServerCounter interface {
	CountServers() int
}

Currently provided are StaticServerCounter, which simply returns a stored int, and CachedServerCounter, which wraps another ServerCounter and provides catching functionality with a configurable cache expiry time.

Proxy server

This PR wires the ServerCounter into the proxy server without changing its behavior by creating a StaticServerCounter with the command-line provided count.

Proxy agent

This PR wires the ServerCounter into the proxy agent without changing its behavior by creating a StaticServerCounter with a default count of 0.

This PR also adds the respectReceivedServerCount field to the agent ClientSet struct. 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 to true by default.

Open questions

Should CountServers() return an error?

Sometimes the ServerCounter will fail to get an updated server count. In this case, we could have CountServers() return (int, error) instead.

I opted against this because we can handle errors in the ServerCounter itself. This simplifies things on the caller side and allows for including a fallback server count in the ServerCounter.

Should ServerCounter include an UpdateCount(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 previous ServerCounter if stored in the same field), and (b) seems like it would have limited use as the ServerCounter should be completely responsible for managing the server count.

A possible workaround is to add the UpdateCount() method to just CachedServerCounter rather than the entire interface. This allows for finer control of caching while maintaining a simple API for the general case.

Should respectReceivedServerCount be true or false by default?

My take: have it true by 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.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 18, 2024
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions 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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: carreter
Once this PR has been reviewed and has the lgtm label, please assign cheftako for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 18, 2024
@carreter
Copy link
Contributor Author

@avrittrohwer for visibility

@jkh52
Copy link
Contributor

jkh52 commented Jun 18, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 18, 2024
@k8s-ci-robot
Copy link
Contributor

@carreter: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-apiserver-network-proxy-make-lint-master d212046 link true /test pull-apiserver-network-proxy-make-lint-master

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.

Instructions 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.

@@ -63,6 +64,8 @@ type ClientSet struct {
warnOnChannelLimit bool

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Should chat on this. During certain events with multiple KASs/Konnectivity servers we can get different server counts from different servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants