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 concurrent VM boot checkup #38

Merged
merged 3 commits into from
Aug 12, 2024

Conversation

arnongilboa
Copy link
Collaborator

@arnongilboa arnongilboa commented Aug 5, 2024

We would like to validate a CSI driver can handle parallelization, so we start 10 VMs simultaneously where each VM has one cloned boot disk and one empty data disk. The test passes if all VMs successfully boot. We allow setting the number of concurrent VMs to boot.

jira-ticket: https://issues.redhat.com/browse/CNV-44285

We would like to validate a CSI driver can handle parallelization, so we
start 10 VMs simultaneously where each VM has one cloned boot disk and
one empty data disk. The test passes if all VMs successfully boot.
We allow setting the number of concurrent VMs to boot.

Signed-off-by: Arnon Gilboa <[email protected]>
Signed-off-by: Arnon Gilboa <[email protected]>
Copy link
Contributor

@alromeros alromeros left a comment

Choose a reason for hiding this comment

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

Good work, I have a couple of comments

log.Print(ErrBootFailedOnSomeVMs)
c.results.ConcurrentVMBoot = ErrBootFailedOnSomeVMs
appendSep(errStr, ErrBootFailedOnSomeVMs)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I see all the returns from this function are nil, should you return some error when boot fails to abort the checkup? Or is this expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since we concurrently boot the VMs via goroutines, and we don't really have a tight timing expectations here (we have a timeout for the whole checkup), I think the best way is to wait for the goroutines to complete (they have early defer for the case of failure). We would like to continue to following checks (in the future), so I see no reason to return a error.

wg.Wait()
if !isBootOk {
log.Print(ErrBootFailedOnSomeVMs)
c.results.ConcurrentVMBoot = ErrBootFailedOnSomeVMs
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also keep track of the failed VMs and report how many of them errored

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not useful imho, as we are not interested in partial success, and you have already have each VMI boot status in the log anyway.

Copy link

@akalenyu akalenyu left a comment

Choose a reason for hiding this comment

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

looks really good, this is going to ensure provisioners are at least somewhat ready for the chaos of production

@@ -82,6 +76,11 @@ func WithDataVolume(volumeName string, pvc *corev1.PersistentVolumeClaim, snap *
Namespace: snap.Namespace,
Name: snap.Name,
}
} else {
Copy link

Choose a reason for hiding this comment

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

I think you want to pass options to WithDataVolume similarly to https://github.com/kubevirt/kubevirt/blob/main/pkg/libvmi/cloudinit.go#L31

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed, but not sure how much I like it. wdyt?

return nil
}

var wg sync.WaitGroup
Copy link

Choose a reason for hiding this comment

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

if you wanted to simplify, you could get rid of sync.WaitGroup and just have 2 loops

  • loop over creation
  • loop over waiting for ready

definitely not a must, just something to consider

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I personally prefer the goroutine-way. Looping over creation is less "concurrent", as it's serialized and you will see the last VM created long after the first one when you create for example 100 VMs. Tried that in the first shot but didn't really like this behavior. Looping over the wait for ready is ok (although it's cheaper from the goroutine if we already have it), but since it's serial we won't have the nice indication in the log whenever each VM is ready.

Copy link

Choose a reason for hiding this comment

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

right the creation http request will block. nvm

return func(dvSpec *cdiv1.DataVolumeSpec) {
dvSpec.Source.Blank = &cdiv1.DataVolumeBlankImage{}
dvSpec.Storage.Resources.Requests = corev1.ResourceList{
corev1.ResourceStorage: resource.MustParse("1G"),

Choose a reason for hiding this comment

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

1G -> 1Gi will look better, normally k8s is standardized on gibibytes so you'll rarely see this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +45 to +49
if pvc != nil {
dvOpts = append(dvOpts, vmi.WithDataVolumePvcSource(pvc))
} else if snap != nil {
dvOpts = append(dvOpts, vmi.WithDataVolumeSnapshotSource(snap))
}

Choose a reason for hiding this comment

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

if you want you can also parametrize newVMUnderTest with options, I guess this is what you didn't like, but could be done later

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right, it will wait for another pr

@akalenyu
Copy link

/lgtm

@arnongilboa arnongilboa merged commit ead00c1 into kiagnose:main Aug 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants