Skip to content

Commit

Permalink
Merge pull request #2169 from ahadas/default_memory
Browse files Browse the repository at this point in the history
Easy fixes
  • Loading branch information
Artyom Lukianov committed Apr 7, 2019
2 parents ebe9902 + e8361aa commit 77bd6a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/api/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ func SetDefaults_Firmware(obj *Firmware) {
func SetDefaults_VirtualMachineInstance(obj *VirtualMachineInstance) {
// FIXME we need proper validation and configurable defaulting instead of this
if _, exists := obj.Spec.Domain.Resources.Requests[v1.ResourceMemory]; !exists {
obj.Spec.Domain.Resources.Requests = v1.ResourceList{
v1.ResourceMemory: resource.MustParse("8192Ki"),
if obj.Spec.Domain.Resources.Requests == nil {
obj.Spec.Domain.Resources.Requests = v1.ResourceList{}
}
obj.Spec.Domain.Resources.Requests[v1.ResourceMemory] = resource.MustParse("8192Ki")
}
if obj.Spec.Domain.Firmware == nil {
obj.Spec.Domain.Firmware = &Firmware{}
Expand Down
1 change: 1 addition & 0 deletions pkg/virt-controller/watch/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ func (c *VMController) setupVMIFromVM(vm *virtv1.VirtualMachine) *virtv1.Virtual
vmi.ObjectMeta = vm.Spec.Template.ObjectMeta
vmi.ObjectMeta.Name = basename
vmi.ObjectMeta.GenerateName = basename
vmi.ObjectMeta.Namespace = vm.ObjectMeta.Namespace
vmi.Spec = vm.Spec.Template.Spec

setupStableFirmwareUUID(vm, vmi)
Expand Down
3 changes: 1 addition & 2 deletions tests/vmi_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,7 @@ var _ = Describe("Configurations", func() {
vmi = tests.NewRandomVMIWithEphemeralDisk(tests.ContainerDiskFor(tests.ContainerDiskAlpine))
vmi.Spec.Domain.Resources = v1.ResourceRequirements{
Requests: kubev1.ResourceList{
kubev1.ResourceCPU: resource.MustParse("800m"),
kubev1.ResourceMemory: resource.MustParse("64M"),
kubev1.ResourceCPU: resource.MustParse("800m"),
},
}
vmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
Expand Down

0 comments on commit 77bd6a5

Please sign in to comment.