Skip to content

Commit

Permalink
VMI status, GuestOSInfo: Fix version field
Browse files Browse the repository at this point in the history
The VMI status.GuestOSInfo struct is filled by the virt-handler,
from values received in the Domain.

Currently, the `Version` field is pointing to the value of
the `VersionID` field.

Point it to the correct value.

Add the missing GuestOSInfo fields to the unit test.

Signed-off-by: Orel Misan <[email protected]>
  • Loading branch information
orelmisan committed Dec 25, 2023
1 parent 2c5e56f commit a93aec5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/virt-handler/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ func (d *VirtualMachineController) updateGuestInfoFromDomain(vmi *v1.VirtualMach

if vmi.Status.GuestOSInfo.Name != domain.Status.OSInfo.Name {
vmi.Status.GuestOSInfo.Name = domain.Status.OSInfo.Name
vmi.Status.GuestOSInfo.Version = domain.Status.OSInfo.VersionId
vmi.Status.GuestOSInfo.Version = domain.Status.OSInfo.Version
vmi.Status.GuestOSInfo.KernelRelease = domain.Status.OSInfo.KernelRelease
vmi.Status.GuestOSInfo.PrettyName = domain.Status.OSInfo.PrettyName
vmi.Status.GuestOSInfo.VersionID = domain.Status.OSInfo.VersionId
Expand Down
36 changes: 30 additions & 6 deletions pkg/virt-handler/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2978,23 +2978,47 @@ var _ = Describe("VirtualMachineInstance", func() {
vmi.UID = vmiTestUUID
vmi.ObjectMeta.ResourceVersion = "1"
vmi.Status.Phase = v1.Scheduled
guestOSName := "TestGuestOS"

vmi.Status.GuestOSInfo = v1.VirtualMachineInstanceGuestOSInfo{
Name: guestOSName,
}
const (
guestOSId = "fedora"
guestOSName = "Fedora Linux"
guestOSPrettyName = "Fedora Linux 35 (Cloud Edition)"
guestOSVersion = "35 (Cloud Edition)"
guestOSVersionId = "35"
guestOSMachine = "x86_64"
guestOSKernelRelease = "5.14.10-300.fc35.x86_64"
guestOSKernelVersion = "#1 SMP Thu Oct 7 20:48:44 UTC 2021"
)

vmi.Status.GuestOSInfo = v1.VirtualMachineInstanceGuestOSInfo{}

mockWatchdog.CreateFile(vmi)
domain := api.NewMinimalDomainWithUUID("testvmi", vmiTestUUID)
domain.Status.Status = api.Running

domain.Status.OSInfo = api.GuestOSInfo{Name: guestOSName}
domain.Status.OSInfo = api.GuestOSInfo{
Id: guestOSId,
Name: guestOSName,
PrettyName: guestOSPrettyName,
Version: guestOSVersion,
VersionId: guestOSVersionId,
Machine: guestOSMachine,
KernelRelease: guestOSKernelRelease,
KernelVersion: guestOSKernelVersion,
}

vmiFeeder.Add(vmi)
domainFeeder.Add(domain)

vmiInterface.EXPECT().Update(context.Background(), gomock.Any()).Do(func(ctx context.Context, arg interface{}) {
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.Name).To(Equal(guestOSName))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.ID).To(Equal(domain.Status.OSInfo.Id))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.Name).To(Equal(domain.Status.OSInfo.Name))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.PrettyName).To(Equal(domain.Status.OSInfo.PrettyName))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.Version).To(Equal(domain.Status.OSInfo.Version))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.VersionID).To(Equal(domain.Status.OSInfo.VersionId))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.Machine).To(Equal(domain.Status.OSInfo.Machine))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.KernelRelease).To(Equal(domain.Status.OSInfo.KernelRelease))
Expect(arg.(*v1.VirtualMachineInstance).Status.GuestOSInfo.KernelVersion).To(Equal(domain.Status.OSInfo.KernelVersion))
}).Return(vmi, nil)

controller.Execute()
Expand Down

0 comments on commit a93aec5

Please sign in to comment.