Skip to content

test: validate that watchers close without error #131505

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

karlkfi
Copy link
Contributor

@karlkfi karlkfi commented Apr 28, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  • Add channel test helpers to k8s.io/client-go/util/testing
  • Use the new channel test helpers in the client and server watch tests to validate that the result channels closes without error when the client stops the watcher.
  • Use the new channel test helpers in the client watcher decoder tests to validate that encoded watch events can be decoded and that the decoder errors with EOF when stopped asynchronously.

These new tests uncovered existing errors (added TODOs):

  1. The watch client doesn't close the response body when it encounters a NegotiateError.
  2. The watch client sometimes sends a decode error on the result channel after the client watcher has been stopped.
  3. StreamWatcher.receive uses %v instead of %w when wrapping errors.

Does this PR introduce a user-facing change?

NONE

Dependencies

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/flake Categorizes issue or PR as related to a flaky test. 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. area/apiserver 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 Apr 28, 2025
@karlkfi karlkfi force-pushed the karl-watcher-closed-tests branch 2 times, most recently from b35e574 to c055de6 Compare April 28, 2025 04:29
@karlkfi
Copy link
Contributor Author

karlkfi commented Apr 28, 2025

/assign @wojtek-t

@siyuanfoundation
Copy link
Contributor

/cc @siyuanfoundation @serathius

/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 Apr 29, 2025
@karlkfi karlkfi changed the title test: validate that watchers close without error [WIP] test: validate that watchers close without error May 1, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 1, 2025
@karlkfi
Copy link
Contributor Author

karlkfi commented May 1, 2025

Blocking this on #131457, which covers closing response body a bit more cleanly and robustly. This can be rebased later to cover channel close and draining

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 10, 2025
@karlkfi karlkfi force-pushed the karl-watcher-closed-tests branch from c055de6 to 2a05e10 Compare May 19, 2025 22:51
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: karlkfi
Once this PR has been reviewed and has the lgtm label, please ask for approval from wojtek-t. For more information see the 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

@karlkfi karlkfi changed the title [WIP] test: validate that watchers close without error test: validate that watchers close without error May 19, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 19, 2025
@karlkfi
Copy link
Contributor Author

karlkfi commented May 19, 2025

/remove-kind flake

This doesn't fix flakes, but does identify one as TODO.

@k8s-ci-robot k8s-ci-robot removed the kind/flake Categorizes issue or PR as related to a flaky test. label May 19, 2025
- Add channel test helpers to k8s.io/client-go/util/testing
- Use the new channel test helpers in the client and server watch
  tests to validate that the result channels closes without error
  when the client stops the watcher.
- Use the new channel test helpers in the client watcher decoder
  tests to validate that encoded watch events can be decoded and
  that the decoder errors with EOF when stopped asynchronously.

These new tests uncovered existing errors (added TODOs):
1.  The watch client doesn't close the response body when it
    encounters a NegotiateError.
2.  The watch client sometimes sends a decode error on the result
    channel after the client watcher has been stopped.
3.  StreamWatcher.receive uses %v instead of %w when wrapping errors.
@karlkfi karlkfi force-pushed the karl-watcher-closed-tests branch from 2a05e10 to f17abda Compare May 19, 2025 23:49
@karlkfi
Copy link
Contributor Author

karlkfi commented May 20, 2025

tests passed. ready for review.

@karlkfi
Copy link
Contributor Author

karlkfi commented May 29, 2025

@wojtek-t can you take a look at this? Do you need me to break it up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XL Denotes a PR that changes 500-999 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.

4 participants