Skip to content

Handle consistent LIST in watch cache to avoid incorrect semantics while setting ResourceVersion on options #132150

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

Merged

Conversation

serathius
Copy link
Contributor

@serathius serathius commented Jun 6, 2025

/kind cleanup

Cleanup after discovery of #132132 and fix #132244

This PR should make the code easier to understand.

Due to Snapshots from cache feature the watch cache started classifying consistent read with limit as legacy exact read. This is because the delegator incorrectly assumed that it can transform consistent read to notOlderThan request.

NONE

@serathius serathius force-pushed the watchcache-consistent-list branch from 5f8422a to 3643a09 Compare June 6, 2025 15:20
@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/regression Categorizes issue or PR as related to a regression from a prior release. kind/bug Categorizes issue or PR as related to a bug. 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 Jun 6, 2025
@k8s-ci-robot k8s-ci-robot requested review from deads2k and enj June 6, 2025 15:20
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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 Jun 6, 2025
@serathius
Copy link
Contributor Author

/assign @wojtek-t

@dims
Copy link
Member

dims commented Jun 6, 2025

/test pull-kubernetes-conformance-kind-ga-only-parallel

@dims
Copy link
Member

dims commented Jun 6, 2025

@serathius i was playing with some test cases in case you find them useful - https://paste.openstack.org/show/bzSa1WUIAn2VlRyEAo4g/

I did not understand one scenario what would/should happen (see "too high RV, exact match" - line 220->227), the test hangs if i uncomment those lines.

@serathius
Copy link
Contributor Author

/retest

@serathius serathius force-pushed the watchcache-consistent-list branch 2 times, most recently from 2309b58 to 0531f05 Compare June 7, 2025 07:15
@serathius serathius force-pushed the watchcache-consistent-list branch from 0531f05 to 307c930 Compare June 7, 2025 08:26
@serathius
Copy link
Contributor Author

/triage accepted
/priority critical-urgent

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jun 9, 2025
@k8s-ci-robot k8s-ci-robot added priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed 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 Jun 9, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 16, 2025
@serathius serathius force-pushed the watchcache-consistent-list branch from 307c930 to 1ca8754 Compare June 16, 2025 21:28
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 16, 2025
@serathius serathius force-pushed the watchcache-consistent-list branch from 1ca8754 to 4cb6d3d Compare June 16, 2025 22:11
@k8s-ci-robot k8s-ci-robot added the sig/etcd Categorizes an issue or PR as relevant to SIG Etcd. label Jun 16, 2025
@serathius serathius force-pushed the watchcache-consistent-list branch from 4cb6d3d to 1ca8754 Compare June 16, 2025 22:12
@serathius
Copy link
Contributor Author

PTAL @wojtek-t

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 18, 2025
@serathius serathius force-pushed the watchcache-consistent-list branch 2 times, most recently from f806007 to 2421ab2 Compare June 26, 2025 07:29
@serathius serathius force-pushed the watchcache-consistent-list branch from 2421ab2 to 292679a Compare June 26, 2025 07:30
Copy link
Member

@wojtek-t wojtek-t left a comment

Choose a reason for hiding this comment

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

Thanks - this is much easier to reason about for me!

Just one minor nit - other than that LGTM

@@ -3495,7 +3495,7 @@ func TestListIndexer(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pred := storagetesting.CreatePodPredicate(tt.fieldSelector, true, tt.indexFields)
_, usedIndex, err := cacher.cacher.listItems(ctx, 0, "/pods/"+tt.requestedNamespace, storage.ListOptions{Predicate: pred, Recursive: tt.recursive})
_, usedIndex, err := cacher.cacher.watchCache.WaitUntilFreshAndGetList(ctx, "/pods/"+tt.requestedNamespace, storage.ListOptions{Predicate: pred, Recursive: tt.recursive})
Copy link
Member

Choose a reason for hiding this comment

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

nit: let use cacher.cache.List(ctx, ...) instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cacher.cache.GetList(ctx, ...) doesn't return Index used. We could create dedicated function for that on cacher, however at this point this is more watchCache test that also validates if cacher passes the Index config to watchCache correctly.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Let's leave as is then.

@wojtek-t
Copy link
Member

/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 Jun 26, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 84e45cf6a6801d7ccc020782044305cc576d703c

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: serathius, wojtek-t

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 Jun 26, 2025
@k8s-ci-robot k8s-ci-robot merged commit 24d9d18 into kubernetes:master Jun 26, 2025
12 of 13 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.34 milestone Jun 26, 2025
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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. 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. sig/etcd Categorizes an issue or PR as relevant to SIG Etcd. 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.

4 participants