diff --git a/cmd/virt-launcher/virt-launcher.go b/cmd/virt-launcher/virt-launcher.go index 62ab434c3d1c..3a8a6b6599b0 100644 --- a/cmd/virt-launcher/virt-launcher.go +++ b/cmd/virt-launcher/virt-launcher.go @@ -351,8 +351,6 @@ func main() { runWithNonRoot := pflag.Bool("run-as-nonroot", false, "Run libvirtd with the 'virt' user") hookSidecars := pflag.Uint("hook-sidecars", 0, "Number of requested hook sidecars, virt-launcher will wait for all of them to become available") noFork := pflag.Bool("no-fork", false, "Fork and let virt-launcher watch itself to react to crashes if set to false") - lessPVCSpaceToleration := pflag.Int("less-pvc-space-toleration", 0, "Toleration in percent when PVs' available space is smaller than requested") - minimumPVCReserveBytes := pflag.Uint64("minimum-pvc-reserve-bytes", 131072, "Minimum reserve to keep empty on PVC during auto-provision of disk.img") ovmfPath := pflag.String("ovmf-path", "/usr/share/OVMF", "The directory that contains the EFI roms (like OVMF_CODE.fd)") qemuAgentSysInterval := pflag.Duration("qemu-agent-sys-interval", 120, "Interval in seconds between consecutive qemu agent calls for sys commands") qemuAgentFileInterval := pflag.Duration("qemu-agent-file-interval", 300, "Interval in seconds between consecutive qemu agent calls for file command") @@ -436,7 +434,7 @@ func main() { notifier := notifyclient.NewNotifier(*virtShareDir) defer notifier.Close() - domainManager, err := virtwrap.NewLibvirtDomainManager(domainConn, *virtShareDir, notifier, *lessPVCSpaceToleration, *minimumPVCReserveBytes, &agentStore, *ovmfPath, ephemeralDiskCreator) + domainManager, err := virtwrap.NewLibvirtDomainManager(domainConn, *virtShareDir, &agentStore, *ovmfPath, ephemeralDiskCreator) if err != nil { panic(err) } diff --git a/pkg/virt-controller/services/template.go b/pkg/virt-controller/services/template.go index b8c1d38323fa..7304b3e21307 100644 --- a/pkg/virt-controller/services/template.go +++ b/pkg/virt-controller/services/template.go @@ -996,8 +996,6 @@ func (t *templateService) renderLaunchManifest(vmi *v1.VirtualMachineInstance, t resources.Limits[k8sv1.ResourceMemory] = *resources.Requests.Memory() } - lessPVCSpaceToleration := t.clusterConfig.GetLessPVCSpaceToleration() - reservePVCBytes := t.clusterConfig.GetMinimumReservePVCBytes() ovmfPath := t.clusterConfig.GetOVMFPath() var command []string @@ -1018,8 +1016,6 @@ func (t *templateService) renderLaunchManifest(vmi *v1.VirtualMachineInstance, t "--container-disk-dir", t.containerDiskDir, "--grace-period-seconds", strconv.Itoa(int(gracePeriodSeconds)), "--hook-sidecars", strconv.Itoa(len(requestedHookSidecarList)), - "--less-pvc-space-toleration", strconv.Itoa(lessPVCSpaceToleration), - "--minimum-pvc-reserve-bytes", strconv.FormatUint(reservePVCBytes, 10), "--ovmf-path", ovmfPath, } if nonRoot { diff --git a/pkg/virt-controller/services/template_test.go b/pkg/virt-controller/services/template_test.go index bde8decb7b35..c06c95aa3fd3 100644 --- a/pkg/virt-controller/services/template_test.go +++ b/pkg/virt-controller/services/template_test.go @@ -378,8 +378,6 @@ var _ = Describe("Template", func() { "--container-disk-dir", "/var/run/kubevirt/container-disks", "--grace-period-seconds", "45", "--hook-sidecars", "1", - "--less-pvc-space-toleration", "10", - "--minimum-pvc-reserve-bytes", "131072", "--ovmf-path", ovmfPath})) Expect(pod.Spec.Containers[1].Name).To(Equal("hook-sidecar-0")) Expect(pod.Spec.Containers[1].Image).To(Equal("some-image:v1")) @@ -1084,8 +1082,6 @@ var _ = Describe("Template", func() { "--container-disk-dir", "/var/run/kubevirt/container-disks", "--grace-period-seconds", "45", "--hook-sidecars", "1", - "--less-pvc-space-toleration", "10", - "--minimum-pvc-reserve-bytes", "131072", "--ovmf-path", ovmfPath})) Expect(pod.Spec.Containers[1].Name).To(Equal("hook-sidecar-0")) Expect(pod.Spec.Containers[1].Image).To(Equal("some-image:v1")) @@ -2860,52 +2856,6 @@ var _ = Describe("Template", func() { }) }) - It("should add the lessPVCSpaceToleration argument to the template", func() { - config, kvInformer, svc = configFactory(defaultArch) - kvConfig := kv.DeepCopy() - kvConfig.Spec.Configuration.DeveloperConfiguration.LessPVCSpaceToleration = 42 - testutils.UpdateFakeKubeVirtClusterConfig(kvInformer, kvConfig) - - vmi := v1.VirtualMachineInstance{ - ObjectMeta: metav1.ObjectMeta{ - Name: "testvmi", Namespace: "default", UID: "1234", - }, - Spec: v1.VirtualMachineInstanceSpec{Volumes: []v1.Volume{}, Domain: v1.DomainSpec{ - Devices: v1.Devices{ - DisableHotplug: true, - }, - }}, - } - pod, err := svc.RenderLaunchManifest(&vmi) - Expect(err).ToNot(HaveOccurred()) - - Expect(pod.Spec.Containers[0].Command).To(ContainElement("--less-pvc-space-toleration"), "command arg key should be correct") - Expect(pod.Spec.Containers[0].Command).To(ContainElement("42"), "command arg value should be correct") - }) - - It("should add the minimum PVC reserve argument to the template", func() { - config, kvInformer, svc = configFactory(defaultArch) - kvConfig := kv.DeepCopy() - kvConfig.Spec.Configuration.DeveloperConfiguration = &v1.DeveloperConfiguration{MinimumReservePVCBytes: 1048576} - testutils.UpdateFakeKubeVirtClusterConfig(kvInformer, kvConfig) - - vmi := v1.VirtualMachineInstance{ - ObjectMeta: metav1.ObjectMeta{ - Name: "testvmi", Namespace: "default", UID: "1234", - }, - Spec: v1.VirtualMachineInstanceSpec{Volumes: []v1.Volume{}, Domain: v1.DomainSpec{ - Devices: v1.Devices{ - DisableHotplug: true, - }, - }}, - } - pod, err := svc.RenderLaunchManifest(&vmi) - Expect(err).ToNot(HaveOccurred()) - - Expect(pod.Spec.Containers[0].Command).To(ContainElement("--minimum-pvc-reserve-bytes"), "command arg key should be correct") - Expect(pod.Spec.Containers[0].Command).To(ContainElement("1048576"), "command arg value should be correct") - }) - Context("with specified priorityClass", func() { It("should add priorityClass", func() { config, kvInformer, svc = configFactory(defaultArch) diff --git a/pkg/virt-launcher/virtwrap/BUILD.bazel b/pkg/virt-launcher/virtwrap/BUILD.bazel index 33c456463b96..a049e8e17ed1 100644 --- a/pkg/virt-launcher/virtwrap/BUILD.bazel +++ b/pkg/virt-launcher/virtwrap/BUILD.bazel @@ -26,7 +26,6 @@ go_library( "//pkg/util/net/ip:go_default_library", "//pkg/virt-handler/cmd-client:go_default_library", "//pkg/virt-handler/migration-proxy:go_default_library", - "//pkg/virt-launcher/notify-client:go_default_library", "//pkg/virt-launcher/virtwrap/access-credentials:go_default_library", "//pkg/virt-launcher/virtwrap/agent:go_default_library", "//pkg/virt-launcher/virtwrap/agent-poller:go_default_library", diff --git a/pkg/virt-launcher/virtwrap/manager.go b/pkg/virt-launcher/virtwrap/manager.go index eac62dd8bba2..1ca2dac29674 100644 --- a/pkg/virt-launcher/virtwrap/manager.go +++ b/pkg/virt-launcher/virtwrap/manager.go @@ -39,7 +39,6 @@ import ( "kubevirt.io/kubevirt/pkg/downwardmetrics" "kubevirt.io/kubevirt/pkg/network/cache" cmdclient "kubevirt.io/kubevirt/pkg/virt-handler/cmd-client" - eventsclient "kubevirt.io/kubevirt/pkg/virt-launcher/notify-client" "kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/agent" "kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/converter" "kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/efi" @@ -120,8 +119,6 @@ type LibvirtDomainManager struct { credManager *accesscredentials.AccessCredentialManager virtShareDir string - notifier *eventsclient.Notifier - lessPVCSpaceToleration int paused pausedVMIs agentData *agentpoller.AsyncAgentStore cloudInitDataStore *cloudinit.CloudInitData @@ -130,7 +127,6 @@ type LibvirtDomainManager struct { ovmfPath string networkCacheStoreFactory cache.InterfaceCacheFactory ephemeralDiskCreator ephemeraldisk.EphemeralDiskCreatorInterface - minimumPVCReserveBytes uint64 directIOChecker converter.DirectIOChecker } @@ -162,17 +158,15 @@ func (s pausedVMIs) contains(uid types.UID) bool { return ok } -func NewLibvirtDomainManager(connection cli.Connection, virtShareDir string, notifier *eventsclient.Notifier, lessPVCSpaceToleration int, minimumPVCReserveBytes uint64, agentStore *agentpoller.AsyncAgentStore, ovmfPath string, ephemeralDiskCreator ephemeraldisk.EphemeralDiskCreatorInterface) (DomainManager, error) { +func NewLibvirtDomainManager(connection cli.Connection, virtShareDir string, agentStore *agentpoller.AsyncAgentStore, ovmfPath string, ephemeralDiskCreator ephemeraldisk.EphemeralDiskCreatorInterface) (DomainManager, error) { directIOChecker := converter.NewDirectIOChecker() - return newLibvirtDomainManager(connection, virtShareDir, notifier, lessPVCSpaceToleration, minimumPVCReserveBytes, agentStore, ovmfPath, ephemeralDiskCreator, directIOChecker) + return newLibvirtDomainManager(connection, virtShareDir, agentStore, ovmfPath, ephemeralDiskCreator, directIOChecker) } -func newLibvirtDomainManager(connection cli.Connection, virtShareDir string, notifier *eventsclient.Notifier, lessPVCSpaceToleration int, minimumPVCReserveBytes uint64, agentStore *agentpoller.AsyncAgentStore, ovmfPath string, ephemeralDiskCreator ephemeraldisk.EphemeralDiskCreatorInterface, directIOChecker converter.DirectIOChecker) (DomainManager, error) { +func newLibvirtDomainManager(connection cli.Connection, virtShareDir string, agentStore *agentpoller.AsyncAgentStore, ovmfPath string, ephemeralDiskCreator ephemeraldisk.EphemeralDiskCreatorInterface, directIOChecker converter.DirectIOChecker) (DomainManager, error) { manager := LibvirtDomainManager{ - virConn: connection, - virtShareDir: virtShareDir, - notifier: notifier, - lessPVCSpaceToleration: lessPVCSpaceToleration, + virConn: connection, + virtShareDir: virtShareDir, paused: pausedVMIs{ paused: make(map[types.UID]bool, 0), }, @@ -180,7 +174,6 @@ func newLibvirtDomainManager(connection cli.Connection, virtShareDir string, not efiEnvironment: efi.DetectEFIEnvironment(runtime.GOARCH, ovmfPath), networkCacheStoreFactory: cache.NewInterfaceCacheFactory(), ephemeralDiskCreator: ephemeralDiskCreator, - minimumPVCReserveBytes: minimumPVCReserveBytes, directIOChecker: directIOChecker, } manager.credManager = accesscredentials.NewManager(connection, &manager.domainModifyLock) diff --git a/pkg/virt-launcher/virtwrap/manager_test.go b/pkg/virt-launcher/virtwrap/manager_test.go index f19d5fbac6d4..2867bfc02acb 100644 --- a/pkg/virt-launcher/virtwrap/manager_test.go +++ b/pkg/virt-launcher/virtwrap/manager_test.go @@ -137,7 +137,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -158,7 +158,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_START_PAUSED).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -179,7 +179,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -199,7 +199,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -215,7 +215,7 @@ var _ = Describe("Manager", func() { mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -233,7 +233,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(state, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -255,7 +255,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_PAUSED, 1, nil) mockDomain.EXPECT().Resume().Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -271,7 +271,7 @@ var _ = Describe("Manager", func() { mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockDomain.EXPECT().Suspend().Return(nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) err = manager.PauseVMI(vmi) Expect(err).To(BeNil()) @@ -294,7 +294,7 @@ var _ = Describe("Manager", func() { mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockDomain.EXPECT().Suspend().Return(nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) err := manager.PauseVMI(vmi) Expect(err).To(BeNil()) @@ -306,7 +306,7 @@ var _ = Describe("Manager", func() { mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_PAUSED, 1, nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) // no call to suspend err := manager.PauseVMI(vmi) @@ -332,7 +332,7 @@ var _ = Describe("Manager", func() { func() { isFreeCalled <- true }) - manager, _ := NewLibvirtDomainManager(mockConn, "fake", nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, "fake", nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) err := manager.UnpauseVMI(vmi) Expect(err).To(BeNil()) @@ -360,7 +360,7 @@ var _ = Describe("Manager", func() { mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_RUNNING, 1, nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) // no call to unpause err := manager.UnpauseVMI(vmi) Expect(err).To(BeNil()) @@ -429,7 +429,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xmlDomain), nil) - manager, _ := newLibvirtDomainManager(mockConn, "fake", nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) + manager, _ := newLibvirtDomainManager(mockConn, "fake", nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{ VirtualMachineSMBios: &cmdv1.SMBios{}, PreallocatedVolumes: []string{"permvolume1"}, @@ -561,7 +561,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().AttachDevice(strings.ToLower(string(attachBytes))) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xmlDomain2), nil) - manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) + manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -671,7 +671,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().DetachDevice(strings.ToLower(string(detachBytes))) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xmlDomain), nil) - manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) + manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -750,7 +750,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xmlDomain), nil) - manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) + manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -851,7 +851,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_SHUTDOWN, 1, nil) mockDomain.EXPECT().CreateWithFlags(libvirt.DOMAIN_NONE).Return(nil) mockDomain.EXPECT().GetXMLDesc(libvirt.DomainXMLFlags(0)).MaxTimes(2).Return(string(xmlDomain2), nil) - manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) + manager, _ := newLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock, mockDirectIOChecker) newspec, err := manager.SyncVMI(vmi, true, &cmdv1.VirtualMachineOptions{VirtualMachineSMBios: &cmdv1.SMBios{}}) Expect(err).To(BeNil()) Expect(newspec).ToNot(BeNil()) @@ -882,7 +882,7 @@ var _ = Describe("Manager", func() { Expect(strings.Contains(xml, "true")).To(BeTrue()) return mockDomain, nil }) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) manager.MarkGracefulShutdownVMI(vmi) }) @@ -906,7 +906,7 @@ var _ = Describe("Manager", func() { Return(`36002021-03-11T09:08:20.144606353Ztrue`, nil) mockDomain.EXPECT().ShutdownFlags(libvirt.DOMAIN_SHUTDOWN_ACPI_POWER_BTN).Times(1).Return(nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) manager.SignalShutdownVMI(vmi) }) @@ -937,10 +937,8 @@ var _ = Describe("Manager", func() { xml, err := xml.MarshalIndent(domainSpec, "", "\t") Expect(err).To(BeNil()) manager := &LibvirtDomainManager{ - virConn: mockConn, - virtShareDir: testVirtShareDir, - notifier: nil, - lessPVCSpaceToleration: 0, + virConn: mockConn, + virtShareDir: testVirtShareDir, } mockDomain.EXPECT().GetState().AnyTimes().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) @@ -984,10 +982,8 @@ var _ = Describe("Manager", func() { xml, err := xml.MarshalIndent(domainSpec, "", "\t") Expect(err).To(BeNil()) manager := &LibvirtDomainManager{ - virConn: mockConn, - virtShareDir: testVirtShareDir, - notifier: nil, - lessPVCSpaceToleration: 0, + virConn: mockConn, + virtShareDir: testVirtShareDir, } mockDomain.EXPECT().GetState().AnyTimes().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) @@ -1038,10 +1034,8 @@ var _ = Describe("Manager", func() { domainSpec := expectIsolationDetectionForVMI(vmi) manager := &LibvirtDomainManager{ - virConn: mockConn, - virtShareDir: testVirtShareDir, - notifier: nil, - lessPVCSpaceToleration: 0, + virConn: mockConn, + virtShareDir: testVirtShareDir, } mockDomain.EXPECT().GetState().AnyTimes().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) @@ -1099,7 +1093,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().AbortJob().MaxTimes(1) mockDomain.EXPECT().GetXMLDesc(gomock.Eq(libvirt.DOMAIN_XML_MIGRATABLE)).AnyTimes().Return(string(xml), nil) mockDomain.EXPECT().GetXMLDesc(gomock.Eq(libvirt.DOMAIN_XML_INACTIVE)).AnyTimes().Return(string(xml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) manager.CancelVMIMigration(vmi) }) @@ -1134,7 +1128,7 @@ var _ = Describe("Manager", func() { AnyTimes(). Return(string(metadataXml), nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) err = manager.CancelVMIMigration(vmi) Expect(err).To(BeNil()) }) @@ -1186,10 +1180,8 @@ var _ = Describe("Manager", func() { AnyTimes(). Return(string(metadataXml), nil) manager := &LibvirtDomainManager{ - virConn: mockConn, - virtShareDir: testVirtShareDir, - notifier: nil, - lessPVCSpaceToleration: 0, + virConn: mockConn, + virtShareDir: testVirtShareDir, } mockDomain.EXPECT().GetState().AnyTimes().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) @@ -1261,10 +1253,8 @@ var _ = Describe("Manager", func() { AnyTimes(). Return(string(metadataXml), nil) manager := &LibvirtDomainManager{ - virConn: mockConn, - virtShareDir: testVirtShareDir, - notifier: nil, - lessPVCSpaceToleration: 0, + virConn: mockConn, + virtShareDir: testVirtShareDir, } mockDomain.EXPECT().GetState().AnyTimes().Return(libvirt.DOMAIN_RUNNING, 1, nil) mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) @@ -1309,7 +1299,7 @@ var _ = Describe("Manager", func() { TargetPod: "fakepod", } - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) err := manager.PrepareMigrationTarget(vmi, true) Expect(err).To(BeNil()) }) @@ -1338,7 +1328,7 @@ var _ = Describe("Manager", func() { domainSpec := expectIsolationDetectionForVMI(vmi) domainSpec.Metadata.KubeVirt.Migration = &api.MigrationMetadata{} - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) mockConn.EXPECT().LookupDomainByName(testDomainName).AnyTimes().Return(mockDomain, nil) mockDomain.EXPECT().GetState().AnyTimes().Return(libvirt.DOMAIN_RUNNING, 1, nil) @@ -1396,7 +1386,7 @@ var _ = Describe("Manager", func() { UID: vmi.Status.MigrationState.MigrationUID, } - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) @@ -1508,7 +1498,7 @@ var _ = Describe("Manager", func() { mockDomain.EXPECT().Free() mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().UndefineFlags(libvirt.DOMAIN_UNDEFINE_NVRAM).Return(nil) - manager, _ := NewLibvirtDomainManager(mockConn, "fake", nil, 0, 0, nil, "/usr/share/", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, "fake", nil, "/usr/share/", ephemeralDiskCreatorMock) err := manager.DeleteVMI(newVMI(testNamespace, testVmName)) Expect(err).To(BeNil()) }, @@ -1522,7 +1512,7 @@ var _ = Describe("Manager", func() { mockConn.EXPECT().LookupDomainByName(testDomainName).Return(mockDomain, nil) mockDomain.EXPECT().GetState().Return(state, 1, nil) mockDomain.EXPECT().DestroyFlags(libvirt.DOMAIN_DESTROY_GRACEFUL).Return(nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) err := manager.KillVMI(newVMI(testNamespace, testVmName)) Expect(err).To(BeNil()) }, @@ -1584,7 +1574,7 @@ var _ = Describe("Manager", func() { AnyTimes(). Return("", nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) doms, err := manager.ListAllDomains() Expect(err).NotTo(HaveOccurred()) @@ -1614,7 +1604,7 @@ var _ = Describe("Manager", func() { {}, }, nil) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) domStats, err := manager.GetDomainStats() Expect(err).To(BeNil()) @@ -1624,7 +1614,7 @@ var _ = Describe("Manager", func() { Context("on failed GetDomainSpecWithRuntimeInfo", func() { It("should fall back to returning domain spec without runtime info", func() { - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) mockDomain.EXPECT().GetState().Return(libvirt.DOMAIN_RUNNING, 1, nil) @@ -1657,7 +1647,7 @@ var _ = Describe("Manager", func() { BeforeEach(func() { agentStore = agentpoller.NewAsyncAgentStore() - libvirtmanager, _ = NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) + libvirtmanager, _ = NewLibvirtDomainManager(mockConn, testVirtShareDir, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) }) It("should report nil when no OS info exists in the cache", func() { @@ -1695,7 +1685,7 @@ var _ = Describe("Manager", func() { BeforeEach(func() { agentStore = agentpoller.NewAsyncAgentStore() - libvirtmanager, _ = NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) + libvirtmanager, _ = NewLibvirtDomainManager(mockConn, testVirtShareDir, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) }) It("should return nil when no interfaces exists in the cache, nor as argument", func() { @@ -1745,7 +1735,7 @@ var _ = Describe("Manager", func() { defer os.Unsetenv("KUBEVIRT_RESOURCE_NAME_test1") defer os.Unsetenv("PCIDEVICE_127_0_0_1") - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, "/usr/share/OVMF", ephemeralDiskCreatorMock) // we need the non-typecast object to make the function we want to test available libvirtmanager := manager.(*LibvirtDomainManager) @@ -1801,7 +1791,7 @@ var _ = Describe("Manager", func() { }, }) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) // we need the non-typecast object to make the function we want to test available libvirtmanager := manager.(*LibvirtDomainManager) @@ -1821,7 +1811,7 @@ var _ = Describe("Manager", func() { }, }) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) // we need the non-typecast object to make the function we want to test available libvirtmanager := manager.(*LibvirtDomainManager) @@ -1843,7 +1833,7 @@ var _ = Describe("Manager", func() { }, }) - manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, nil, 0, 0, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) + manager, _ := NewLibvirtDomainManager(mockConn, testVirtShareDir, &agentStore, "/usr/share/OVMF", ephemeralDiskCreatorMock) // we need the non-typecast object to make the function we want to test available libvirtmanager := manager.(*LibvirtDomainManager)