diff --git a/.github/workflows/build-x86-image.yaml b/.github/workflows/build-x86-image.yaml index 1a6db36c537..57153079bfb 100644 --- a/.github/workflows/build-x86-image.yaml +++ b/.github/workflows/build-x86-image.yaml @@ -837,7 +837,7 @@ jobs: - build-kube-ovn - build-e2e-binaries runs-on: ubuntu-22.04 - timeout-minutes: 35 + timeout-minutes: 40 strategy: fail-fast: false matrix: diff --git a/.github/workflows/scheduled-e2e.yaml b/.github/workflows/scheduled-e2e.yaml index 5ea55c32328..21684f26837 100644 --- a/.github/workflows/scheduled-e2e.yaml +++ b/.github/workflows/scheduled-e2e.yaml @@ -334,7 +334,7 @@ jobs: kube-ovn-conformance-e2e: name: Kube-OVN Conformance E2E runs-on: ubuntu-22.04 - timeout-minutes: 30 + timeout-minutes: 40 strategy: fail-fast: false matrix: diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index 5c566fa8171..c8e24294391 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -1549,12 +1549,15 @@ func (c *Controller) acquireAddress(pod *v1.Pod, podNet *kubeovnNet) (string, st ipPool = strings.Split(ippoolStr, ";") } else { ipPool = strings.Split(ippoolStr, ",") + if len(ipPool) == 2 && util.CheckProtocol(ipPool[0]) != util.CheckProtocol(ipPool[1]) { + ipPool = []string{ippoolStr} + } } for i, ip := range ipPool { ipPool[i] = strings.TrimSpace(ip) } - if len(ipPool) == 1 && net.ParseIP(ipPool[0]) == nil { + if len(ipPool) == 1 && (!strings.ContainsRune(ipPool[0], ',') && net.ParseIP(ipPool[0]) == nil) { var skippedAddrs []string for { portName := ovs.PodNameToPortName(podName, pod.Namespace, podNet.ProviderName) diff --git a/test/e2e/kube-ovn/ipam/ipam.go b/test/e2e/kube-ovn/ipam/ipam.go index 13c2753c83e..adb86f342fa 100644 --- a/test/e2e/kube-ovn/ipam/ipam.go +++ b/test/e2e/kube-ovn/ipam/ipam.go @@ -252,64 +252,68 @@ var _ = framework.Describe("[group:ipam]", func() { ippoolSep = "," } - replicas := 3 - ippool := framework.RandomIPs(cidr, ippoolSep, replicas) - labels := map[string]string{"app": stsName} + for replicas := 1; replicas <= 3; replicas++ { + ippool := framework.RandomIPs(cidr, ippoolSep, replicas) + labels := map[string]string{"app": stsName} - ginkgo.By("Creating statefulset " + stsName + " with ippool " + ippool) - sts := framework.MakeStatefulSet(stsName, stsName, int32(replicas), labels, framework.PauseImage) - sts.Spec.Template.Annotations = map[string]string{util.IpPoolAnnotation: ippool} - sts = stsClient.CreateSync(sts) + ginkgo.By("Creating statefulset " + stsName + " with ippool " + ippool) + sts := framework.MakeStatefulSet(stsName, stsName, int32(replicas), labels, framework.PauseImage) + sts.Spec.Template.Annotations = map[string]string{util.IpPoolAnnotation: ippool} + sts = stsClient.CreateSync(sts) - ginkgo.By("Getting pods for statefulset " + stsName) - pods := stsClient.GetPods(sts) - framework.ExpectHaveLen(pods.Items, replicas) - - ips := make([]string, 0, replicas) - for _, pod := range pods.Items { - framework.ExpectHaveKeyWithValue(pod.Annotations, util.AllocatedAnnotation, "true") - framework.ExpectHaveKeyWithValue(pod.Annotations, util.CidrAnnotation, subnet.Spec.CIDRBlock) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.GatewayAnnotation, subnet.Spec.Gateway) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.IpPoolAnnotation, ippool) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.LogicalSwitchAnnotation, subnet.Name) - framework.ExpectMAC(pod.Annotations[util.MacAddressAnnotation]) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.RoutedAnnotation, "true") + ginkgo.By("Getting pods for statefulset " + stsName) + pods := stsClient.GetPods(sts) + framework.ExpectHaveLen(pods.Items, replicas) - podIPs := make([]string, 0, len(pod.Status.PodIPs)) - for _, podIP := range pod.Status.PodIPs { - podIPs = append(podIPs, podIP.IP) + ips := make([]string, 0, replicas) + for _, pod := range pods.Items { + framework.ExpectHaveKeyWithValue(pod.Annotations, util.AllocatedAnnotation, "true") + framework.ExpectHaveKeyWithValue(pod.Annotations, util.CidrAnnotation, subnet.Spec.CIDRBlock) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.GatewayAnnotation, subnet.Spec.Gateway) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.IpPoolAnnotation, ippool) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.LogicalSwitchAnnotation, subnet.Name) + framework.ExpectMAC(pod.Annotations[util.MacAddressAnnotation]) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.RoutedAnnotation, "true") + + podIPs := make([]string, 0, len(pod.Status.PodIPs)) + for _, podIP := range pod.Status.PodIPs { + podIPs = append(podIPs, podIP.IP) + } + framework.ExpectConsistOf(podIPs, strings.Split(pod.Annotations[util.IpAddressAnnotation], ",")) + ips = append(ips, pod.Annotations[util.IpAddressAnnotation]) } - framework.ExpectConsistOf(podIPs, strings.Split(pod.Annotations[util.IpAddressAnnotation], ",")) - ips = append(ips, pod.Annotations[util.IpAddressAnnotation]) - } - framework.ExpectConsistOf(ips, strings.Split(ippool, ippoolSep)) - - ginkgo.By("Deleting pods for statefulset " + stsName) - for _, pod := range pods.Items { - err := podClient.Delete(pod.Name) - framework.ExpectNoError(err, "failed to delete pod "+pod.Name) - } - stsClient.WaitForRunningAndReady(sts) + framework.ExpectConsistOf(ips, strings.Split(ippool, ippoolSep)) - ginkgo.By("Getting pods for statefulset " + stsName) - pods = stsClient.GetPods(sts) - framework.ExpectHaveLen(pods.Items, replicas) + ginkgo.By("Deleting pods for statefulset " + stsName) + for _, pod := range pods.Items { + err := podClient.Delete(pod.Name) + framework.ExpectNoError(err, "failed to delete pod "+pod.Name) + } + stsClient.WaitForRunningAndReady(sts) - for i, pod := range pods.Items { - framework.ExpectHaveKeyWithValue(pod.Annotations, util.AllocatedAnnotation, "true") - framework.ExpectHaveKeyWithValue(pod.Annotations, util.CidrAnnotation, subnet.Spec.CIDRBlock) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.GatewayAnnotation, subnet.Spec.Gateway) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.IpPoolAnnotation, ippool) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.IpAddressAnnotation, ips[i]) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.LogicalSwitchAnnotation, subnet.Name) - framework.ExpectMAC(pod.Annotations[util.MacAddressAnnotation]) - framework.ExpectHaveKeyWithValue(pod.Annotations, util.RoutedAnnotation, "true") + ginkgo.By("Getting pods for statefulset " + stsName) + pods = stsClient.GetPods(sts) + framework.ExpectHaveLen(pods.Items, replicas) - podIPs := make([]string, 0, len(pod.Status.PodIPs)) - for _, podIP := range pod.Status.PodIPs { - podIPs = append(podIPs, podIP.IP) + for i, pod := range pods.Items { + framework.ExpectHaveKeyWithValue(pod.Annotations, util.AllocatedAnnotation, "true") + framework.ExpectHaveKeyWithValue(pod.Annotations, util.CidrAnnotation, subnet.Spec.CIDRBlock) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.GatewayAnnotation, subnet.Spec.Gateway) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.IpPoolAnnotation, ippool) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.IpAddressAnnotation, ips[i]) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.LogicalSwitchAnnotation, subnet.Name) + framework.ExpectMAC(pod.Annotations[util.MacAddressAnnotation]) + framework.ExpectHaveKeyWithValue(pod.Annotations, util.RoutedAnnotation, "true") + + podIPs := make([]string, 0, len(pod.Status.PodIPs)) + for _, podIP := range pod.Status.PodIPs { + podIPs = append(podIPs, podIP.IP) + } + framework.ExpectConsistOf(podIPs, strings.Split(pod.Annotations[util.IpAddressAnnotation], ",")) } - framework.ExpectConsistOf(podIPs, strings.Split(pod.Annotations[util.IpAddressAnnotation], ",")) + + ginkgo.By("Deleting statefulset " + stsName) + stsClient.DeleteSync(stsName) } })