Skip to content

Commit 8d9d3d1

Browse files
committed
chore(module): rename containers to support integrity checks
1. Rename containers of kubevirt Pods, cdi Pods and dvcr Pods created in non-system namespaces (namespaces without d8- prefix). 2. Mount container-disk binary into /var/run in container with user uploaded image (support attaching cvi, vi to vm). Related PRs: deckhouse/3p-kubevirt#19 deckhouse/3p-containerized-data-importer#17 Signed-off-by: Ivan Mikheykin <[email protected]>
1 parent 6a151e6 commit 8d9d3d1

File tree

9 files changed

+26
-17
lines changed

9 files changed

+26
-17
lines changed

.werf/defines/images.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ Result:
4646
{{- end }}
4747
{{- end -}}
4848
{{- end }}
49-
{{ end }}
49+
{{ end }}

build/components/versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ firmware:
33
libvirt: v10.9.0
44
edk2: stable202411
55
core:
6-
3p-kubevirt: v1.3.1-v12n.11
7-
3p-containerized-data-importer: v1.60.3-v12n.9
6+
3p-kubevirt: v1.3.1-v12n.12
7+
3p-containerized-data-importer: v1.60.3-v12n.10
88
distribution: 2.8.3
99
package:
1010
acl: v2.3.1

images/virtualization-artifact/pkg/audit/events/vm/vm_control.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/deckhouse/deckhouse/pkg/log"
2626
"github.com/deckhouse/virtualization-controller/pkg/audit/events"
2727
"github.com/deckhouse/virtualization-controller/pkg/audit/util"
28+
vmutil "github.com/deckhouse/virtualization-controller/pkg/common/vm"
2829
)
2930

3031
func NewVMControl(options events.EventLoggerOptions) *VMControl {
@@ -73,7 +74,7 @@ func (m *VMControl) Fill() error {
7374

7475
var terminatedStatuses string
7576
for _, status := range pod.Status.ContainerStatuses {
76-
if status.Name == "compute" && status.State.Terminated != nil {
77+
if vmutil.IsComputeContainer(status.Name) && status.State.Terminated != nil {
7778
terminatedStatuses = status.State.Terminated.Message
7879
}
7980
}

images/virtualization-artifact/pkg/audit/events/vm/vm_control_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ var _ = Describe("VMOP Events", func() {
8686
Spec: corev1.PodSpec{
8787
Containers: []corev1.Container{
8888
{
89-
Name: "compute",
89+
Name: "d8v-compute",
9090
Image: "test-image",
9191
},
9292
},
@@ -95,7 +95,7 @@ var _ = Describe("VMOP Events", func() {
9595
Status: corev1.PodStatus{
9696
ContainerStatuses: []corev1.ContainerStatus{
9797
{
98-
Name: "compute",
98+
Name: "d8v-compute",
9999
State: corev1.ContainerState{Terminated: &corev1.ContainerStateTerminated{Message: "guest-shutdown"}},
100100
},
101101
},

images/virtualization-artifact/pkg/common/consts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const (
2323
OwnerUID = "OWNER_UID"
2424

2525
// BounderContainerName provides a constant to use as a name for bounder Container
26-
BounderContainerName = "bounder"
26+
BounderContainerName = "d8v-dvcr-bounder"
2727
// ImporterContainerName provides a constant to use as a name for importer Container
28-
ImporterContainerName = "importer"
28+
ImporterContainerName = "d8v-dvcr-importer"
2929
// UploaderContainerName provides a constant to use as a name for uploader Container
30-
UploaderContainerName = "uploader"
30+
UploaderContainerName = "d8v-dvcr-uploader"
3131
// UploaderPortName provides a constant to use as a port name for uploader Service
3232
UploaderPortName = "uploader"
3333
// UploaderPort provides a constant to use as a port for uploader Service

images/virtualization-artifact/pkg/common/vm/vm.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ limitations under the License.
1717
package vm
1818

1919
import (
20+
"strings"
21+
2022
virtv2 "github.com/deckhouse/virtualization/api/core/v1alpha2"
2123
)
2224

25+
// VMContainerNameSuffix - a name suffix for container with virt-launcher, libvirt and qemu processes.
26+
// Container name is "d8v-compute", but previous versions may have "compute" container.
27+
const VMContainerNameSuffix = "compute"
28+
2329
// CalculateCoresAndSockets calculates the number of sockets and cores per socket needed to achieve
2430
// the desired total number of CPU cores.
2531
// The function tries to minimize the number of sockets while ensuring the desired core count.
@@ -59,3 +65,7 @@ func ApprovalMode(vm *virtv2.VirtualMachine) virtv2.RestartApprovalMode {
5965
}
6066
return vm.Spec.Disruptions.RestartApprovalMode
6167
}
68+
69+
func IsComputeContainer(name string) bool {
70+
return strings.HasSuffix(name, VMContainerNameSuffix)
71+
}

images/virtualization-artifact/pkg/controller/powerstate/shutdown_reason.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ import (
2222

2323
corev1 "k8s.io/api/core/v1"
2424
kvv1 "kubevirt.io/api/core/v1"
25+
26+
vmutil "github.com/deckhouse/virtualization-controller/pkg/common/vm"
2527
)
2628

2729
type GuestSignalReason string
2830

2931
const (
30-
// DefaultVMContainerName - a container name with virt-launcher, libvirt and qemu processes.
31-
DefaultVMContainerName = "compute"
32-
3332
// GuestResetReason - a reboot command was issued from inside the VM.
3433
GuestResetReason GuestSignalReason = "guest-reset"
3534

@@ -65,10 +64,9 @@ func ShutdownReason(kvvmi *kvv1.VirtualMachineInstance, kvPods *corev1.PodList)
6564
return ShutdownInfo{}
6665
}
6766

68-
// Extract termination mesage from the "compute" container.
67+
// Extract termination message from the container with VM.
6968
for _, contStatus := range recentPod.Status.ContainerStatuses {
70-
// "compute" is a default container name for VM Pod.
71-
if contStatus.Name != DefaultVMContainerName {
69+
if !vmutil.IsComputeContainer(contStatus.Name) {
7270
continue
7371
}
7472
msg := ""

images/virtualization-artifact/pkg/controller/vm/internal/statistic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (h *StatisticHandler) syncResources(changed *virtv2.VirtualMachine,
125125
}
126126
var ctr corev1.Container
127127
for _, container := range pod.Spec.Containers {
128-
if container.Name == "compute" {
128+
if vm.IsComputeContainer(container.Name) {
129129
ctr = container
130130
}
131131
}

images/virtualization-artifact/pkg/controller/vm/internal/statistic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var _ = Describe("TestStatisticHandler", func() {
8989
NodeName: nodeName,
9090
Containers: []corev1.Container{
9191
{
92-
Name: "compute",
92+
Name: "d8v-compute",
9393
Resources: corev1.ResourceRequirements{
9494
Requests: corev1.ResourceList{
9595
corev1.ResourceCPU: resource.MustParse(requestCPU),

0 commit comments

Comments
 (0)