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

fix paging list in karmada search proxy #3402

Merged
merged 1 commit into from
Apr 23, 2023

Conversation

ikaven1024
Copy link
Member

@ikaven1024 ikaven1024 commented Apr 12, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:
When paging query via karmada search proxy, if member cluster resources number is larger than page size (limit), the return resourceVersion and continue is not incorrect.

For example, there are two member clusters:

Cluster1 Cluster2
RV 123 456
Pods 10 10

And client request with:

/apis/search.karmada.io/v1alpha1/proxying/karmada/proxy/api/v1/namespaces/default/pods?limit=5

Incomplete resourceVersion
got:{"cluster1":"123"} (decoded), while want {"cluster1":"123","cluster2":"456"}

Unreasonable continue
There's no resource version in continue, and next page query will got a wrong rv.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-search`: Fixed paging list in karmada search proxy in large-scale member clusters issue.

@karmada-bot karmada-bot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Apr 12, 2023
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 12, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2023

Codecov Report

Merging #3402 (8924521) into master (ef774d2) will increase coverage by 0.31%.
The diff coverage is 80.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3402      +/-   ##
==========================================
+ Coverage   51.63%   51.95%   +0.31%     
==========================================
  Files         210      210              
  Lines       18926    19077     +151     
==========================================
+ Hits         9772     9911     +139     
+ Misses       8622     8617       -5     
- Partials      532      549      +17     
Flag Coverage Δ
unittests 51.95% <80.00%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/search/proxy/store/util.go 91.81% <66.66%> (-2.50%) ⬇️
pkg/search/proxy/store/multi_cluster_cache.go 76.92% <81.13%> (+2.47%) ⬆️

... and 10 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@karmada-bot karmada-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 14, 2023
@ikaven1024
Copy link
Member Author

Test client:

factory := informers.NewSharedInformerFactoryWithOptions(c, 0, informers.WithTweakListOptions(func(options *metav1.ListOptions) {
	options.Limit = 5
}))

factory.Core().V1().Pods().Informer()

factory.Start(stopCh)
factory.WaitForCacheSync(stopCh)

Logs in search:

I0415 02:35:46.322963   58010 multi_cluster_cache.go:171] Request list /v1, Resource=pods with rv=&store.multiClusterResourceVersion{rvs:map[string]string{}, isZero:true} cont=store.multiClusterContinue{RV:"", Cluster:"", Continue:""}, limit=5
I0415 02:35:46.325858   58010 multi_cluster_cache.go:425] fillMissingClusterResourceVersion gvr=/v1, Resource=pods cluster=kwok-cluster2
I0415 02:35:46.326377   58010 multi_cluster_cache.go:184] Response list /v1, Resource=pods with rv=&store.multiClusterResourceVersion{rvs:map[string]string{"kwok-cluster1":"121450", "kwok-cluster2":"121618"}, isZero:false} continue=store.multiClusterContinue{RV:"eyJrd29rLWNsdXN0ZXIxIjoiMTIxNDUwIiwia3dvay1jbHVzdGVyMiI6IjEyMTYxOCJ9", Cluster:"kwok-cluster2", Continue:""}
I0415 02:35:46.334693   58010 multi_cluster_cache.go:171] Request list /v1, Resource=pods with rv=&store.multiClusterResourceVersion{rvs:map[string]string{}, isZero:false} cont=store.multiClusterContinue{RV:"eyJrd29rLWNsdXN0ZXIxIjoiMTIxNDUwIiwia3dvay1jbHVzdGVyMiI6IjEyMTYxOCJ9", Cluster:"kwok-cluster2", Continue:""}, limit=5
I0415 02:35:46.346554   58010 multi_cluster_cache.go:184] Response list /v1, Resource=pods with rv=&store.multiClusterResourceVersion{rvs:map[string]string{"kwok-cluster1":"121450", "kwok-cluster2":"121618"}, isZero:false} continue=store.multiClusterContinue{RV:"eyJrd29rLWNsdXN0ZXIxIjoiMTIxNDUwIiwia3dvay1jbHVzdGVyMiI6IjEyMTYxOCJ9", Cluster:"kwok-cluster2", Continue:"eyJ2IjoibWV0YS5rOHMuaW8vdjEiLCJydiI6MTIxNjE4LCJzdGFydCI6ImRlZmF1bHQvbmdpbngyLTc4NTk4NjRiNjgtajZiNTZcdTAwMDAifQ"}
I0415 02:35:46.349324   58010 multi_cluster_cache.go:171] Request list /v1, Resource=pods with rv=&store.multiClusterResourceVersion{rvs:map[string]string{}, isZero:false} cont=store.multiClusterContinue{RV:"eyJrd29rLWNsdXN0ZXIxIjoiMTIxNDUwIiwia3dvay1jbHVzdGVyMiI6IjEyMTYxOCJ9", Cluster:"kwok-cluster2", Continue:"eyJ2IjoibWV0YS5rOHMuaW8vdjEiLCJydiI6MTIxNjE4LCJzdGFydCI6ImRlZmF1bHQvbmdpbngyLTc4NTk4NjRiNjgtajZiNTZcdTAwMDAifQ"}, limit=5
I0415 02:35:46.353498   58010 multi_cluster_cache.go:184] Response list /v1, Resource=pods with rv=&store.multiClusterResourceVersion{rvs:map[string]string{"kwok-cluster1":"121450", "kwok-cluster2":"121618"}, isZero:false} continue=store.multiClusterContinue{RV:"eyJrd29rLWNsdXN0ZXIxIjoiMTIxNDUwIiwia3dvay1jbHVzdGVyMiI6IjEyMTYxOCJ9", Cluster:"", Continue:""}
I0415 02:35:46.357867   58010 multi_cluster_cache.go:303] Request watch /v1, Resource=pods with rv=eyJrd29rLWNsdXN0ZXIxIjoiMTIxNDUwIiwia3dvay1jbHVzdGVyMiI6IjEyMTYxOCJ9

