Skip to content

Set up defaulting webhook #51

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

Merged
merged 10 commits into from
Apr 20, 2023
Merged

Conversation

danielvegamyhre
Copy link
Contributor

@danielvegamyhre danielvegamyhre commented Apr 20, 2023

Fixes #6

  • Adds defaulting and validation webhook
  • Defaults job.spec.completionMode to Indexed if it is unset (includes unit tests and integration tests for this)
  • Currently the webhook does no validation; all validation is still done via CEL
  • Manually tested by deploying on a cluster and creating a JobSet with a job that has completionMode unset, then verifying the job was created in Indexed completion mode.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielvegamyhre

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 20, 2023
@k8s-ci-robot k8s-ci-robot requested a review from ahg-g April 20, 2023 17:28
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 20, 2023
@danielvegamyhre danielvegamyhre changed the title [IN PROGRESS] Set up defaulting webhook Set up defaulting webhook Apr 20, 2023
}{
{
name: "job completion mode is unset",
js: &JobSet{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not able to use wrappers here because it would create a circular import dependency (testing package imports v1alpha1, so v1alpha1 cannot import testing).

We could consider a refactor to solve this (kueue uses a separate webhooks package and sets up a CustomerDefaulter, which allows for more flexibility, contextual logging, etc. but this would require creating a separate webhook struct rather than adding methods to the JobSet struct to implement the Defaulter interface, and it becomes more complicated and didn't seem like it was worth it for this very simple defaulting we are doing.

@ahg-g
Copy link
Contributor

ahg-g commented Apr 20, 2023

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Apr 20, 2023
@ahg-g
Copy link
Contributor

ahg-g commented Apr 20, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 20, 2023
@k8s-ci-robot k8s-ci-robot merged commit 2daf75c into kubernetes-sigs:main Apr 20, 2023
@danielvegamyhre danielvegamyhre deleted the webhook branch April 20, 2023 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup validation and defaulting webhook
3 participants