client-go/reflector: give up on watch-list after incomplete streams #140902
Please note that we're already in Code Freeze for the upcoming v1.37.0 release.
Adding the milestone to this PR is strictly prohibited without proper approval. If this PR needs to be included in the v1.37.0 release:
1. Technical review: get the PR reviewed and approved as usual (/lgtm and /approve)
2. Inclusion in release: ping @sig-release-leads on the #sig-release Slack channel and suggest to add the v1.37.0 milestone to the PR
<a href="https://easycla.lfx.linuxfoundation.org/#/?version=2"><img src="https://s3.amazonaws.com/cla-project-logo-prod/cla-signed.svg?v=2" alt="CLA Signed" align="left" height="28" width="328" ></a><br >The committers listed above are authorized under a signed CLA.<ul><li>:white_check_mark: login: BitWeaverDev / name: BitWeaverDev (04e65c1ec28b01047da4524531f50ab492708400)</li></ul>
This issue is currently awaiting triage.
If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.
The triage/accepted label can be added by org members by writing /triage accepted in a comment.
<details>
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.
</details>
Welcome @BitWeaverDev! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes/kubernetes'>kubernetes/kubernetes</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes/kubernetes has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:
Hi @BitWeaverDev. Thanks for your PR.
I'm waiting for a kubernetes 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.
<details>
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.
</details>
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: <a href="https://github.com/kubernetes/kubernetes/pull/140902#" title="Author self-approved">BitWeaverDev</a>
Once this PR has been reviewed and has the lgtm label, please assign liggitt for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
<details open>
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
</details>
<!-- META={"approvers":["liggitt"]} -->
please sign CNCF CLA and reopen
/close
/reopen
@BitWeaverDev: Reopened this PR.
<details>
In response to this:
>/reopen
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.
</details>
Please note that we're already in Code Freeze for the upcoming v1.37.0 release.
Adding the milestone to this PR is strictly prohibited without proper approval. If this PR needs to be included in the v1.37.0 release:
1. Technical review: get the PR reviewed and approved as usual (/lgtm and /approve)
2. Inclusion in release: ping @sig-release-leads on the #sig-release Slack channel and suggest to add the v1.37.0 milestone to the PR
@BitWeaverDev are you still following up on this PR?
@BitWeaverDev are you still following up on this PR?
Yes waiting for someone to review.
/test
@tamilmani1989: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.
<details>
In response to this:
>/test
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.
</details>
wont 5 mins too long to break retries?
/ok-to-test
@tamilmani1989: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.
<details>
In response to this:
>/ok-to-test
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.
</details>
Yes, and it was worse than just slow. When a stream ends without the bookmark, handleListWatch returns no error, so the loop retries immediately with no backoff. A 5 minute bound meant 5 minutes of back-to-back requests against the broken server. It also matched minWatchTimeout, so a slow stream that hit the server-side timeout would get no retry at all.
I changed it to count incomplete streams instead and give up after 3. Errors that already back off (connection refused, 429) are not counted. The test now checks for exactly 3 attempts before the fallback list.
tamilmani1989
BitWeaverDev
What type of PR is this?
/kind bug
What this PR does / why we need it:
If an aggregated API server accepts a WatchList request, sends some initial
events, and then closes the stream without ever sending the
initial-events-endbookmark,Reflector.watchList()retries thewatch-list request forever inside its own loop. There is no deadline or
retry limit on this path, so a single misbehaving
APIServicecan preventthe informer from ever completing its initial sync.
In the reported incident this happened to one of the per-resource
QuotaMonitorinformers in kube-controller-manager. BecauseQuotaMonitor.IsSynced()requires all of its informers to reportHasSynced(), the ResourceQuota controller's workers never started,ResourceQuota.status.usedwent stale, and new pods were rejected.This PR bounds how many times
watchList()will re-establish watch-listrequests that end without the bookmark. After three such streams, it
returns an error, which the existing code in
ListAndWatchWithContextalready treats as "watch-list didn't work, fall back to a regular list" -
so no changes were needed to the fallback path itself.
Which issue(s) this PR fixes:
Fixes #140890
Special notes for your reviewer:
This PR was written in part with the assistance of generative AI.
The bound counts incomplete streams rather than elapsed time. Those retries
happen with no backoff, so a time bound would hammer the server until it
expired, and a time bound equal to the watch timeout would also leave no
retry for a slow stream that legitimately hit the server-side timeout.
Errors that already back off (connection refused, 429) are not counted.
Does this PR introduce a user-facing change?
``
release-note
``NONE