Skip to content

Create a validation webhook #348

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

Conversation

erusso7
Copy link
Contributor

@erusso7 erusso7 commented Mar 21, 2023

Job done:

  • Generated all the required files using operator-sdk to enable the webhook for the operator.
  • Implemented the first validation using the Create and Update webhook
  • Implement other validations to meet the Add a validating webhook #89 issue's requirements.
  • Squash commits before the final PR

Pending to do:

  • Adapt this code to make it work downstream

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 21, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 21, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @erusso7. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@netlify
Copy link

netlify bot commented Mar 21, 2023

Deploy Preview for kubernetes-sigs-kmm ready!

Name Link
🔨 Latest commit 096a965
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kmm/deploys/64255b851da2d1000852a4c4
😎 Deploy Preview https://deploy-preview-348--kubernetes-sigs-kmm.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 21, 2023
@erusso7 erusso7 force-pushed the create_validation_webhooks branch from 263bc79 to b086628 Compare March 21, 2023 15:08
@erusso7 erusso7 force-pushed the create_validation_webhooks branch from ddcdbb4 to 9384427 Compare March 21, 2023 15:43
@erusso7 erusso7 force-pushed the create_validation_webhooks branch 2 times, most recently from c68febc to 0f89b04 Compare March 21, 2023 15:53
Copy link
Contributor

@qbarrand qbarrand left a comment

Choose a reason for hiding this comment

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

I think we should also declare a dependency on cert-manager.

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2023

Codecov Report

Patch coverage: 92.30% and project coverage change: +0.25 🎉

Comparison is base (b2574f3) 82.84% compared to head (096a965) 83.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #348      +/-   ##
==========================================
+ Coverage   82.84%   83.10%   +0.25%     
==========================================
  Files          27       30       +3     
  Lines        2816     2882      +66     
==========================================
+ Hits         2333     2395      +62     
- Misses        392      396       +4     
  Partials       91       91              
Impacted Files Coverage Δ
api/v1beta1/module_webhook.go 92.30% <92.30%> (ø)

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 21, 2023
@erusso7 erusso7 force-pushed the create_validation_webhooks branch from b569508 to 07415db Compare March 21, 2023 17:32
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2023
Comment on lines 77 to 79
- name: Install cert-manager
run: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml

Copy link
Contributor

@ybettan ybettan Mar 26, 2023

Choose a reason for hiding this comment

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

This is breaking make deploy or kubectl apply -k https://github.com/kubernetes-sigs/kernel-module-management/config/default.

I am tryin to make a local copy of https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml inside config/certmanager instead

@qbarrand thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have created 2 PRs to make sure we are not missing such changes in the future:

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, don't we need to install cert-manager and the validation webhook in manager-hub as well?
We can open an issue about it and do it in a later PR though.

Copy link
Contributor

@ybettan ybettan Mar 27, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor

@ybettan ybettan Mar 27, 2023

Choose a reason for hiding this comment

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

I tried to extract the installation of certmanager (not the Certificate nor the Issuer but `certmanager itself) to another PR that should be used as a base for this PR IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ybettan I think we should not add the 5000 lines of YAML for cert-manager. Instead:

  • if users are installing with kubectl apply -k, then we should document that they need to run kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml beforehand;
  • is users are installing from the OLM bundle, then we could specify that cert-manager is a dependency.

With regards to validating ManagedClusterModule in the Hub context, I would address that in a separate PR.

Copy link
Contributor

@ybettan ybettan Mar 28, 2023

Choose a reason for hiding this comment

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

Updated PR for installing cert-manager that install it from https directly instead of coping all the manifests.

Copy link
Contributor

Choose a reason for hiding this comment

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

@erusso7 Can you please rebase the PR on the new main branch?

@erusso7 erusso7 force-pushed the create_validation_webhooks branch 4 times, most recently from 48e5f28 to 417dc64 Compare March 28, 2023 17:14
@erusso7 erusso7 force-pushed the create_validation_webhooks branch from 417dc64 to e611b12 Compare March 29, 2023 13:33
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Mar 29, 2023

@erusso7: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kernel-module-management-test-deploy 743c053 link true /test pull-kernel-module-management-test-deploy

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@erusso7 erusso7 force-pushed the create_validation_webhooks branch from e611b12 to 07f0bb3 Compare March 29, 2023 14:14
@erusso7 erusso7 force-pushed the create_validation_webhooks branch from 07f0bb3 to 0c18014 Compare March 29, 2023 14:47
@ybettan
Copy link
Contributor

ybettan commented Mar 29, 2023

I don't know how this happened:

+ kubectl wait --for=condition=Available deployment/kmm-operator-controller-manager -n kmm-operator-system
deployment.apps/kmm-operator-controller-manager condition met
+ echo 'Add an kmm-ci Module that contains a valid mapping...'
+ kubectl apply -f ci/module-kmm-ci-build-sign.yaml
Add an kmm-ci Module that contains a valid mapping...
Error from server (InternalError): error when creating "ci/module-kmm-ci-build-sign.yaml": Internal error occurred: failed calling webhook "vmodule.kb.io": failed to call webhook: Post "[https://kmm-operator-webhook-service.kmm-operator-system.svc:443/validate-kmm-sigs-x-k8s-io-v1beta1-module?timeout=10s](https://kmm-operator-webhook-service.kmm-operator-system.svc/validate-kmm-sigs-x-k8s-io-v1beta1-module?timeout=10s)": dial tcp 10.103.134.208:443: connect: connection refused

@erusso7
Copy link
Contributor Author

erusso7 commented Mar 29, 2023

/retest

- Scaffolding using the operator-sdk
- Adapted the code just enabling Validation webhooks for Create and Update verbs.
- Implement custom logic that validates the module's specs.

Signed-off-by: Erusso7 <[email protected]>
@yevgeny-shnaidman
Copy link
Contributor

/retest

@erusso7 erusso7 force-pushed the create_validation_webhooks branch from 0c18014 to 096a965 Compare March 30, 2023 09:50
@ybettan
Copy link
Contributor

ybettan commented Mar 30, 2023

/lgtm
/assign @qbarrand

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 30, 2023
@qbarrand
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: erusso7, qbarrand

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 30, 2023
@k8s-ci-robot k8s-ci-robot merged commit b55ea5d into kubernetes-sigs:main Mar 30, 2023
@erusso7 erusso7 deleted the create_validation_webhooks branch March 31, 2023 08:10
@qbarrand qbarrand mentioned this pull request May 3, 2023
3 tasks
qbarrand added a commit to qbarrand/kernel-module-management that referenced this pull request Jun 2, 2023
kubernetes-sigs#348)

This change adds the implementation of the ManagedClusterModuleStatus.
The latter reflects the number of desired, applied and degraded
ManifestWork CRs owned by the respective ManagedClusterModule CR.

Signed-off-by: Michail Resvanis <[email protected]>
Upstream-Commit: 2a12408

Signed-off-by: Michail Resvanis <[email protected]>
Co-authored-by: Michail Resvanis <[email protected]>
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants