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

hook: add PVC option #10598

Merged
merged 2 commits into from Nov 13, 2023
Merged

hook: add PVC option #10598

merged 2 commits into from Nov 13, 2023

Conversation

alicefr
Copy link
Member

@alicefr alicefr commented Oct 20, 2023

Use a PVC for storing and sharing files between the compute and the sidecar containers.

What this PR does / why we need it:
This PR adds the possibility of using a PVC with the KubeVirt hook sidecar and the compute container.

One usage of this enhancement is for debugging purposes and a full guide with a demo is available here. This option allows to supply of additional debug tools without the need to rebuild the virt-launcher image and explain how to launch QEMU with a debug tool like strace.

A concrete example of when this can be useful is when QEMU faces some permission issues, like in this case. For those types of failures, starting QEMU with strace can save you a lot of time.

Special notes for your reviewer:
Please check the guide, otherwise, these changes standalone don't make much sense. I'd love also to integrate the documentation and demo somehow upstream and suggestions are welcome.

Additionally, we could provide an additional image as part of KubeVIrt release with the most used debugging tool that could be used to populate the PVC.

Add PVC option to the hook sidecars for supplying additional debugging tools

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels Oct 20, 2023
@alicefr
Copy link
Member Author

alicefr commented Oct 20, 2023

@kubevirt-bot
Copy link
Contributor

@alicefr: GitHub didn't allow me to request PR reviews from the following users: zippy2.

Note that only kubevirt members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @victortoso @andreabolognani @zippy2

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.

@alicefr
Copy link
Member Author

alicefr commented Oct 20, 2023

@vasiliy-ul I'd love also to have your opinion on this feature, would you mind taking a look at this guide when you have a bit of time

Copy link
Contributor

@vasiliy-ul vasiliy-ul left a comment

Choose a reason for hiding this comment

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

@alicefr, very interesting approach. I particularly liked the detailed guide and the demo 👍

Regarding the

I'd love also to integrate the documentation and demo somehow upstream and suggestions are welcome.

I think this can be part of the user guide. A section about troubleshooting the VMs and debug techniques would be very useful. Additionally, didn't you think about a blog post?

pkg/virt-controller/services/template.go Outdated Show resolved Hide resolved
Use a PVC for storing and sharing files between the compute and the sidecar
containers.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
@alicefr alicefr changed the title WIP: hook: add PVC option hook: add PVC option Oct 26, 2023
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 26, 2023
@alicefr
Copy link
Member Author

alicefr commented Oct 26, 2023

I update the PR with a unit test for the hook option and I think now this is ready for review

Signed-off-by: Alice Frosi <afrosi@redhat.com>
Copy link
Contributor

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

@alicefr honestly, just questions that came to my mind while going through the code. :)

Comment on lines +513 to +519
if requestedHookSidecar.PVC.SharedComputePath != "" {
containers[0].VolumeMounts = append(containers[0].VolumeMounts,
k8sv1.VolumeMount{
Name: requestedHookSidecar.PVC.Name,
MountPath: requestedHookSidecar.PVC.SharedComputePath,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a condition of its own at the same level as if requestedHookSidecar.PVC != nil. Mainly to reduce the cyclomatic complexity.

Copy link
Member Author

@alicefr alicefr Nov 3, 2023

Choose a reason for hiding this comment

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

It could reduce the nested if but I need to recheck if the PVC is nil and it would add another condition to the if. Hence, I'm not sure if this is more readable

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally missed the possibility of nil here. 🤦🏽‍♂️

}
sidecarVolumes = append(sidecarVolumes, vol)
if requestedHookSidecar.PVC.SharedComputePath != "" {
containers[0].VolumeMounts = append(containers[0].VolumeMounts,
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT about using compute.VolumeMounts instead of containers[0].VolumeMounts because, IIUC, we're appending to compute container's volume mounts here and the variable compute is a pointer:

compute := t.newContainerSpecRenderer(vmi, volumeRenderer, resources, userId).Render(command)

Copy link
Member Author

@alicefr alicefr Nov 3, 2023

Choose a reason for hiding this comment

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

The containers aren't pointers, so, I don't think that modifying the compute object will be reflected in the containers array. AFAIU, they are full copies

pkg/virt-controller/services/template_test.go Show resolved Hide resolved
@victortoso
Copy link
Member

I have nothing to add, I think the code looks fine and the feature is very very helpful.
/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2023
@alicefr
Copy link
Member Author

alicefr commented Nov 13, 2023

/test pull-kubevirt-e2e-k8s-1.27-sig-storage

Copy link
Contributor

@vasiliy-ul vasiliy-ul left a comment

Choose a reason for hiding this comment

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

Sorry for the delay :)

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vasiliy-ul

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 13, 2023
@kubevirt-bot kubevirt-bot merged commit b256dc4 into kubevirt:main Nov 13, 2023
37 checks passed
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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants