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

add VSphereClusterTemplate type #1207

Merged

Conversation

ykakarap
Copy link

@ykakarap ykakarap commented Jul 8, 2021

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:

Adds VSphereClusterTemplate type

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 8, 2021
@k8s-ci-robot k8s-ci-robot requested review from chuckha and detiber July 8, 2021 21:07
@ykakarap
Copy link
Author

ykakarap commented Jul 8, 2021

/assign @srm09

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 8, 2021
@ykakarap ykakarap force-pushed the vsphereclustertemplate branch 2 times, most recently from b6f603a to 5fa0c51 Compare July 9, 2021 00:07
Copy link
Member

@fabriziopandini fabriziopandini left a 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)?

@ykakarap ykakarap force-pushed the vsphereclustertemplate branch from 5fa0c51 to 446b630 Compare July 9, 2021 18:58
Comment on lines 39 to 43
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"))
}
Copy link
Member

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 {
Copy link
Member

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?

@ykakarap ykakarap changed the title add VSphereClusterTemplate type [WIP] add VSphereClusterTemplate type Jul 16, 2021
@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 Jul 16, 2021
@ykakarap ykakarap force-pushed the vsphereclustertemplate branch from 446b630 to 0126201 Compare July 16, 2021 21:36
@ykakarap
Copy link
Author

/retest

@ykakarap ykakarap force-pushed the vsphereclustertemplate branch 2 times, most recently from fec3a24 to 85fa631 Compare July 16, 2021 22:11
@fabriziopandini
Copy link
Member

thanks for updating, changes lgtm to me
I leave the final word to CAPV maintainers

Copy link
Contributor

@srm09 srm09 left a 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.
Copy link
Contributor

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.

Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

Comment on lines +66 to +59
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"))
}
Copy link
Contributor

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.

Comment on lines 37 to 39
func (c *VSphereCluster) Default() {
defaultVSphereCluterSpec(&c.Spec)
}
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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 ?

Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback @srm09 @yastij. Will update the PR :)

@ykakarap ykakarap force-pushed the vsphereclustertemplate branch 2 times, most recently from b6141aa to 7878ef2 Compare July 26, 2021 00:54
@ykakarap ykakarap changed the title [WIP] add VSphereClusterTemplate type add VSphereClusterTemplate type Jul 26, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2021
@ykakarap
Copy link
Author

@srm09 Addressed all review comments. PTAL.

@srm09
Copy link
Contributor

srm09 commented Jul 27, 2021

/lgtm
/assign @yastij for final +1 before merging it in

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 27, 2021
@ykakarap ykakarap force-pushed the vsphereclustertemplate branch from 7878ef2 to e332e5e Compare August 5, 2021 23:57
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 5, 2021
@ykakarap
Copy link
Author

ykakarap commented Aug 5, 2021

@srm09 Had to rebase because of conflicts. Can you please re-lgtm? 🙂

@srm09
Copy link
Contributor

srm09 commented Aug 6, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2021
@randomvariable
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /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 Aug 11, 2021
@k8s-ci-robot k8s-ci-robot merged commit 42649cc into kubernetes-sigs:master Aug 11, 2021
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. 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.

Add VSphereClusterTemplate type
6 participants