Skip to content

Commit

Permalink
Updates to use CreateNetworkStauses from net-attach-def client for mu…
Browse files Browse the repository at this point in the history
…ltiple interfaces in CNI results
  • Loading branch information
dougbtv committed Jul 25, 2024
1 parent 8587734 commit bc6c8d5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 26 deletions.
54 changes: 36 additions & 18 deletions pkg/k8sclient/k8sclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")

Expand Down Expand Up @@ -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", "")

Expand Down Expand Up @@ -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", "")

Expand Down Expand Up @@ -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", "")

Expand Down Expand Up @@ -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", "")

Expand Down Expand Up @@ -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", "")

Expand Down
11 changes: 7 additions & 4 deletions pkg/multus/multus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, amd64, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, 386, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, arm64, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, 386, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, arm64, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, arm, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, s390x, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, arm, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, ppc64le, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, amd64, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses

Check failure on line 744 in pkg/multus/multus.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: nadutils.CreateNetworkStatuses
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
Expand Down
8 changes: 4 additions & 4 deletions pkg/types/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
Expand Down Expand Up @@ -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())
})
Expand Down

0 comments on commit bc6c8d5

Please sign in to comment.