harvester / harvester

Open source hyperconverged infrastructure (HCI) software
https://harvesterhci.io/
Apache License 2.0
3.9k stars 328 forks source link

[BUG] IP address of VM not displayed in UI When ipv6 address is present on Pod Interface of VM #6955

Open rrajendran17 opened 3 weeks ago

rrajendran17 commented 3 weeks ago

Describe the bug IP address of the VM will not be displayed in GUI, when ipv6 is enabled on the Node and pod interface in the VM acquired a v6 address.

To Reproduce 1.Broadcast ipv6 address from devices connected to Harvester Node 2.Create a cluster network and create a vlan network with vlan id 3.Create a VM on a vlan network 4.pod interface of the VM will acquire an ipv6 address 5.VM interface in the guest os will have ipv4 address acquired from DHCP 6.VM interface in the guest os will have ipv6 address

Expected behavior Harvester UI should show the ipv4 address of the VM interface

Actual Behaviour: Since the vmi gets only the ipv6 address of the pod interface of VM, UI filters it and shows empty in harvester UI for vm ip address.

Environment

Kubevirt version: v1.1.1

Additional context The following Kubevirt changes introduced in v1.1.1 is causing this issue

https://github.com/kubevirt/kubevirt/pull/10799

To confirm if https://github.com/kubevirt/kubevirt/pull/10799 from kubevirt changes is causing the issue, we performed the following experiment

and it confirms the above is the reason causing this issue when ipv6 address is enabled on pod interface and vm interface.

Note:This issue will be seen only in the case where podInterface inside the vm pod is having an ipv6 address during start up.

       This address will be stored in podCache during initial update of vmi status.

1.disable the ipv6 address on the pod interface in vm pod sysctl -w net.ipv6.conf..disable_ipv6 = 1 2.check if there is no ip addresses on pod interface on vm pod kubectl exec -it /bin/bash ip addr show 3.Remove all ip addresses on the eth0/enp1s0 interface of vm guest os 4.step 3, will make sure to wipe all ips for enp1s0 on vmi status (https://github.com/kubevirt/kubevirt/blob/03c48fca9dcb9b1c27518fed20faa9648c04acb5/pkg/network/setup/netstat.go#L282)

5.verify "kubectl get vmi -o yaml vmi.Status.Interfaces will show interface eth0/enp1s0 with no ip addresses. 6.Now try to add ip address on the eth0/enp1s0 interface of vm guest os 7.step 6, will trigger updateStatus where vmi should be updated with ip address received fro qemu-ga.

But we observed the old ipv6 address on the pod interface was again getting updated on the vmi status.It is due to the following reason.

https://github.com/kubevirt/kubevirt/blob/03c48fca9dcb9b1c27518fed20faa9648c04acb5/pkg/network/setup/netstat.go#L149

The above code will copy the ips from the podCache which was stored the first time when pod came up.Later when qemu-ga tries to update the vmi status, but since ifaceStatus.IP == "" its already populated from updateIfacesStatusFromPodCache, ip from qemu-ga will not be updated.

https://github.com/kubevirt/kubevirt/blob/03c48fca9dcb9b1c27518fed20faa9648c04acb5/pkg/network/setup/netstat.go#L282

Workaround is to disable ipv6 entirely before startup, so that pod interfaces do not acquire any ipv6 address and also to disable ipv6 on vm guest os.

rrajendran17 commented 2 weeks ago

This requires a kubevirt fix.