diff --git a/pkg/k8sclient/k8sclient_test.go b/pkg/k8sclient/k8sclient_test.go index 8bc712395..7e9a9332c 100644 --- a/pkg/k8sclient/k8sclient_test.go +++ b/pkg/k8sclient/k8sclient_test.go @@ -1199,11 +1199,14 @@ users: delegate, err := types.LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) - netstatus := []nettypes.NetworkStatus{*delegateNetStatus} + netstatus := make([]nettypes.NetworkStatus, 0) + for _, status := range delegateNetStatuses { + netstatus = append(netstatus, *status) + } fakePod := testutils.NewFakePod(fakePodName, "kube-system/net1", "") @@ -1254,11 +1257,14 @@ users: delegate, err := types.LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) - netstatus := []nettypes.NetworkStatus{*delegateNetStatus} + netstatus := make([]nettypes.NetworkStatus, 0) + for _, status := range delegateNetStatuses { + netstatus = append(netstatus, *status) + } fakePod := testutils.NewFakePod(fakePodName, "kube-system/net1", "") @@ -1312,11 +1318,14 @@ users: delegate, err := types.LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) - netstatus := []nettypes.NetworkStatus{*delegateNetStatus} + netstatus := make([]nettypes.NetworkStatus, 0) + for _, status := range delegateNetStatuses { + netstatus = append(netstatus, *status) + } fakePod := testutils.NewFakePod(fakePodName, "kube-system/net1", "") @@ -1394,11 +1403,14 @@ users: delegate, err := types.LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) - netstatus := []nettypes.NetworkStatus{*delegateNetStatus} + netstatus := make([]nettypes.NetworkStatus, 0) + for _, status := range delegateNetStatuses { + netstatus = append(netstatus, *status) + } fakePod := testutils.NewFakePod(fakePodName, "kube-system/net1", "") @@ -1450,11 +1462,14 @@ users: delegate, err := types.LoadDelegateNetConf([]byte(conf), nil, "", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) - netstatus := []nettypes.NetworkStatus{*delegateNetStatus} + netstatus := make([]nettypes.NetworkStatus, 0) + for _, status := range delegateNetStatuses { + netstatus = append(netstatus, *status) + } fakePod := testutils.NewFakePod(fakePodName, "kube-system/net1", "") @@ -1505,11 +1520,14 @@ users: delegate, err := types.LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) - netstatus := []nettypes.NetworkStatus{*delegateNetStatus} + netstatus := make([]nettypes.NetworkStatus, 0) + for _, status := range delegateNetStatuses { + netstatus = append(netstatus, *status) + } fakePod := testutils.NewFakePod(fakePodName, "kube-system/net1", "") diff --git a/pkg/multus/multus.go b/pkg/multus/multus.go index 5452d9e7e..6ae6243c4 100644 --- a/pkg/multus/multus.go +++ b/pkg/multus/multus.go @@ -738,15 +738,18 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c logging.Debugf("CmdAdd: getDelegateDeviceInfo returned an error - err=%v", err) } - // create the network status, only in case Multus as kubeconfig + // Create the network statuses, only in case Multus has kubeconfig if kubeClient != nil && kc != nil { if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) { - delegateNetStatus, err := nadutils.CreateNetworkStatus(tmpResult, delegate.Name, delegate.MasterPlugin, devinfo) + delegateNetStatuses, err := nadutils.CreateNetworkStatuses(tmpResult, delegate.Name, delegate.MasterPlugin, devinfo) if err != nil { - return nil, cmdErr(k8sArgs, "error setting network status: %v", err) + return nil, cmdErr(k8sArgs, "error setting network statuses: %v", err) } - netStatus = append(netStatus, *delegateNetStatus) + // Append all returned statuses after dereferencing each + for _, status := range delegateNetStatuses { + netStatus = append(netStatus, *status) + } } } else if devinfo != nil { // Warn that devinfo exists but could not add it to downwards API diff --git a/pkg/types/conf_test.go b/pkg/types/conf_test.go index b47821632..a0ac3a666 100644 --- a/pkg/types/conf_test.go +++ b/pkg/types/conf_test.go @@ -704,9 +704,9 @@ var _ = Describe("config operations", func() { delegate, err := LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).NotTo(HaveOccurred()) }) @@ -737,9 +737,9 @@ var _ = Describe("config operations", func() { delegate, err := LoadDelegateNetConf([]byte(conf), nil, "0000:00:00.0", "") Expect(err).NotTo(HaveOccurred()) fmt.Println("result.Version: ", result.Version()) - delegateNetStatus, err := netutils.CreateNetworkStatus(result, delegate.Conf.Name, delegate.MasterPlugin, nil) + delegateNetStatuses, err := netutils.CreateNetworkStatuses(result, delegate.Conf.Name, delegate.MasterPlugin, nil) - GinkgoT().Logf("delegateNetStatus %+v\n", delegateNetStatus) + GinkgoT().Logf("delegateNetStatuses %+v\n", delegateNetStatuses) Expect(err).To(HaveOccurred()) })