Skip to content

Commit f82bd17

Browse files
maiquebRamLavi
andcommitted
networking, virt: generalize conflict detection
This way we can ensure appropriate cases are caught in a generic way. With it, we can safely expect to find IP conflicts when there are duplicate IPs in the network. In future commits, we will be able to catch MAC conflicts when there are duplicate MACs in the network Co-authored-by: Ram Lavi <[email protected]> Signed-off-by: Miguel Duarte Barroso <[email protected]>
1 parent 9b471d7 commit f82bd17

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

test/extended/networking/livemigration.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ import (
3030
"github.com/openshift/origin/test/extended/util/image"
3131
)
3232

33-
const kvIPRequestsAnnot = "network.kubevirt.io/addresses"
33+
const (
34+
kvIPRequestsAnnot = "network.kubevirt.io/addresses"
35+
primaryUDNNetworkName = "overlay"
36+
)
3437

3538
var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][Feature:Layer2LiveMigration] Kubevirt Virtual Machines", func() {
3639
// disable automatic namespace creation, we need to add the required UDN label
@@ -570,14 +573,26 @@ func duplicateVM(cli *kubevirt.Client, vmNamespace, vmName string) {
570573
Expect(json.Unmarshal([]byte(originalVMIRawAnnotations), &originalVMIAnnotations)).To(Succeed())
571574

572575
var vmiCreationOptions []kubevirt.Option
576+
var vmiExpectations []func()
573577
if requestedIPs, hasIPRequests := originalVMIAnnotations[kvIPRequestsAnnot]; hasIPRequests {
574578
vmiCreationOptions = append(
575579
vmiCreationOptions,
576580
kubevirt.WithAnnotations(ipRequests(requestedIPs)),
577581
)
582+
vmiExpectations = append(vmiExpectations, func() {
583+
waitForVMPodEventWithMessage(
584+
cli,
585+
vmNamespace,
586+
duplicateVMName,
587+
"IP is already allocated",
588+
2*time.Minute,
589+
)
590+
})
578591
}
579592
Expect(cli.CreateVMIFromSpec(vmNamespace, duplicateVMName, vmiSpec, vmiCreationOptions...)).To(Succeed())
580-
waitForVMPodEventWithMessage(cli, vmNamespace, duplicateVMName, "IP is already allocated", 2*time.Minute)
593+
for _, expectation := range vmiExpectations {
594+
expectation()
595+
}
581596
}
582597

583598
func waitForVMPodEventWithMessage(vmClient *kubevirt.Client, vmNamespace, vmName, expectedEventMessage string, timeout time.Duration) {
@@ -788,7 +803,6 @@ func networkName(netSpecConfig string) string {
788803

789804
// formatAddressesAnnotation converts slice of IPs to the required JSON format for kubevirt addresses annotation
790805
func formatAddressesAnnotation(preconfiguredIPs []string) (string, error) {
791-
const primaryUDNNetworkName = "overlay"
792806
if len(preconfiguredIPs) == 0 {
793807
return "", nil
794808
}

0 commit comments

Comments
 (0)