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

Create validation webhook for lvmcluster #255

Merged
merged 5 commits into from
Sep 12, 2022

Conversation

iamniting
Copy link
Member

@iamniting iamniting commented Sep 9, 2022

webhook intercepts the faulty CR and raises an appropriate error to guide the user.

Signed-off-by: Nitin Goyal [email protected]

Ref:
https://olm.operatorframework.io/docs/advanced-tasks/adding-admission-and-conversion-webhooks/
https://github.com/openshift/service-ca-operator

Signed-off-by: Nitin Goyal <[email protected]>
Output of:
./bin/operator-sdk create webhook --group lvm --version v1alpha1
--kind LVMCluster --programmatic-validation

Signed-off-by: Nitin Goyal <[email protected]>
@iamniting
Copy link
Member Author

@nbalacha @sp98 We have one corner case for the update validation where we should allow the user to delete the wrong path from the LVMCluster but we are not. As it is really difficult to find if the path is really wrong or not from the webhook server.

Steps to reproduce:

  1. Create a lvmcluster with some wrong path that does not exist.
  2. Edit the lvmcluster and try to correct the path. (It won't allow the update/edit at all)

Workaround:

  1. Edit the validation webhook and remove the UPDATE operation for lvmclusters resource under rules
  2. Edit the lvmcluster again. (It will allow this time)
  3. Revert the validation webhook changes again.

@iamniting iamniting force-pushed the webhook-v1 branch 2 times, most recently from ab698ac to fa75cd7 Compare September 12, 2022 05:10
config/webhook/kustomizeconfig.yaml Show resolved Hide resolved
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this in kustomizeconfig.yaml

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not required as we are not using cert-manager in the openshift

Copy link
Contributor

Choose a reason for hiding this comment

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

How are certificates set up in Openshift? What about if the operator is installed on plain K8s?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are set up using the https://github.com/openshift/service-ca-operator and OLM.

In the case of k8s user has to make changes to the manifests to get it working in k8s.

api/v1alpha1/lvmcluster_webhook.go Outdated Show resolved Hide resolved
api/v1alpha1/lvmcluster_webhook.go Outdated Show resolved Hide resolved
api/v1alpha1/lvmcluster_webhook.go Outdated Show resolved Hide resolved
api/v1alpha1/lvmcluster_webhook.go Outdated Show resolved Hide resolved
api/v1alpha1/lvmcluster_webhook.go Outdated Show resolved Hide resolved
api/v1alpha1/lvmcluster_webhook.go Show resolved Hide resolved
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 12, 2022

@iamniting: 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
ci/prow/lvm-operator-bundle-e2e-aws 08188c4 link false /test lvm-operator-bundle-e2e-aws

Full PR test history. Your PR dashboard.

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.

if val, ok := devices[nodeSelector][path]; ok {
var err error
if val != deviceClass.Name {
err = fmt.Errorf("Error: device path %s overlaps in two different deviceClasss %s and %s", path, val, deviceClass.Name)
Copy link
Contributor

@nbalacha nbalacha Sep 12, 2022

Choose a reason for hiding this comment

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

Ideally this is no required seeing that we are now restricting it to one deviceClass.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 12, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 12, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iamniting, nbalacha

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 12, 2022
@openshift-merge-robot openshift-merge-robot merged commit 8b13068 into openshift:main Sep 12, 2022
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants