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

[WIP]add APIVersion and Kind checks for helper.ToUnstructured() #6028

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zach593
Copy link
Contributor

@zach593 zach593 commented Jan 8, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

This issue blocks me to continue #6017.

In function helper.ToUnstructured(), karmada will convert other types of object to unstructured.Unstructured, but if object is missed TypeMeta, the generated unstructured.Unstructured will also missed APIVersion and Kind, of course in most of the time these are harmful.

Missing TypeMeta objects usually come from typed clients or objects that manually created in code.
In kubernetes issue kubernetes/client-go#541 talked about typed client , looks like these guys won't fix this.

This issue affected many tests, and caused some tests to falsely report success. I fixed all the affected code I could see, but there may be still some I haven't noticed. This may also have an impact in non-test code, which I need to confirm further.

After fixing all the affected codes, I think adding an APIVersion and Kind checks to helper.ToUnstructured() can prevent the impact from expanding further. However, this check obviously needs to be added after ensuring that all the affected codes have been modified to avoid causing a stronger impact.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. labels Jan 8, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kevin-wangzefeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 8, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 26.31579% with 14 lines in your changes missing coverage. Please review.

Project coverage is 48.23%. Comparing base (72b6bd7) to head (3afc187).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
pkg/scheduler/event_handler.go 27.27% 6 Missing and 2 partials ⚠️
pkg/util/helper/unstructured.go 25.00% 4 Missing and 2 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6028      +/-   ##
==========================================
- Coverage   48.37%   48.23%   -0.15%     
==========================================
  Files         665      666       +1     
  Lines       54836    54843       +7     
==========================================
- Hits        26526    26451      -75     
- Misses      26592    26681      +89     
+ Partials     1718     1711       -7     
Flag Coverage Δ
unittests 48.23% <26.31%> (-0.15%) ⬇️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. 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.

3 participants