kubewarden / kubewarden-controller

Manage admission policies in your Kubernetes cluster with ease
https://kubewarden.io
Apache License 2.0
195 stars 33 forks source link

fix: do not exit when k8s' matchConditions are not available #901

Closed flavio closed 1 month ago

flavio commented 1 month ago

Do not exit with an error when the matchConditions field is not available for ValidatingWebhookConfiguration and MutatingWebhookConfiguration.

The code is already structured to work when this feature is not available, hence we don't have to cause the controller to exit with an error.

Fixes https://github.com/kubewarden/kubewarden-controller/issues/900

flavio commented 1 month ago

CC @williamlin-suse

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 70.65%. Comparing base (4be87f4) to head (f05f8aa). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #901 +/- ## ========================================== + Coverage 70.53% 70.65% +0.11% ========================================== Files 30 30 Lines 2559 2559 ========================================== + Hits 1805 1808 +3 + Misses 584 582 -2 + Partials 170 169 -1 ``` | [Flag](https://app.codecov.io/gh/kubewarden/kubewarden-controller/pull/901/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubewarden) | Coverage Δ | | |---|---|---| | [integration-tests](https://app.codecov.io/gh/kubewarden/kubewarden-controller/pull/901/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubewarden) | `60.43% <ø> (+0.11%)` | :arrow_up: | | [unit-tests](https://app.codecov.io/gh/kubewarden/kubewarden-controller/pull/901/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kubewarden) | `39.21% <ø> (ø)` | | 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=kubewarden#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.

viccuad commented 1 month ago

For completion, the check performed in CheckAdmissionWebhookMatchConditions() may fail indeed, as we are using OpenAPIV3 to query the cluster. This Kubernetes feature is alpha since 1.23 (and may not be enabled), yet only GA since 1.27. But we shouldn't halt indeed if there's an error.