-
Notifications
You must be signed in to change notification settings - Fork 296
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
add VSphereClusterTemplate type #1207
add VSphereClusterTemplate type #1207
Conversation
/assign @srm09 |
b6f603a
to
5fa0c51
Compare
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.
@ykakarap thanks for this PR!
Could you kindly enable web hooks for the new type ensuring that template type applies the same defaulting & validation rules of the actual type, otherwise this could trigger continuous reconcile loop down the path when comparing the desired state (the VSphereTemplate object) with the actual state (the instance of VSphereCluster generated from the template)?
5fa0c51
to
446b630
Compare
spec := ct.Spec.Template.Spec | ||
|
||
if spec.Thumbprint != "" && spec.Insecure != nil && *spec.Insecure { | ||
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "template", "spec", "Insecure"), spec.Insecure, "cannot be set to true at the same time as .spec.template.spec.Thumbprint")) | ||
} |
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.
Might be an implementation detail to be considered by the CAPV mantainers, but I'm wondering if this should be a func shared between with VSphereCluster webhook, so we are sure that the two validations web hooks are kept in sync over time?
} | ||
|
||
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type | ||
func (ct *VSphereClusterTemplate) ValidateUpdate(old runtime.Object) 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.
Should we make this immutable, like the other templates?
446b630
to
0126201
Compare
/retest |
fec3a24
to
85fa631
Compare
thanks for updating, changes lgtm to me |
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 error in the tests is due to the new defaulting webhook being introduced for VSphereCluster type. If the webhook isn't necessary, we should remove it, which in turn would remove the error. Looking forward to hearing about the reasoning behind the webhook.
@@ -0,0 +1,24 @@ | |||
# permissions for end users to edit vsphereclustertemplates. |
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 file is not required, could you please remove this.
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 file config/rbac/role.yaml
gets updated once we make changes to the controllers to allow them to read/update/delete/reconcile the template objects.
@@ -0,0 +1,20 @@ | |||
# permissions for end users to view vsphereclustertemplates. |
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.
same as above.
@@ -0,0 +1,7 @@ | |||
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha4 |
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.
same as above.
if s.Thumbprint != "" && s.Insecure != nil && *s.Insecure { | ||
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "Insecure"), s.Insecure, "cannot be set to true at the same time as .spec.Thumbprint")) | ||
} |
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 an FYI, the struct variable Insecure
is deprecated and is scheduled for removal in v1alpha4. So this will go away once the PR for removing deprecated types gets merged.
func (c *VSphereCluster) Default() { | ||
defaultVSphereCluterSpec(&c.Spec) | ||
} |
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.
Is there a specific reason that the defaulting webhook is being included here? I see the implementation of the method is empty. If this is for the sake of future usage, let's introduce it only when there is some specific defaulting logic that needs to be implemented.
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.
Yes, it is for future use cases. So that we make sure to introduce consistent defaulting for template and the cluster type when ever we do that.
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.
My vote is to wait till the need arises for a separate webhook. Adding a note in the clustertemplate_webhook to make sure this needs to be replicated across the two types would be a way to move forward.
Thoughts @gab-satchi @yastij ?
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.
+1 on not adding dead code
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.
b6141aa
to
7878ef2
Compare
@srm09 Addressed all review comments. PTAL. |
/lgtm |
7878ef2
to
e332e5e
Compare
@srm09 Had to rebase because of conflicts. Can you please re-lgtm? 🙂 |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: randomvariable 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 |
What this PR does / why we need it:
Add VSphereClusterTemplate type. This type is needed to work with ClusterClass
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #1206
Release note: