Skip to content

Commit 1add496

Browse files
sharath-srikanth-chellappaSharath Srikanth Chellappa
andauthored
Add upstream patch to kubevirt to force hp-volume- pod to respect blockdevices (IcM 467224770) (#7781)
Co-authored-by: Sharath Srikanth Chellappa <sharathsr@microsoft.com>
1 parent fd5e30e commit 1add496

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
From af25759a3205ac3cdf42254923e3e20cf336a4a0 Mon Sep 17 00:00:00 2001
2+
From: Vicente Cheng <vicente.cheng@suse.com>
3+
Date: Fri, 17 Feb 2023 17:23:06 +0800
4+
Subject: [PATCH] virt-controller: render hp-volume- pod should respect
5+
blockdevices
6+
7+
We found that the VolumeDevices does not generate as the first
8+
time we render on hp-volume- pod. That would cause the global path
9+
not to be generated by kubelet again when the hp-volume- is
10+
dead, then render again.
11+
12+
We should respect the VolumeDevics on the Spec. That would make
13+
kubelet behavior is the same as the first time when the hp-volume-
14+
pod is killed.
15+
16+
Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
17+
---
18+
pkg/virt-controller/services/template.go | 41 +++++++++++-------------
19+
1 file changed, 19 insertions(+), 22 deletions(-)
20+
21+
diff --git a/pkg/virt-controller/services/template.go b/pkg/virt-controller/services/template.go
22+
index 4fe5fdcd0374..d4f1fbae7840 100644
23+
--- a/pkg/virt-controller/services/template.go
24+
+++ b/pkg/virt-controller/services/template.go
25+
@@ -25,19 +25,14 @@ import (
26+
"strconv"
27+
"strings"
28+
29+
- "kubevirt.io/kubevirt/pkg/virt-controller/watch/topology"
30+
-
31+
- "k8s.io/kubectl/pkg/cmd/util/podcmd"
32+
- "k8s.io/utils/pointer"
33+
-
34+
+ networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
35+
k8sv1 "k8s.io/api/core/v1"
36+
"k8s.io/apimachinery/pkg/api/resource"
37+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
38+
"k8s.io/apimachinery/pkg/runtime/schema"
39+
"k8s.io/client-go/tools/cache"
40+
-
41+
- networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
42+
-
43+
+ "k8s.io/kubectl/pkg/cmd/util/podcmd"
44+
+ "k8s.io/utils/pointer"
45+
v1 "kubevirt.io/api/core/v1"
46+
exportv1 "kubevirt.io/api/export/v1alpha1"
47+
"kubevirt.io/client-go/kubecli"
48+
@@ -52,6 +47,7 @@ import (
49+
"kubevirt.io/kubevirt/pkg/util"
50+
"kubevirt.io/kubevirt/pkg/util/net/dns"
51+
virtconfig "kubevirt.io/kubevirt/pkg/virt-config"
52+
+ "kubevirt.io/kubevirt/pkg/virt-controller/watch/topology"
53+
"kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api"
54+
)
55+
56+
@@ -845,20 +841,21 @@ func (t *templateService) RenderHotplugAttachmentPodTemplate(volumes []*v1.Volum
57+
},
58+
},
59+
})
60+
- if !skipMount {
61+
- pvc := claimMap[volume.Name]
62+
- if pvc != nil {
63+
- if types.IsPVCBlock(pvc.Spec.VolumeMode) {
64+
- pod.Spec.Containers[0].VolumeDevices = append(pod.Spec.Containers[0].VolumeDevices, k8sv1.VolumeDevice{
65+
- Name: volume.Name,
66+
- DevicePath: fmt.Sprintf("/path/%s/%s", volume.Name, pvc.GetUID()),
67+
- })
68+
- } else {
69+
- pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, k8sv1.VolumeMount{
70+
- Name: volume.Name,
71+
- MountPath: fmt.Sprintf("/%s", volume.Name),
72+
- })
73+
- }
74+
+ pvc := claimMap[volume.Name]
75+
+ if pvc == nil {
76+
+ continue
77+
+ }
78+
+ if types.IsPVCBlock(pvc.Spec.VolumeMode) {
79+
+ pod.Spec.Containers[0].VolumeDevices = append(pod.Spec.Containers[0].VolumeDevices, k8sv1.VolumeDevice{
80+
+ Name: volume.Name,
81+
+ DevicePath: fmt.Sprintf("/path/%s/%s", volume.Name, pvc.GetUID()),
82+
+ })
83+
+ } else {
84+
+ if !skipMount {
85+
+ pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, k8sv1.VolumeMount{
86+
+ Name: volume.Name,
87+
+ MountPath: fmt.Sprintf("/%s", volume.Name),
88+
+ })
89+
}
90+
}
91+
}

SPECS/kubevirt/kubevirt.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Patch0: Cleanup-housekeeping-cgroup-on-vm-del.patch
3333
Patch1: Allocate-2-cpu-for-the-emulator-thread.patch
3434
Patch2: Hotplug_detach_grace_period.patch
3535
Patch3: CVE-2023-44487.patch
36+
Patch4: Hp-volume-pod-should-respect-blockdevices.patch
3637
%global debug_package %{nil}
3738
BuildRequires: glibc-devel
3839
BuildRequires: glibc-static >= 2.35-6%{?dist}
@@ -212,6 +213,9 @@ install -p -m 0644 cmd/virt-handler/nsswitch.conf %{buildroot}%{_datadir}/kube-v
212213
%{_bindir}/virt-tests
213214

214215
%changelog
216+
* Thu Feb 8 2024 Sharath Srikanth Chellappa <sharathsr@microsoft.com> - 0.59.0-12
217+
- Add patch for render hp-volume- pod to respect blockdevices (IcM 467224770)
218+
215219
* Thu Feb 01 2024 Daniel McIlvaney <damcilva@microsoft.com> - 0.59.0-12
216220
- Address CVE-2023-44487 by patching vendored golang.org/x/net
217221

0 commit comments

Comments
 (0)