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

[yurthub] support cache response for partial object metadata requests。 #2170

Conversation

rambohe-ch
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage

/kind bug

What this PR does / why we need it:

support cache response for partial object metadata requests, like the following request:

curl -H "Accept: application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1" "$API_SERVER/apis/apiextensions.k8s.io/v1/customresourcedefinitions"

Which issue(s) this PR fixes:

Fixes #2121

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

@rambohe-ch
Copy link
Member Author

@vie-serendipity PTAL

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 64.22018% with 39 lines in your changes missing coverage. Please review.

Project coverage is 59.05%. Comparing base (3713163) to head (b92602e).
Report is 42 commits behind head on master.

Files with missing lines Patch % Lines
pkg/yurthub/util/util.go 0.00% 33 Missing ⚠️
pkg/yurthub/proxy/util/util.go 84.61% 3 Missing and 1 partial ⚠️
pkg/yurthub/proxy/autonomy/autonomy.go 0.00% 1 Missing ⚠️
pkg/yurthub/proxy/local/local.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2170      +/-   ##
==========================================
+ Coverage   56.09%   59.05%   +2.95%     
==========================================
  Files         186      211      +25     
  Lines       18092    19070     +978     
==========================================
+ Hits        10149    11261    +1112     
+ Misses       6910     6726     -184     
- Partials     1033     1083      +50     
Flag Coverage Δ
unittests 59.05% <64.22%> (+2.95%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rambohe-ch rambohe-ch force-pushed the support-partialobjectmetadata-requests branch from 3c7c926 to 667a6ee Compare October 14, 2024 22:50
var gvk schema.GroupVersionKind
acceptHeader := req.Header.Get("Accept")
parts := strings.Split(acceptHeader, ";")
for _, part := range parts {
Copy link
Member

Choose a reason for hiding this comment

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

I noticed kubernetes use goautoneg to parse accept, I think that might be better to some corner cases.

clauses := goautoneg.ParseAccept(header)

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

@rambohe-ch rambohe-ch force-pushed the support-partialobjectmetadata-requests branch from 667a6ee to a5601c3 Compare October 20, 2024 10:52
@rambohe-ch rambohe-ch force-pushed the support-partialobjectmetadata-requests branch from a5601c3 to 2c8b065 Compare October 20, 2024 10:55
…, like the following request:

curl -H "Accept: application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1" "$API_SERVER/apis/apiextensions.k8s.io/v1/customresourcedefinitions"

Signed-off-by: rambohe-ch <[email protected]>
@rambohe-ch rambohe-ch force-pushed the support-partialobjectmetadata-requests branch from 2c8b065 to b92602e Compare October 20, 2024 11:20
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
13.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@vie-serendipity
Copy link
Member

/LGTM @rambohe-ch

@zyjhtangtang zyjhtangtang merged commit 09b1ab1 into openyurtio:master Oct 21, 2024
12 of 13 checks passed
zyjhtangtang pushed a commit to zyjhtangtang/openyurt that referenced this pull request Oct 23, 2024
…, like the following request: (openyurtio#2170)

curl -H "Accept: application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1" "$API_SERVER/apis/apiextensions.k8s.io/v1/customresourcedefinitions"

Signed-off-by: rambohe-ch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question] Does yurthub support to local proxy for customresourcedefinitions (CRDs) ?
3 participants