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

refactor: simplify wehbook configuration controller handlers #894

Conversation

fabriziosestito
Copy link
Contributor

@fabriziosestito fabriziosestito commented Sep 24, 2024

Description

Before this change, we leveraged several annotations to check if a WebhookConfiguration was related to the type of policy managed by a controller.
For instance, the scope and group annotations were used to check if a policy was cluster or namespace scoped and if it was a group.
When adding PolicyGroups we realized that it was hard to maintain multiple annotations.

This PR simplifies the WebhookConfiguration controller handlers, by using just two annotations (name and namespace) and by using the client to check if the resource of a certain type exists.
This is ok regarding performance and API server load since the request is cached.

and returning a reconcile request.

@fabriziosestito fabriziosestito self-assigned this Sep 24, 2024
@fabriziosestito fabriziosestito added this to the 1.18 milestone Sep 24, 2024
@fabriziosestito fabriziosestito force-pushed the refactor/simplify-webhook-configuation-controller-handlers branch from e921c46 to c50360c Compare September 24, 2024 12:49
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.27%. Comparing base (141a393) to head (281414e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
- Coverage   69.33%   69.27%   -0.06%     
==========================================
  Files          30       30              
  Lines        3052     3040      -12     
==========================================
- Hits         2116     2106      -10     
+ Misses        769      767       -2     
  Partials      167      167              
Flag Coverage Δ
integration-tests 58.20% <100.00%> (-0.10%) ⬇️
unit-tests 40.41% <ø> (ø)

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.

Copy link
Member

@flavio flavio left a comment

Choose a reason for hiding this comment

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

Thanks an interesting approach. Are there consequences caused by using a field indexer?

@fabriziosestito
Copy link
Contributor Author

Thanks an interesting approach. Are there consequences caused by using a field indexer?

I don't think so. However I'd like to proceed with the name, namespace approach for simplicty.

@fabriziosestito fabriziosestito force-pushed the refactor/simplify-webhook-configuation-controller-handlers branch 3 times, most recently from 5525634 to 84a9df8 Compare October 3, 2024 11:11
@fabriziosestito fabriziosestito marked this pull request as ready for review October 3, 2024 11:12
@fabriziosestito fabriziosestito requested a review from a team as a code owner October 3, 2024 11:12
… annotations

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
@fabriziosestito fabriziosestito force-pushed the refactor/simplify-webhook-configuation-controller-handlers branch from 84a9df8 to 281414e Compare October 22, 2024 15:18
@flavio flavio merged commit f4ed3ec into kubewarden:main Oct 23, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants