forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep original pod ip on a dummy interface
When kubelet is restarted, it goes over all pods, peeks in their respective network namespaces and tries to detect their IP in order to update their Pod objects. However, with the bridge binding mode, we move this IP address to VM and the pod interface is left IP-less. That causes kubelet's IP check to fail and results in pod removal. With this patch, we use a dummy interface named after the pod interface to keep the pod IP address. When kubelet performs the check, it sees interface with expectected name (eth0) and reports its IP address on Pod object. Signed-off-by: Ryan Hallisey <[email protected]> Fix dummy unit test Add func test for vmi restart w/ bridge network Signed-off-by: Ryan Hallisey <[email protected]> Restart kubelet Signed-off-by: Ryan Hallisey <[email protected]> Check for the eth0 and eth0-nic interfaces
- Loading branch information
1 parent
b013947
commit 859e99c
Showing
10 changed files
with
210 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,7 +247,6 @@ var _ = Describe("[rfe_id:151][crit:high][vendor:[email protected]][level:compon | |
|
||
By("applying the hostname from meta-data") | ||
Expect(libnet.WithIPv6(console.LoginToCirros)(vmi)).To(Succeed()) | ||
|
||
Expect(console.SafeExpectBatch(vmi, []expect.Batcher{ | ||
&expect.BSnd{S: "hostname\n"}, | ||
&expect.BExp{R: dns.SanitizeHostname(vmi)}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,6 +570,76 @@ var _ = Describe("[rfe_id:273][crit:high][vendor:[email protected]][level:compon | |
|
||
tests.WaitForSuccessfulVMIStart(newVMI) | ||
}) | ||
|
||
It("VMIs with Bridge Networking shouldn't fail after the kubelet restarts", func() { | ||
bridgeVMI := vmi | ||
// Remove the masquerade interface to use the default bridge one | ||
bridgeVMI.Spec.Domain.Devices.Interfaces = nil | ||
bridgeVMI.Spec.Networks = nil | ||
v1.SetDefaults_NetworkInterface(bridgeVMI) | ||
Expect(bridgeVMI.Spec.Domain.Devices.Interfaces).NotTo(BeEmpty()) | ||
|
||
By("starting a VMI with bridged network on a node") | ||
bridgeVMI, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(bridgeVMI) | ||
Expect(err).To(BeNil(), "Should submit VMI successfully") | ||
|
||
// Start a VirtualMachineInstance with bridged networking | ||
nodeName := tests.WaitForSuccessfulVMIStart(bridgeVMI) | ||
|
||
tests.VerifyDummyNicForBridgeNetwork(bridgeVMI) | ||
|
||
By("restarting kubelet") | ||
pod := renderPkillAllPod("kubelet") | ||
pod.Spec.NodeName = nodeName | ||
_, err = virtClient.CoreV1().Pods(tests.NamespaceTestDefault).Create(pod) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("starting another VMI on the same node, to verify kubelet is running again") | ||
newVMI := newCirrosVMI() | ||
newVMI.Spec.NodeSelector = map[string]string{"kubernetes.io/hostname": nodeName} | ||
Eventually(func() error { | ||
newVMI, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(newVMI) | ||
Expect(err).To(BeNil()) | ||
return nil | ||
}, 100, 10).Should(Succeed(), "Should be able to start a new VM") | ||
|
||
By("checking if the VMI with bridged networking is still running, it will verify the CNI didn't cause the pod to be killed") | ||
tests.WaitForSuccessfulVMIStart(bridgeVMI) | ||
}) | ||
|
||
It("VMIs with Bridge Networking should work with Duplicate Address Detection (DAD)", func() { | ||
bridgeVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
// Remove the masquerade interface to use the default bridge one | ||
bridgeVMI.Spec.Domain.Devices.Interfaces = nil | ||
bridgeVMI.Spec.Networks = nil | ||
v1.SetDefaults_NetworkInterface(bridgeVMI) | ||
Expect(bridgeVMI.Spec.Domain.Devices.Interfaces).NotTo(BeEmpty()) | ||
|
||
By("starting a VMI with bridged network on a node") | ||
bridgeVMI, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(bridgeVMI) | ||
Expect(err).To(BeNil(), "Should submit VMI successfully") | ||
|
||
// Start a VirtualMachineInstance with bridged networking | ||
By("Waiting the VirtualMachineInstance start") | ||
tests.WaitUntilVMIReady(bridgeVMI, console.LoginToCirros) | ||
tests.VerifyDummyNicForBridgeNetwork(bridgeVMI) | ||
|
||
// Update the VMI object so we get the IP address | ||
bridgeVMI, err = virtClient.VirtualMachineInstance(bridgeVMI.Namespace).Get(bridgeVMI.Name, &metav1.GetOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
vmIP := libnet.GetVmiPrimaryIpByFamily(bridgeVMI, k8sv1.IPv4Protocol) | ||
dadCommand := fmt.Sprintf("sudo /usr/sbin/arping -D -I eth0 -c 2 %s | grep Received | cut -d ' ' -f 2\n", vmIP) | ||
|
||
Expect(console.SafeExpectBatch(bridgeVMI, []expect.Batcher{ | ||
&expect.BSnd{S: "\n"}, | ||
&expect.BExp{R: console.PromptExpression}, | ||
|
||
&expect.BSnd{S: dadCommand}, | ||
&expect.BExp{R: "0"}, | ||
}, 600)).To(Succeed()) | ||
}) | ||
|
||
}) | ||
|
||
Context("[Serial]when virt-handler is not responsive", func() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ var _ = Describe("[Serial][rfe_id:694][crit:medium][vendor:[email protected]][le | |
} | ||
|
||
checkLearningState := func(vmi *v1.VirtualMachineInstance, expectedValue string) { | ||
output := tests.RunCommandOnVmiPod(vmi, []string{"cat", "/sys/class/net/eth0/brport/learning"}) | ||
output := tests.RunCommandOnVmiPod(vmi, []string{"cat", "/sys/class/net/eth0-nic/brport/learning"}) | ||
ExpectWithOffset(1, strings.TrimSpace(output)).To(Equal(expectedValue)) | ||
} | ||
|
||
|