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

rate limite etcd healthcheck request #112046

Merged
merged 3 commits into from Sep 12, 2022
Merged

Conversation

aojea
Copy link
Member

@aojea aojea commented Aug 25, 2022

/kind bug

What this PR does / why we need it:

Etcd healthcheck create one request to etcd per healthcheck requested, this can cause an excessive traffic going from apiserver to etcd.

Implement a rate limiter based on the configured timeout of the healthcheck, so all connections that are rate limited return the last known value.

apiserver /healthz/etcd endpoint rate limits the number of forwarded health check requests to the etcd backends, answering with the last known state if the rate limit is exceeded. The rate limit is based on 1/2 of the timeout configured, with no burst allowed.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 25, 2022
@aojea
Copy link
Member Author

aojea commented Aug 25, 2022

/assign @deads2k @soltysh @tkashem

I think that this is a better solution for the etcd healthzchecks, I'm not familiar with the code so I plumbed it here, but it can go directly into the etcd healthcheck

Looking for feedback first, I will add tests if this is an acceptable solution

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 25, 2022
@aojea
Copy link
Member Author

aojea commented Aug 25, 2022

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 25, 2022
@aojea
Copy link
Member Author

aojea commented Aug 26, 2022

🤔 👀

/test pull-kubernetes-integration

@liggitt
Copy link
Member

liggitt commented Aug 26, 2022

the etcd check specifically was attempted to be made non-blocking in #104437, but that didn't get completed

@aojea
Copy link
Member Author

aojea commented Aug 26, 2022

/test pull-kubernetes-integration

1 similar comment
@aojea
Copy link
Member Author

aojea commented Aug 26, 2022

/test pull-kubernetes-integration

@aojea
Copy link
Member Author

aojea commented Aug 28, 2022

the etcd check specifically was attempted to be made non-blocking in #104437, but that didn't get completed

let's target the etcd check specifically, I've also found a bug in current logic

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 28, 2022
@k8s-ci-robot k8s-ci-robot added the area/dependency Issues or PRs related to dependency changes label Aug 29, 2022
@aojea
Copy link
Member Author

aojea commented Aug 29, 2022

/assign @liggitt @lavalamp

as original reviewers of #104437

stop leaking goroutines

reduce etcd test duration
return the last request error, instead of last error received
The rate limit allows 1 event per healthcheck timeout / 2
@lavalamp
Copy link
Member

I think this is ready to go as long as we don't make N separate checkers...

@leilajal
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 30, 2022
@aojea
Copy link
Member Author

aojea commented Sep 10, 2022

I think this is ready to go as long as we don't make N separate checkers...

kindly ping @lavalamp #112046 (comment)

@lavalamp
Copy link
Member

Sorry I missed your last update.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 12, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, lavalamp

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2022
@lavalamp
Copy link
Member

If you can figure out an easy way to count how many health checks this does in e.g. our e2e tests before/after this change, and the difference is very large, a backport might be reasonable.

(Do we scrape etcd metrics at the test end? That would be the first place I'd look. This might not be super easy to measure.)

@k8s-ci-robot k8s-ci-robot merged commit 0f37b31 into kubernetes:master Sep 12, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Sep 12, 2022
@aojea
Copy link
Member Author

aojea commented Sep 13, 2022

(Do we scrape etcd metrics at the test end? That would be the first place I'd look. This might not be super easy to measure.)

Mike Spreitzer added tooling to dump the metrics of etcd on the integration tests (all test share the same etcd instance)
You just download the tarball with the mtrics

wget https://storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/112252/pull-kubernetes-integration/1568270000328806400/artifacts/etcd-scrapes.tgz

and run the script he created pointing to the file

$HOME/go/src/k8s.io/kubernetes/hack/run-prometheus-on-etcd-scrapes.sh etcd-scrapes.tgz

I didn't find any metrics that shows the number of Get received on the healthz endpoint, or something that can give us an idea ... I've compared a dumped version from before and other from after this patch and I couldn't find any significant difference-

I don't think that our e2e abuse the /healthz/etcd endpoint , it seems Openshift does much more stress on the endpoint and that's why we were carrying over with David's patch

@lavalamp
Copy link
Member

OK, thanks for checking!

@wojtek-t
Copy link
Member

I missed that originally - but this looks great - I'm really happy that you made that happen.

Re @lavalamp questions - i don't think we would find anything in our tests (which don't overload any of the endpoints FWICT), but it certainly can help protecting some real-world scenarios.
But I don't think I can come up with a justifying argument for backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/dependency Issues or PRs related to dependency changes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants