Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Match DV disks with volumes #29

Merged
merged 1 commit into from
Oct 16, 2020
Merged

Conversation

mfranczy
Copy link
Contributor

@mfranczy mfranczy commented Oct 14, 2020

Signed-off-by: Marcin Franczyk [email protected]

What this PR does / why we need it:
It allows to pass devices options and matches disks settings with volumes

Which issue(s) this PR fixes:
Fixes gardener-attic/gardener-extension-provider-kubevirt#36

Special notes for your reviewer:

Release note:

improvement_user

@mfranczy mfranczy requested a review from a team as a code owner October 14, 2020 16:52
@mfranczy mfranczy changed the title Match DV disks with volumes [WIP] Match DV disks with volumes Oct 14, 2020
@gardener-robot gardener-robot added the needs/review Needs review label Oct 14, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 14, 2020
@gardener-robot gardener-robot added size/l Size of pull request is large (see gardener-robot robot/bots/size.py) needs/second-opinion Needs second review by someone else labels Oct 14, 2020
@mfranczy
Copy link
Contributor Author

mfranczy commented Oct 14, 2020

@stoyanr PR is still in progress casue I didn't test that yet, tomorrow during the sync meeting we have to discuss volumeSource type

@gardener-robot-ci-2 gardener-robot-ci-2 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Oct 14, 2020
@gardener-robot gardener-robot removed the needs/review Needs review label Oct 14, 2020
@gardener-robot gardener-robot added size/s Size of pull request is small (see gardener-robot robot/bots/size.py) and removed size/l Size of pull request is large (see gardener-robot robot/bots/size.py) labels Oct 15, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@gardener-robot gardener-robot added size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) and removed size/s Size of pull request is small (see gardener-robot robot/bots/size.py) labels Oct 15, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@mfranczy mfranczy changed the title [WIP] Match DV disks with volumes Match DV disks with volumes Oct 15, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 15, 2020
Copy link
Contributor

@stoyanr stoyanr left a comment

Choose a reason for hiding this comment

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

Looks very good, I only have a few naming suggestions and a few more regarding wording of comments.

@@ -64,6 +69,8 @@ type KubeVirtProviderSpec struct {
// AdditionalVolumeSpec represents an additional volume attached to a VM.
// Only one of its members may be specified.
type AdditionalVolumeSpec struct {
// Name of the volume
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Name of the volume
// Name is the additional volume name

@@ -89,6 +96,22 @@ type VolumeSource struct {
Secret *kubevirtv1.SecretVolumeSource `json:"secret,omitempty"`
}

// Devices allows to fine-tune devices attached to KubeVirt VM
type Devices struct {
// Disks allows to customize disks attached to KubeVirt VM
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Disks allows to customize disks attached to KubeVirt VM
// Disks allows customizing the disks attached to the VM.

// Disks allows to customize disks attached to KubeVirt VM
// +optional
Disks []kubevirtv1.Disk `json:"disks,omitempty"`
// Whether to have random number generator from host
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Whether to have random number generator from host
// Rng specifies whether to have a random number generator from host.

// Whether to have random number generator from host
// +optional
Rng *kubevirtv1.Rng `json:"rng,omitempty"`
// Whether or not to enable virtio multi-queue for block devices
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Whether or not to enable virtio multi-queue for block devices
// BlockMultiQueue specifies whether to enable virtio multi-queue for block devices.

// Whether or not to enable virtio multi-queue for block devices
// +optional
BlockMultiQueue bool `json:"blockMultiQueue,omitempty"`
// If specified, virtual network interfaces configured with a virtio bus will also enable the vhost multiqueue feature
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// If specified, virtual network interfaces configured with a virtio bus will also enable the vhost multiqueue feature
// NetworkInterfaceMultiQueue specifies whether virtual network interfaces configured with a virtio bus will also enable the vhost multi-queue feature.

@@ -163,26 +163,47 @@ ethernets:
return interfaces, networks, networkData
}

func findDiskByVolumeName(name string, disks []kubevirtv1.Disk) *kubevirtv1.Disk {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function finds a disk in a slice by its name, no "volume" here.

Suggested change
func findDiskByVolumeName(name string, disks []kubevirtv1.Disk) *kubevirtv1.Disk {
func findDiskByName(name string, disks []kubevirtv1.Disk) *kubevirtv1.Disk {

return nil
}

func generateDefaultDisk(name string) kubevirtv1.Disk {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use build rather than generate for consistency with the rest of the code.

Suggested change
func generateDefaultDisk(name string) kubevirtv1.Disk {
func buildDefaultDisk(name string) kubevirtv1.Disk {

func buildVolumes(
machineName, namespace, userDataSecretName, networkData string,
rootVolume cdicorev1alpha1.DataVolumeSpec,
additionalVolumes []api.AdditionalVolumeSpec,
providedDisks []kubevirtv1.Disk,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use configuredDisks as it's a bit more concrete.

Suggested change
providedDisks []kubevirtv1.Disk,
configuredDisks []kubevirtv1.Disk,

return errs
}

func hasDiskVolumeMatch(diskName string, volumes []api.AdditionalVolumeSpec) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function checks whether the given slice has a volume with the given name.

Suggested change
func hasDiskVolumeMatch(diskName string, volumes []api.AdditionalVolumeSpec) bool {
func hasVolumeWithName(diskName string, volumes []api.AdditionalVolumeSpec) bool {

@@ -163,26 +163,47 @@ ethernets:
return interfaces, networks, networkData
}

func findDiskByVolumeName(name string, disks []kubevirtv1.Disk) *kubevirtv1.Disk {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please move the 2 helper functions findDiskByName and buildDefaultDisk below buildVolumes for consistency with the rest of the code?

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Oct 16, 2020
Signed-off-by: Marcin Franczyk <[email protected]>
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 16, 2020
@mfranczy
Copy link
Contributor Author

@stoyanr I addressed all your comments.

@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 16, 2020
@stoyanr stoyanr merged commit ef994b6 into gardener-attic:master Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs/changes Needs (more) changes needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/second-opinion Needs second review by someone else size/m Size of pull request is medium (see gardener-robot robot/bots/size.py)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add additional VM configuration options
6 participants