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

add cache source annotation for objects returned by proxy #2469

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

ikaven1024
Copy link
Member

@ikaven1024 ikaven1024 commented Sep 2, 2022

Signed-off-by: yingjinhui yingjinhui@didiglobal.com

What type of PR is this?
/kind feature

What this PR does / why we need it:

  1. add annotation resource.karmada.io/cached-from-cluster to objects returned by proxy, staying the same with search.
  2. fix updating objects returns invalid resourceVersion error.

Which issue(s) this PR fixes:
Fixes #2463

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-search`: objects returned by proxy will have `resource.karmada.io/cached-from-cluster` annotation to indicate which member cluster from. 

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 2, 2022
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 2, 2022
@RainbowMango
Copy link
Member

/assign @XiShanYongYe-Chang

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/cluster_proxy.go Show resolved Hide resolved
return nil, err
}

if requestInfo.Verb != "update" {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a possibility that the verb is patch?

Copy link
Member Author

Choose a reason for hiding this comment

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

Users will not patch resourceVersion and cached source annotation.

@@ -205,6 +208,12 @@ func (c *MultiClusterCache) List(ctx context.Context, gvr schema.GroupVersionRes
if err != nil {
return 0, "", err
}

for i := range extractList {
// TODO: add annotation will modify the object in cache, shall we deep copy it? The modification seems not bad.
Copy link
Member

Choose a reason for hiding this comment

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

If so, this todo can be removed and can be updated with comment.


deleteAnnotationAfterTest = func(c kubernetes.Interface, name string, anno string) {
data := []byte(`{"metadata": {"annotations": {"` + anno + `":null}}}`)
_, _ = c.CoreV1().Nodes().Patch(context.TODO(), name, types.StrategicMergePatchType, data, metav1.PatchOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

The patch verb may fail in the CI environment.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean throw the patch error? IMO, this is just a clean method, error can be ignored. I will add a log to print this error.

}, time.Second*10, 0).Should(gomega.BeTrue())

gomega.Expect(get.Annotations[clusterv1alpha1.CacheSourceAnnotationKey]).Should(gomega.Equal(member1))
Copy link
Member

Choose a reason for hiding this comment

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

After this line maybe also need to deleteAnnotationAfterTest

Signed-off-by: yingjinhui <yingjinhui@didiglobal.com>
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~

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 7, 2022
@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 Sep 7, 2022
@karmada-bot karmada-bot merged commit 958f381 into karmada-io:master Sep 7, 2022
@XiShanYongYe-Chang
Copy link
Member

Hi @ikaven1024, can you help update the release-note to:

karmada-search: objects returned by proxy will have `resource.karmada.io/cached-from-cluster` to indicate which member cluster from.

@RainbowMango
Copy link
Member

I update the kind from feature to bug.

karmada-bot added a commit that referenced this pull request Sep 15, 2022
#2483-#2490-#2501-upstream-release-1.3

Automated cherry pick of #2469: add cache source annotation for objects returned by proxy
#2483: fix concurrent map writes panic while list via proxy
#2490: add wait for proxy ready
#2501: fix flaking test: search proxy get node report not found
@RainbowMango RainbowMango added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Nov 29, 2022
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/feature Categorizes issue or PR as related to a new feature. 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.

Add cluster annotation to proxying objects
4 participants