diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index d3998a2785b..917f959c669 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -1549,7 +1549,7 @@ func (c *Controller) getPodAttachmentNet(pod *v1.Pod) ([]*kubeovnNet, error) { } if len(attach.IPRequest) != 0 { - ret.IPRequest = attach.IPRequest[0] + ret.IPRequest = strings.Join(attach.IPRequest, ",") } ret.MacRequest = attach.MacRequest diff --git a/test/e2e/multus/e2e_test.go b/test/e2e/multus/e2e_test.go index cb670b03394..a994363bbb1 100644 --- a/test/e2e/multus/e2e_test.go +++ b/test/e2e/multus/e2e_test.go @@ -514,9 +514,19 @@ var _ = framework.SerialDescribe("[group:multus]", func() { ginkgo.By("Creating pod " + podName) mac := "00:00:00:11:22:33" randomIP := framework.RandomIPs(subnet.Spec.CIDRBlock, "", 1) - requestIP := strings.Split(randomIP, ",")[0] - annotations := map[string]string{nadv1.NetworkAttachmentAnnot: fmt.Sprintf(`[{"name": "%s", "namespace": "%s", "mac": "%s", "ips": ["%s"]}]`, nad.Name, nad.Namespace, mac, requestIP)} + randomIPArray := strings.Split(randomIP, ",") + var requestIPString string + for i, ip := range randomIPArray { + if i == len(randomIPArray)-1 { + requestIPString += fmt.Sprintf(`"%s"`, ip) + } else { + requestIPString += fmt.Sprintf(`"%s",`, ip) + } + } + + framework.Logf("requestIPString: %s", requestIPString) + annotations := map[string]string{nadv1.NetworkAttachmentAnnot: fmt.Sprintf(`[{"name": "%s", "namespace": "%s", "mac": "%s", "ips": [%s]}]`, nad.Name, nad.Namespace, mac, requestIPString)} annotations[fmt.Sprintf(util.LogicalSwitchAnnotationTemplate, provider)] = subnetName cmd := []string{"sh", "-c", "sleep infinity"} @@ -530,6 +540,6 @@ var _ = framework.SerialDescribe("[group:multus]", func() { retIP := pod.Annotations[fmt.Sprintf(util.IPAddressAnnotationTemplate, provider)] framework.ExpectEqual(mac, retMac) - framework.ExpectEqual(requestIP, retIP) + framework.ExpectEqual(strings.Join(randomIPArray, ","), retIP) }) })