@ikaven1024 ikaven1024 changed the title [WIP]fill cluster rv in proxying list fix paging list in karmada search proxy Apr 14, 2023
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 14, 2023
@ikaven1024
Copy link
Member Author

/assign @XiShanYongYe-Chang

Copy link

@nulls-cell nulls-cell left a comment

Choose a reason for hiding this comment

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

add some comment .

@RainbowMango
Copy link
Member

Echo test log here before retesting:
https://github.com/karmada-io/karmada/actions/runs/4706573878/jobs/8347964144?pr=3402

Timeline >>
  STEP: Creating ClusterPropagationPolicy(clusterrole-fxvgb) @ 04/15/23 07:35:04.617
  STEP: Creating ClusterRole(clusterrole-fxvgb) @ 04/15/23 07:35:04.639
  [FAILED] in [It] - /home/runner/work/karmada/karmada/test/e2e/framework/rbac.go:158 @ 04/15/23 07:42:14.732
  STEP: Removing ClusterPropagationPolicy(clusterrole-fxvgb) @ 04/15/23 07:42:14.732
  STEP: Remove ClusterRole(clusterrole-fxvgb) @ 04/15/23 07:42:14.746
  << Timeline

  [FAILED] Timed out after 420.000s.
  Expected
      <bool>: false
  to equal
      <bool>: true
  In [It] at: /home/runner/work/karmada/karmada/test/e2e/framework/rbac.go:158 @ 04/15/23 07:42:14.732

  Full Stack Trace
    github.com/karmada-io/karmada/test/e2e/framework.WaitClusterRoleDisappearOnCluster({0x3fd9ec4, 0x7}, {0xc0009d8618, 0x11})
    	/home/runner/work/karmada/karmada/test/e2e/framework/rbac.go:158 +0x556
    github.com/karmada-io/karmada/test/e2e.glob..func2.2.1.4()
    	/home/runner/work/karmada/karmada/test/e2e/clusteraffinities_test.go:257 +0x2ab
------------------------------
[SynchronizedAfterSuite] PASSED [0.009 seconds]
[SynchronizedAfterSuite] 
/home/runner/work/karmada/karmada/test/e2e/suite_test.go:137
------------------------------
• [INTERRUPTED] [0.082 seconds]
Resource interpreter customization testing when Apply single ResourceInterpreterCustomization without DependencyInterpretation operation [JustBeforeEach] InterpreterOperation InterpretStatus testing InterpretStatus 

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks~

pkg/search/proxy/store/multi_cluster_cache.go Outdated Show resolved Hide resolved
Comment on lines +431 to +446
if rv == "" {
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Just a question: when the rv is empty, will an error occur when the whole rv is displayed at the end because the rv of a cluster is empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the missing cluster is not nested in the multi cluster rv

@@ -125,6 +136,7 @@ func marshalRvs(rvs map[string]string) []byte {
}

type multiClusterContinue struct {
RV string `json:"rv"`
Copy link
Member

Choose a reason for hiding this comment

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

Is this change a user-facing change?

Copy link
Member Author

Choose a reason for hiding this comment

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

User will receive a encoded string. In principle users shall only regard it as a string, and don't care what the playload in it.

Signed-off-by: yingjinhui <yingjinhui@didiglobal.com>
@XiShanYongYe-Chang
Copy link
Member

Thanks a lot
/approve

Ask again review from @liblikewhen
/cc @liblikewhen

@karmada-bot karmada-bot requested a review from nulls-cell April 20, 2023 12:14
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: XiShanYongYe-Chang

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 20, 2023
@XiShanYongYe-Chang
Copy link
Member

/lgtm

I think we need to rebase it to the previous branch, @ikaven1024 can you help do it?

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2023
@karmada-bot karmada-bot merged commit 3812616 into karmada-io:master Apr 23, 2023
@RainbowMango
Copy link
Member

Do you mean cherry-pick?

@XiShanYongYe-Chang
Copy link
Member

Do you mean cherry-pick?

Yes, it is.

@ikaven1024
Copy link
Member Author

Do you mean cherry-pick?

Yes, it is.

1.4 & 1.5 is ready:
#3449
#3450

1.3: TODO

karmada-bot added a commit that referenced this pull request Apr 23, 2023
…02-upstream-release-1.5

Automated cherry pick of #3402: fill cluster rv in proxying list
karmada-bot added a commit that referenced this pull request Apr 23, 2023
…02-upstream-release-1.4

Automated cherry pick of #3402: fill cluster rv in proxying list
karmada-bot added a commit that referenced this pull request Apr 24, 2023
…02-upstream-release-1.3

Automated cherry pick of #3402: fill cluster rv in proxying list
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. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants