Skip to content

Commit

Permalink
Remove unused parameters from launcher
Browse files Browse the repository at this point in the history
Signed-off-by: L. Pivarc <lpivarc@redhat.com>
  • Loading branch information
xpivarc committed Aug 19, 2021
1 parent 47cce0c commit a6de356
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 125 deletions.
4 changes: 1 addition & 3 deletions cmd/virt-launcher/virt-launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/virt-controller/services/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
50 changes: 0 additions & 50 deletions pkg/virt-controller/services/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pkg/virt-launcher/virtwrap/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 5 additions & 12 deletions pkg/virt-launcher/virtwrap/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -130,7 +127,6 @@ type LibvirtDomainManager struct {
ovmfPath string
networkCacheStoreFactory cache.InterfaceCacheFactory
ephemeralDiskCreator ephemeraldisk.EphemeralDiskCreatorInterface
minimumPVCReserveBytes uint64
directIOChecker converter.DirectIOChecker
}

Expand Down Expand Up @@ -162,25 +158,22 @@ 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),
},
agentData: agentStore,
efiEnvironment: efi.DetectEFIEnvironment(runtime.GOARCH, ovmfPath),
networkCacheStoreFactory: cache.NewInterfaceCacheFactory(),
ephemeralDiskCreator: ephemeralDiskCreator,
minimumPVCReserveBytes: minimumPVCReserveBytes,
directIOChecker: directIOChecker,
}
manager.credManager = accesscredentials.NewManager(connection, &manager.domainModifyLock)
Expand Down
Loading

0 comments on commit a6de356

Please sign in to comment.