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 support for passing disk devices to vsphere machines #512
Add support for passing disk devices to vsphere machines #512
Conversation
@@ -428,6 +464,21 @@ func clone(s *machineScope) error { | |||
return nil | |||
} | |||
|
|||
func getDiskSpec(s *machineScope, devices object.VirtualDeviceList) (types.BaseVirtualDeviceConfigSpec, 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.
can we include a unit for this? similar to TestGetNetworkDevices
overall this looks great! PTAL @bison |
d4b5b06
to
a6aa47a
Compare
const ( | ||
// FullClone indicates a VM will have no relationship to the source of the | ||
// clone operation once the operation is complete. This is the safest clone | ||
// mode, but it is also the fastest. |
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 description and the one below claim to be the fastest clones 😅 I suspect this one is actually not the fastest? Can you double check and update the comments appropriately
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 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.
Probably best to just leave it then 😅 Didn't realise that was a copy/pasta from upstream
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.
/retest |
}, | ||
}, | ||
{ | ||
name: "Succefully get disk 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.
duplicate name with case above
// FullClone indicates a VM will have no relationship to the source of the | ||
// clone operation once the operation is complete. This is the safest clone | ||
// mode, but it is also the fastest. | ||
FullClone CloneMode = "fullClone" |
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't see where FullClone
is used at all
// to FullClone. | ||
// When LinkedClone mode is enabled the DiskGiB field is ignored as it is | ||
// not possible to expand disks of linked clones. | ||
// Defaults to LinkedClone, but fails gracefully to FullClone if the source |
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't really see where this "fails gracefully to FullClone", seems we are missing some logic in reconciler line 344
} | ||
} | ||
} | ||
|
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.
shouldn't we set the diskMoveType
based on the above
e.g
fullCloneDiskMoveType = types.VirtualMachineRelocateDiskMoveOptionsMoveAllDiskBackingsAndConsolidate
linkCloneDiskMoveType = types.VirtualMachineRelocateDiskMoveOptionsCreateNewChildDiskBacking
See https://github.com/openshift/machine-api-operator/pull/512/files#r394223024
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.
👍
fdf0b0a
to
0e48e1c
Compare
/retest |
/retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre 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 |
0e48e1c
to
2ac2612
Compare
2ac2612
to
913ee82
Compare
/retest |
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.
Added a couple of questions and suggestions for possible improvements
// CloneMode specifies the type of clone operation. | ||
// The LinkedClone mode is only support for templates that have at least | ||
// one snapshot. If the template has no snapshots, then CloneMode defaults | ||
// to FullClone. |
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.
Does it not default to LinkedClone based on
if s.providerSpec.CloneMode == "" || s.providerSpec.CloneMode == vspherev1.LinkedClone { |
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.
It defaults here https://github.com/openshift/machine-api-operator/pull/512/files#diff-11b6610f82e5d47fdfb8dda44b90dd1eR405 when no snapshots are found
deviceSpecs := []types.BaseVirtualDeviceConfigSpec{} | ||
|
||
// Only non-linked clones may expand the size of the template's disk. | ||
if snapshotRef == 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.
Nit: If the comment above this line is correct, I would expect this if statement to check the diskMoveType == fullCloneDIskMoveType
rather than checking the snapshotRef
which is kind of a side effect, WDYT? Behaviour should be functionally equivalent if I've understood this correctly?
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.
Right, it should be the same. I took this check from upstream https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/master/pkg/services/govmomi/vcenter/clone.go#L123 , maybe checking for snapshot reference is safer because the next line will fail otherwise.
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 would the next line fail is this is not nil? I don't think snapshotRef is used in there is it?
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.
Sorry for the confusion, the next line doesn't fail. The clone task fails if diskSpec from L460 is appended and SnapshotRef is nil.
@@ -467,6 +513,21 @@ func clone(s *machineScope) (string, error) { | |||
return task.Reference().Value, nil | |||
} | |||
|
|||
func getDiskSpec(s *machineScope, devices object.VirtualDeviceList) (types.BaseVirtualDeviceConfigSpec, 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.
Nit, should add a comment for the function to explain what is does
machineScope := &machineScope{ | ||
Context: context.TODO(), | ||
providerSpec: &vsphereapi.VSphereMachineProviderSpec{ | ||
DiskGiB: 1, |
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.
Could possibly add this field to the testCases
and try a couple of different values to make this test suite a little more thorough? WDYT?
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'm not getting this, you suggest trying different disk sizes?
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.
Yeah, the disk size (and expected disk size) could come from the test case and then you could try 1, 2, 3 as values in different cases and check the calculation of the size is correct, WDYT?
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.
makes sense, more tests never hurt :D
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.
@JoelSpeed done
913ee82
to
ec0e536
Compare
@alexander-demichev: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
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
/retest Please review the full test history for this PR and help us cut down flakes. |
Add support for passing disk devices to vsphere machines. The code is based on upstream one https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/master/pkg/services/govmomi/vcenter/clone.go#L74-L85