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

feat: policy server deployment tolerations. #793

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

jvanz
Copy link
Member

@jvanz jvanz commented Jul 2, 2024

Description

Updates the PolicyServer CRDs to allow users to define the toleration to be used in the policy server deployment.

Fix #752

Test

make test

Additional Information

I'm aware that we have a PR changing our tests (#788 ). I'm fine to wait that PR to be merged before. I'm glad to rebase this change on top of that PR after it gets merged into main.

Updates the PolicyServer CRDs to allow users to define the toleration to
be used in the policy server deployment.

Signed-off-by: José Guilherme Vanz <[email protected]>
@jvanz jvanz self-assigned this Jul 2, 2024
@jvanz jvanz requested a review from a team as a code owner July 2, 2024 17:15
Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.43%. Comparing base (235d006) to head (6e105ed).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #793      +/-   ##
==========================================
- Coverage   71.73%   71.43%   -0.30%     
==========================================
  Files          23       23              
  Lines        1705     1705              
==========================================
- Hits         1223     1218       -5     
- Misses        371      375       +4     
- Partials      111      112       +1     
Flag Coverage Δ
integration-tests 63.28% <100.00%> (-0.30%) ⬇️
unit-tests 31.90% <ø> (ø)

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.

@@ -168,6 +168,7 @@ func (r *PolicyServerReconciler) updatePolicyServerDeployment(policyServer *poli
SecurityContext: podSecurityContext,
Containers: []corev1.Container{admissionContainer},
ServiceAccountName: policyServer.Spec.ServiceAccountName,
Tolerations: policyServer.Spec.Tolerations,
Copy link
Member

@viccuad viccuad Jul 3, 2024

Choose a reason for hiding this comment

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

Just in case, shouldn't it be done with something similar to https://github.com/kubewarden/kubewarden-controller/blob/main/internal/controller/policyserver_controller_deployment.go#L299-L300?

That way, we support the users changing the Deployment if there was no PolicyServer spec.tolerations set.
I'm not sure what informal promise do we have with our users for this behavior. I recall someone asking for this possibility of being able to manually set the affinity, but maybe it's an anachronism. If that's the case, I would like to use this PR to unify the behavior for tolerations and affinity.

Copy link
Member

Choose a reason for hiding this comment

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

@viccuad I don't understand why we wrote the code you linked. I would have handled affinity like @jvanz just did here with tolerations...

@fabriziosestito can you chime in?

Copy link
Member Author

@jvanz jvanz Jul 3, 2024

Choose a reason for hiding this comment

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

Is not related to how we used to detect changes in the resource and trigger a reconciliation? I have a vague memory about a discussion around this. If that's the case and now we use the controller-runtime helper functions, I believe we do not need to do that anymore.

Copy link
Contributor

@fabriziosestito fabriziosestito Jul 3, 2024

Choose a reason for hiding this comment

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

We can remove it and use the same approach of the Tolerations field. As far as I understood the if block does not change the reconciliation behaviour, it's probably some leftover since now we use the controller-runtime CreatOr*

That way, we support the users changing the Deployment if there was no PolicyServer spec.tolerations set.

I don't think the user should be able to thinker with the Deployment, as the only interface we expose is the PolicyServer CRD

Copy link
Member

Choose a reason for hiding this comment

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

If we agree then, I would like to follow the same approach of Tolerations for Affinity in this PR.

@jvanz jvanz requested review from viccuad and flavio July 3, 2024 18:42
The policy server reconciler check if the policy server spec has a non
empty affinity. If that's the case, it set the affinity in the policy
server deployment. This allow users to set the affinity manually in the
deployment. This should not be allowed. The policy server CRDS should be
the interface to configure the affinity. Therefore, that check is
removed and the affinity from the policy server spec is always set in
the deployment.

Signed-off-by: José Guilherme Vanz <[email protected]>
Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

LGTM!

@jvanz jvanz merged commit 807090f into kubewarden:main Jul 4, 2024
9 checks passed
@jvanz jvanz deleted the tolerations-issue752 branch July 4, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend PolicyServer CRD to have tolerations
4 participants