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

core: omit invalid resource version parameters when doing paged requests #1281

Merged
merged 4 commits into from
Aug 22, 2023

Conversation

goenning
Copy link
Contributor

Motivation

Fix #1278

Solution

This is inspired by what client-go does, which means we don't set the resourceVersionMatch and resourceVersion when the continue param is defined.

I'm not sure if this covers all the scenarios, but it fixed the bug I was seeing.

As an example, if you change the pod_paged example to include .any_semantic(), the response will not be paged. With this PR the response would be paged as expected.

And as per your suggestion, I didn't implement this during the watcher paging loop because it's not exclusive to the watcher functionality, anyone paging with list would have this issue.

@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Merging #1281 (086ef33) into main (d410464) will increase coverage by 0.12%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head 086ef33 differs from pull request most recent head bc1aeac. Consider uploading reports for the commit bc1aeac to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1281      +/-   ##
==========================================
+ Coverage   72.66%   72.78%   +0.12%     
==========================================
  Files          75       75              
  Lines        6186     6196      +10     
==========================================
+ Hits         4495     4510      +15     
+ Misses       1691     1686       -5     
Files Changed Coverage Δ
kube-core/src/params.rs 84.72% <100.00%> (+3.04%) ⬆️
kube-core/src/request.rs 98.74% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

@clux clux added the changelog-fix changelog fix category for prs label Aug 19, 2023
@clux clux added this to the 0.86.0 milestone Aug 19, 2023
@clux clux changed the title fix querystring parameters when doing paged requests core: omit invalid resource version parameters when doing paged requests Aug 19, 2023
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this. Happy to merge this now, but leaving this for a few days in case of comments (also some overlap here with the watchlist pr).

@clux
Copy link
Member

clux commented Aug 19, 2023

Oh, at least need a DCO fix on this @goenning . Deny issue is fixed in main.

Signed-off-by: goenning <me@goenning.net>
@goenning goenning force-pushed the go/fix-paging-params branch 2 times, most recently from 64d78f6 to 1d73dd1 Compare August 19, 2023 18:33
Signed-off-by: goenning <me@goenning.net>
goenning and others added 2 commits August 20, 2023 12:28
Signed-off-by: goenning <me@goenning.net>
@clux clux enabled auto-merge (squash) August 22, 2023 06:03
@clux clux merged commit f44ce00 into kube-rs:main Aug 22, 2023
15 checks passed
Comment on lines +107 to +110
// When there's a continue token, we don't want to set resourceVersion
if let Some(rv) = &self.resource_version {
if rv != "0" || (rv == "0" && self.limit.is_none()) {
qp.append_pair("resourceVersion", rv.as_str());
Copy link
Member

Choose a reason for hiding this comment

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

Going over this again just as a sanity; is this possibly slightly imprecise?

If resourceVersion is "0" with no limit, we end up NOT serialising resourceVersion which puts us in "Most Recent" semantics rather than "Any" semantics. Presumably this was not intended and the resourceVersion should be serialized above the first if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we need to add a test for that too, but as per the snippet above, if rv=0 and the limit is unset, the resourceVersion is serialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-fix changelog fix category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceVersionMatch should be cleared when doing a paged call
2 participants