feat: Support Kata mounts with virtio-blk - #3805
Conversation
63ffc47 to
f1a42b1
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sprt The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @sprt! |
|
Hi @sprt. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
f1a42b1 to
7b8671f
Compare
22aab7a to
e90ea3b
Compare
|
/ok-to-test |
There was a problem hiding this comment.
🟡 Changes recommended
DirectVolume correctness issues and the missing packaged Helm chart update must be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds experimental Kata Containers virtio-blk support through Kata’s DirectVolume API.
Changes:
- Adds Kata-aware direct-volume lifecycle handling.
- Adds RBAC, hostPath, pod metadata, tests, and documentation.
- Vendors the Kata DirectVolume dependency.
File summaries
| File | Summary |
|---|---|
vendor/modules.txt |
Updates vendored module metadata. |
vendor/github.com/kata-containers/kata-containers/src/runtime/pkg/direct-volume/utils.go |
Vendors DirectVolume utilities. |
vendor/github.com/kata-containers/kata-containers/src/runtime/LICENSE |
Adds dependency licensing. |
README.md |
Links Kata mount documentation. |
pkg/azuredisk/nodeserver.go |
Implements Kata volume lifecycle handling. |
pkg/azuredisk/nodeserver_test.go |
Tests Kata node operations. |
pkg/azuredisk/kata.go |
Implements Kata detection and DirectVolume integration. |
pkg/azuredisk/fake_azuredisk.go |
Adds a fake DirectVolume service. |
pkg/azuredisk/fake_azuredisk_test.go |
Tests the fake service. |
pkg/azuredisk/azuredisk.go |
Initializes DirectVolume support. |
go.sum |
Records dependency checksums. |
go.mod |
Adds the Kata dependency. |
docs/kata-mount.md |
Documents setup and limitations. |
deploy/rbac-csi-azuredisk-node.yaml |
Grants pod and RuntimeClass reads. |
deploy/csi-azuredisk-node.yaml |
Mounts DirectVolume metadata storage. |
deploy/csi-azuredisk-driver.yaml |
Enables pod metadata. |
charts/latest/azuredisk-csi-driver/templates/rbac-csi-azuredisk-node.yaml |
Mirrors RBAC changes in Helm. |
charts/latest/azuredisk-csi-driver/templates/csi-azuredisk-node.yaml |
Mirrors hostPath changes in Helm. |
charts/latest/azuredisk-csi-driver/templates/csi-azuredisk-driver.yaml |
Enables pod metadata in Helm. |
Review details
- Files reviewed: 15/20 changed files
- Comments generated: 7
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| snapshot: "{{ .Values.snapshot.image.csiSnapshotter.tag }}" | ||
| spec: | ||
| attachRequired: true | ||
| podInfoOnMount: false |
There was a problem hiding this comment.
add a .Values.node.enableKataCCMount feature flag to decide whether enable or not here
| name: sys-devices-dir | ||
| - mountPath: /sys/class/ | ||
| name: sys-class | ||
| - mountPath: /run/kata-containers/shared/direct-volumes |
There was a problem hiding this comment.
this should be protected by new feature flag: .Values.node.enableKataCCMount
| path: /sys/class/ | ||
| type: Directory | ||
| name: sys-class | ||
| - hostPath: |
There was a problem hiding this comment.
this should be protected by new feature flag: .Values.node.enableKataCCMount
| - apiGroups: [""] | ||
| resources: ["nodes"] | ||
| verbs: ["get", "patch"] | ||
| - apiGroups: [""] |
There was a problem hiding this comment.
this should be protected by new feature flag: .Values.node.enableKataCCMount
| annotation on your Kata Containers RuntimeClass: | ||
|
|
||
| ```yaml | ||
| azure.csi.disk/kata-mount: direct-volume |
There was a problem hiding this comment.
would you add more explanation as an example with the required annotation here?
| ## Limitations | ||
|
|
||
| * Virtio-blk requires exclusive access to the Azure Disk and the volume | ||
| needs to have the `ReadWriteOncePod` access mode. Otherwise the |
There was a problem hiding this comment.
have the ReadWriteOncePod access mode instead of ReadWriteOnce access mode
| err = preparePublishPath(target, d.mounter) | ||
| if err != nil { | ||
| return nil, status.Error(codes.Internal, fmt.Sprintf("Target path could not be prepared: %v", err)) | ||
| if kataPod, err := kataGetMountPod(ctx, d.kubeClient, params); err != nil { |
There was a problem hiding this comment.
pls also add enableKataCCMount flag in the driver, ref: https://github.com/kubernetes-sigs/azurefile-csi-driver/blob/022c14a4f34207de234477ad36751aeb412e71ca/pkg/azurefile/nodeserver.go#L192
There was a problem hiding this comment.
Done - named it enableKataMount because this is not Kata-CC-specific
There was a problem hiding this comment.
🔵 Needs a closer look
Direct mounts currently mishandle read-only requests, filesystem normalization, raw block semantics, and partitioned disks.
Review details
Suppressed comments (4)
pkg/azuredisk/nodeserver.go:279
- The Kata path reimplements filesystem resolution instead of using
resolveFSType. This leaves values such asXFSunnormalized (sonouuidis also omitted) and assigns the defaultext4filesystem to raw block capabilities, contradicting the block semantics enforced during staging. ReuseresolveFSTypehere so the metadata matches the device that was staged.
// Get fsType that the volume will be formatted and mounted with
fstype := getDefaultFsType()
var mountFlags []string
if mnt := volumeCapability.GetMount(); mnt != nil {
if mnt.FsType != "" {
pkg/azuredisk/nodeserver.go:292
req.Readonlyis not propagated to the direct-volume mount options. Consequently, a filesystem requested read-only is mounted writable inside the Kata VM; several new success cases setReadonly: truewhile expecting options withoutro. Add the read-only option before constructingMountInfo.
fsGroup, fsGroupChangePolicy := getPodFSGroup(kataPod, volumeCapability, req.GetReadonly())
metadata := map[string]string{}
pkg/azuredisk/nodeserver.go:320
- This passes the whole disk even when
volumeAttributes.partitionwas used duringNodeStageVolume. In that case staging formatted/mounteddevice-partN, but Kata is instructed to mountdevice, so the guest mount fails against the partition table instead of the filesystem. Apply the same partition suffix for filesystem direct volumes.
mountInfo := directvolume.MountInfo{
VolumeType: kataDirectVolumeType,
Device: device,
FsType: fstype,
docs/kata-mount.md:10
- The sentence is missing “be.”
This virtio-blk integration can enabled by setting the following
- Files reviewed: 15/20 changed files
- Comments generated: 0 new
- Review effort level: Balanced
86d7e86 to
1b05456
Compare
Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
1b05456 to
c0395e7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Zero-valued fsGroup handling can break Kata mounts, and the setup documentation currently cannot enable the feature correctly.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 18/23 changed files
- Comments generated: 3
- Review effort level: Balanced
| if fsGroup != nil { | ||
| metadata[directvolume.FSGroupMetadataKey] = strconv.FormatInt(*fsGroup, 10) |
| This virtio-blk integration can be enabled by setting the following | ||
| annotation on your Kata Containers RuntimeClass: |
| metadata: | ||
| name: kata | ||
| annotations: | ||
| io.katacontainers.csi-mount: "direct-volume" |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Cc @andyzhangx who is aware of this.
This revives work from 2 years ago to better support Azure CSI with Kata Containers (micro-VM container runtime): https://github.com/kubernetes-sigs/azurefile-csi-driver/pulls?q=is%3Apr+author%3Aarc9693
By default, Kata passes the host-mounted filesystem to the pod VM via virtio-fs. Here, we teach the driver to pass the underlying block device to the pod VM via virtio-blk, which will then be mounted by Kata inside the pod VM. This improves performance significantly.
Dependencies:
Limitations:
The overall flow is:
azure.csi.disk/kata-mount: direct-volumeto their Kata RuntimeClass to opt into the new behavior. The goal is to gate the feature in the RuntimeClass (as opposed to Pod/StorageClass) for users to migrate easily.Implementation notes:
podInfoOnMount: truein the driver to enable probing the Pod RuntimeClass and fsGroup.Which issue(s) this PR fixes:
N/A
Requirements:
Special notes for your reviewer:
See above
Release note: