Skip to content

Commit

Permalink
Update source for k8s bump to v0.18.3
Browse files Browse the repository at this point in the history
Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
  • Loading branch information
Billy99 committed Oct 23, 2020
1 parent 36b5edf commit f62529d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.openshift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This dockerfile is specific to building Multus for OpenShift
FROM openshift/origin-release:golang-1.10 as builder
FROM openshift/origin-release:golang-1.15 as builder

ADD . /usr/src/multus-cni

Expand Down
11 changes: 6 additions & 5 deletions k8sclient/k8sclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package k8sclient

import (
"context"
"encoding/json"
"fmt"
"net"
Expand Down Expand Up @@ -66,22 +67,22 @@ type ClientInfo struct {

// AddPod adds pod into kubernetes
func (c *ClientInfo) AddPod(pod *v1.Pod) (*v1.Pod, error) {
return c.Client.Core().Pods(pod.ObjectMeta.Namespace).Create(pod)
return c.Client.CoreV1().Pods(pod.ObjectMeta.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
}

// GetPod gets pod from kubernetes
func (c *ClientInfo) GetPod(namespace, name string) (*v1.Pod, error) {
return c.Client.Core().Pods(namespace).Get(name, metav1.GetOptions{})
return c.Client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
}

// DeletePod deletes a pod from kubernetes
func (c *ClientInfo) DeletePod(namespace, name string) error {
return c.Client.Core().Pods(namespace).Delete(name, &metav1.DeleteOptions{})
return c.Client.CoreV1().Pods(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})
}

// AddNetAttachDef adds net-attach-def into kubernetes
func (c *ClientInfo) AddNetAttachDef(netattach *nettypes.NetworkAttachmentDefinition) (*nettypes.NetworkAttachmentDefinition, error) {
return c.NetClient.NetworkAttachmentDefinitions(netattach.ObjectMeta.Namespace).Create(netattach)
return c.NetClient.NetworkAttachmentDefinitions(netattach.ObjectMeta.Namespace).Create(context.TODO(), netattach, metav1.CreateOptions{})
}

// Eventf puts event into kubernetes events
Expand Down Expand Up @@ -241,7 +242,7 @@ func parsePodNetworkAnnotation(podNetworks, defaultNamespace string) ([]*types.N
func getKubernetesDelegate(client *ClientInfo, net *types.NetworkSelectionElement, confdir string, pod *v1.Pod, resourceMap map[string]*types.ResourceInfo) (*types.DelegateNetConf, map[string]*types.ResourceInfo, error) {

logging.Debugf("getKubernetesDelegate: %v, %v, %s, %v, %v", client, net, confdir, pod, resourceMap)
customResource, err := client.NetClient.NetworkAttachmentDefinitions(net.Namespace).Get(net.Name, metav1.GetOptions{})
customResource, err := client.NetClient.NetworkAttachmentDefinitions(net.Namespace).Get(context.TODO(), net.Name, metav1.GetOptions{})
if err != nil {
errMsg := fmt.Sprintf("cannot find a network-attachment-definition (%s) in namespace (%s): %v", net.Name, net.Namespace, err)
if client != nil {
Expand Down
22 changes: 14 additions & 8 deletions multus/multus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
}, nil)

clientInfo := NewFakeClientInfo()
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
context.TODO(), fakePod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

_, err = clientInfo.AddNetAttachDef(
Expand Down Expand Up @@ -1473,7 +1474,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
}, nil)

clientInfo := NewFakeClientInfo()
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
context.TODO(), fakePod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

_, err = clientInfo.AddNetAttachDef(
Expand Down Expand Up @@ -1549,7 +1551,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
}, nil)

clientInfo := NewFakeClientInfo()
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
context.TODO(), fakePod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

_, err = clientInfo.AddNetAttachDef(
Expand All @@ -1570,8 +1573,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {

// delete pod to emulate no pod info
clientInfo.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name)
nilPod, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Get(
fakePod.ObjectMeta.Name, metav1.GetOptions{})
nilPod, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Get(
context.TODO(), fakePod.ObjectMeta.Name, metav1.GetOptions{})
Expect(nilPod).To(BeNil())
Expect(errors.IsNotFound(err)).To(BeTrue())

Expand Down Expand Up @@ -2641,7 +2644,8 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
}, nil)

clientInfo := NewFakeClientInfo()
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
context.TODO(), fakePod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

_, err = clientInfo.AddNetAttachDef(
Expand Down Expand Up @@ -2723,7 +2727,8 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
}, nil)

clientInfo := NewFakeClientInfo()
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
context.TODO(), fakePod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

_, err = clientInfo.AddNetAttachDef(
Expand Down Expand Up @@ -2793,7 +2798,8 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
}, nil)

clientInfo := NewFakeClientInfo()
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
context.TODO(), fakePod, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

_, err = clientInfo.AddNetAttachDef(
Expand Down

0 comments on commit f62529d

Please sign in to comment.