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

Skip validation errors in mutating webhooks #2865

Merged
merged 1 commit into from
Dec 13, 2022

Commits on Dec 12, 2022

  1. Skip validation errors in mutating webhooks

    Request processing by kube-apiserver is roughly:
      { mutating webhooks } => { OpenAPI schema validation } => { validating webhooks }
    
    In this PR, we disable validation errors (at least, JSON unmarshalling
    validation errors) during mutating webhook processing. It seems
    counter-intuitive not to return an error in mutating webhooks for a
    serious violation such as invalid JSON, but doing so allows OpenAPI
    schema validation to proceed. Schema validation gives us nice errors,
    so e.g.:
    
    instead of:
    
    ```
    The Fleet "" is invalid
    ```
    
    we get:
    
    ```
    The Fleet "fleet-example" is invalid: spec.template.spec.sdkServer.grpcPort: Invalid value: 33332229357: spec.template.spec.sdkServer.grpcPort in body should be less than or equal to 65535
    ```
    
    This will become all the more important if we eventually move to CEL
    based validations.
    
    I'm also changing the error in googleforgames#2863 to an internal error - after this
    PR, any hard error from a handler (vs a cause) is unexpected.
    
    Fixes googleforgames#1770
    zmerlynn committed Dec 12, 2022
    Configuration menu
    Copy the full SHA
    fdca3f3 View commit details
    Browse the repository at this point in the history