openyurtio / openyurt

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)
https://openyurt.io
Apache License 2.0
1.68k stars 388 forks source link

improve independent webhook #2078

Closed rambohe-ch closed 2 weeks ago

rambohe-ch commented 2 weeks ago

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 enhancement

What this PR does / why we need it:

Because of Group is empty for node and pod resource, so webhook paths are not registered correctly. The detail logs are as following:

I0618 03:23:08.492989       1 webhook.go:158] controller-runtime/builder "msg"="Registering a mutating webhook" "GVK"={"Group":"","Version":"v1","Kind":"Node"} "path"="/mutate--v1-node"
I0618 03:23:08.493039       1 server.go:183] controller-runtime/webhook "msg"="Registering webhook" "path"="/mutate--v1-node"
I0618 03:23:08.493061       1 webhook.go:189] controller-runtime/builder "msg"="Registering a validating webhook" "GVK"={"Group":"","Version":"v1","Kind":"Node"} "path"="/validate--v1-node"
I0618 03:23:08.493085       1 server.go:183] controller-runtime/webhook "msg"="Registering webhook" "path"="/validate--v1-node

so add a new func named RegisterIndependentWebhook to deal with these kind of webhook registration.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

other Note

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.15%. Comparing base (3713163) to head (8d3d5f4). Report is 4 commits behind head on master.

Files Patch % Lines
pkg/yurtmanager/webhook/node/v1/node_handler.go 0.00% 1 Missing :warning:
...kg/yurtmanager/webhook/pod/v1alpha1/pod_handler.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2078 +/- ## ========================================== + Coverage 56.09% 56.15% +0.05% ========================================== Files 186 186 Lines 18092 18073 -19 ========================================== - Hits 10149 10148 -1 + Misses 6910 6894 -16 + Partials 1033 1031 -2 ``` | [Flag](https://app.codecov.io/gh/openyurtio/openyurt/pull/2078/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/openyurtio/openyurt/pull/2078/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio) | `56.15% <0.00%> (+0.05%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openyurtio#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

zyjhtangtang commented 2 weeks ago

/LGTM

zyjhtangtang commented 2 weeks ago

/LGTM