-
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 VM naming strategy for VMs in govmomi mode #3286
base: main
Are you sure you want to change the base?
Conversation
Welcome @viveksyngh! |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @viveksyngh. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
c0c07cd
to
7ca274d
Compare
- Add VM naming stragey for vsphere vms and VMs in govami mode
7ca274d
to
0deb41a
Compare
- Rename the type to VSphereVMNamingStrategy and update docs, function name etc
026364a
to
782c264
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.
please give a ping once this is no longer a draft and is ready for review.
/cc
make sure you add a test. |
275cf76
to
bd815fd
Compare
@@ -68,6 +68,30 @@ type VSphereMachineSpec struct { | |||
// | |||
// +optional | |||
GuestSoftPowerOffTimeout *metav1.Duration `json:"guestSoftPowerOffTimeout,omitempty"` | |||
|
|||
// NamingStrategy allows configuring the naming strategy used when calculating the name of the VSphereVM. |
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.
calculating -> preparing
as it's not a math calculation.
EDIT: seems consistent with the supervisor PR. so you can leave it as is.
name of the VSphereVM.
this field is inside VSphereMachineSpec not VSphereVMSpec
// VSphereVMNamingStrategy defines the naming strategy for the VSphereVMs. | ||
type VSphereVMNamingStrategy struct { |
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 this be named
VSphereMachineNamingStrategy
// * Names are automatically truncated at 63 characters. Please note that this can lead to name conflicts, | ||
// so we highly recommend to use a template which leads to a name shorter than 63 characters. | ||
// +optional | ||
Template *string `json:"template,omitempty"` |
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.
no need for *string, just string?
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.
EDIT: seems consistent with the supervisor PR. so you can leave it as is.
// * While the template offers some flexibility, we would like the name to link to the Machine name | ||
// to ensure better user experience when troubleshooting |
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.
// * While the template offers some flexibility, we would like the name to link to the Machine name | |
// to ensure better user experience when troubleshooting | |
// * While the template offers some flexibility, it is best for the name to link to the Machine name | |
// to ensure better user experience when troubleshooting |
personalization should not be present in official docs (ideally).
EDIT: seems consistent with the supervisor PR. so you can leave it as is.
return nil, AggregateObjErrors(newTyped.GroupVersionKind().GroupKind(), newTyped.Name, allErrs) | ||
} | ||
|
||
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. | ||
func (webhook *VSphereMachineTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { | ||
return nil, nil | ||
} | ||
|
||
func validateVSphereVMNamingTemplate(_ context.Context, vsphereMachineTemplate *infrav1.VSphereMachineTemplate) field.ErrorList { |
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 this following some code that core CAPI already has or is this done from scratch as a use case for CAPV?
if the former, could you link to that code for reviewer's reference?
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 based on this MR which was added to support this in supervisor mode #3099
In supervisor mode, the object is called VirtualMachine which drives the creation of vSphere VMs while in govami mode this object is called VSphereVM.
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.
looks like a lot comes from that PR.
why not also name it VirtualMachineNamingStrategy here? that seems more consistent despite the diff backend objects.
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 can do that if we prefer that. I just to wanted to call it what it is being used for.
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.
that would be my preference. not sure what other reviewers will comment on this.
maxNameLength = 63 | ||
) | ||
|
||
// Note: Inlining these functions from sprig to avoid introducing a dependency. |
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.
sprig is a typo?
- op: add | ||
path: /spec/template/spec/namingStrategy | ||
value: | ||
template: '{{ if le (len .machine.name) 20 }}{{ .machine.name }}{{else}}{{ trimSuffix "-" (trunc 14 .machine.name) }}-{{ trunc -5 .machine.name }}{{end}}' |
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.
add missing new line at the end.
This MR is more or less similar code from this MR which added the functionality in the supervisor mode. #3099 I can make the requested changes but I have tried to align this as much as possible with supervisor mode changes. |
/ok-to-test |
|
What this PR does / why we need it:
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 #