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

CRD defaulting and validation should not be placed in the controller #152

Closed
airycanon opened this issue Jun 3, 2024 · 3 comments
Closed

Comments

@airycanon
Copy link

CRD defaulting and validation should not be placed in the controller, but rather in the admission webhook.

Benefits:

  • Users can receive clear and specific error messages when validation fails.
  • If validation fails, it won't trigger the controller's reconcile, avoiding unnecessary resource consumption.
@airycanon airycanon changed the title CRD defaulting and Validation should not be placed in the Controller CRD defaulting and validation should not be placed in the Controller Jun 3, 2024
@airycanon airycanon changed the title CRD defaulting and validation should not be placed in the Controller CRD defaulting and validation should not be placed in the controller Jun 3, 2024
@zyy17
Copy link
Collaborator

zyy17 commented Jun 4, 2024

IMO, to keep the operator deployment simple, adding the admission webhook should be optional for setting default value and validation.

Without admission webhook, control can still can set the default value and validation. If the resource fails the validation, the controller will stop the reconcile until the user modifies it to the correct value.

@airycanon
Copy link
Author

IMO, to keep the operator deployment simple, adding the admission webhook should be optional for setting default value and validation.

Without admission webhook, control can still can set the default value and validation. If the resource fails the validation, the controller will stop the reconcile until the user modifies it to the correct value.

I agree that the admission webhook is optional, but doing validation in the controller has a significant drawback: users won't receive immediate feedback when they submit incorrect fields. They would have to investigate the controller logs to troubleshoot the issue, which can be inconvenient and time-consuming.

@zyy17
Copy link
Collaborator

zyy17 commented Jun 20, 2024

@airycanon Sorry for not getting back to you sooner.

You're right, and we can take the admission webhook as an enhancement. We can keep track of it. I created the new issue #153. If you are interested in the feature, feel free to contribute to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants