replication: add webhook for volumereplicationclass#257
Conversation
| # kubebuilder latest release has a label with name kuberentes | ||
| # TODO: remove this in next kubebuilder update as this is fixed | ||
| # in kubebuilder master | ||
| ignore_words_list: kuberentes |
There was a problem hiding this comment.
please add a link to the kubebuilder issue in this comment, that makes it easier to verify what next release contains the fix
There was a problem hiding this comment.
there was no issue created for it, it was fixed in a PR kubernetes-sigs/kubebuilder#2964 here
| kind: Issuer | ||
| metadata: | ||
| labels: | ||
| app.kuberentes.io/name: issuer |
There was a problem hiding this comment.
please add a comment here that it is spelled correctly, and point to the codespell config
There was a problem hiding this comment.
this is auto generated file adding commit might get overriden when its rebuild
| @@ -0,0 +1,20 @@ | |||
|
|
|||
| apiVersion: v1 | |||
There was a problem hiding this comment.
starting with an empty line? Maybe include the yaml-start-of-document --- instead (and in other yaml files)
There was a problem hiding this comment.
again this is auto generated file
| @@ -57,4 +57,7 @@ resources: | |||
| kind: VolumeReplicationClass | |||
There was a problem hiding this comment.
did you use a kubebuilder command to generate the initial files? Please include the command(s) in the commit message so that others can reproduce it, or follow the steps to add other webhooks.
| ) | ||
|
|
||
| // log is for logging in this package. | ||
| var volumereplicationclasslog = logf.Log.WithName("volumereplicationclass-resource") |
There was a problem hiding this comment.
vrcLog would do too. But it isn't used much, so the long name might not be too inconvenient.
| // log is for logging in this package. | ||
| var volumereplicationclasslog = logf.Log.WithName("volumereplicationclass-resource") | ||
|
|
||
| func (r *VolumeReplicationClass) SetupWebhookWithManager(mgr ctrl.Manager) error { |
There was a problem hiding this comment.
Why r for VolumeReplicationClass? I guess it's used elsewhere and can not easily be modified without changing other files. r is not a self-explaining name when using it inside functions.
There was a problem hiding this comment.
this is also auto generated not manually added, i think it need changes in many places
| } | ||
|
|
||
| // ValidateUpdate implements webhook.Validator. Validates the updated | ||
| // VolumeReplicationClass and does not allow changes to existing spec object. |
There was a problem hiding this comment.
If it does not allow any changes to the .Spec part, why not use reflect.DeepEqual for that? No need to compare .Provisioner and .Parameters separately.
There was a problem hiding this comment.
not comparing spec because for now we have only two fields in spec but later we might add new fields which are suppose to be editable also that the reason to compare it explicitly
| }).Should(Succeed()) | ||
|
|
||
| }, 60) | ||
|
|
There was a problem hiding this comment.
Where are the tests? I expected to find a By() or similar. At least one positive and one negative test would be nice.
There was a problem hiding this comment.
Again this is an auto-generated file, current we dont have any functional suite tests. We have already 2 suite files in the repo. https://github.com/csi-addons/kubernetes-csi-addons/blob/main/controllers/csiaddons/suite_test.go https://github.com/csi-addons/kubernetes-csi-addons/blob/main/controllers/replication.storage/suite_test.go. i need to see how to have a single suite to run with the mock controller. I will take it up in the next PR to see how to make it possible.
Adding scalefolding for webhooks for volumereplicationclass. below is the command to generate it. ``` $operator-sdk create webhook --group replication.storage --version v1alpha1 --kind VolumeReplicationClass --programmatic-validation ``` Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
Added go logic to block updating the provisioner name or the parameters in the existing VolumeReplicationClass Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit contains the yaml changes to enable the webhook in csv Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
exclude kuberentes from codespell as there is a typo in label name in latest kubebuilder release and it is fixed in latest master and should be available in next release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
Provided an option to make webhook configurable in the manager deployment . The webhook will be enabled by default when operator is deployed as OLM bundle as OLM takes care of ceritifcates and its disabled in standalone deployment for now as we have dependency with certificates and cert manager as it needs to be setup separately. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
`$` is not required if we dont have any output from the command in the markdown. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
add namePrefix and namespace for webhook and the certificates to match with other resources. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
A new all-in-one yaml files will be generated and it will include all the required RBAC, CRD's , Webhooks, Certificates in a single file. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
added a new section for deployment of cert-manager and the controller with webhook enabled. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
|
I have tested both yaml-based and bundle-based deployments both work as expected. |
24d9b0e to
7d30db3
Compare
use local built image from CI testing. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
| func (v *VolumeReplicationClass) ValidateCreate() error { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
The pr description mentions webhooks for create too
but here it is empty.
There was a problem hiding this comment.
update the PR description, Create is not required as it should/can be handled as part of CRD schema validation.
nixpanic
left a comment
There was a problem hiding this comment.
I don't know much about WebHooks, but this looks reasonable to me.
Syncing latest changes from upstream main for kubernetes-csi-addons
Add webhook for VolumeReplicationClass to validate update CR.
Signed-off-by: Madhu Rajanna madhupr007@gmail.com