-
Notifications
You must be signed in to change notification settings - Fork 40
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was no issue created for it, it was fixed in a PR kubernetes-sigs/kubebuilder#2964 here
config/certmanager/certificate.yaml
Outdated
kind: Issuer | ||
metadata: | ||
labels: | ||
app.kuberentes.io/name: issuer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment here that it is spelled correctly, and point to the codespell config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again this is auto generated file
@@ -57,4 +57,7 @@ resources: | |||
kind: VolumeReplicationClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Added go logic to block updating the provisioner name or the parameters in the existing VolumeReplicationClass Signed-off-by: Madhu Rajanna <[email protected]>
This commit contains the yaml changes to enable the webhook in csv Signed-off-by: Madhu Rajanna <[email protected]>
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 <[email protected]>
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 <[email protected]>
`$` is not required if we dont have any output from the command in the markdown. Signed-off-by: Madhu Rajanna <[email protected]>
add namePrefix and namespace for webhook and the certificates to match with other resources. Signed-off-by: Madhu Rajanna <[email protected]>
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 <[email protected]>
added a new section for deployment of cert-manager and the controller with webhook enabled. Signed-off-by: Madhu Rajanna <[email protected]>
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
Thanks!
func (v *VolumeReplicationClass) ValidateCreate() error { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pr description mentions webhooks for create too
but here it is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the PR description, Create is not required as it should/can be handled as part of CRD schema validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 [email protected]