diff --git a/pkg/sdn/plugin/common.go b/pkg/sdn/plugin/common.go index 39fa62de95e5..6668347790ff 100644 --- a/pkg/sdn/plugin/common.go +++ b/pkg/sdn/plugin/common.go @@ -14,14 +14,12 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kcache "k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/fields" + kcontainer "k8s.io/kubernetes/pkg/kubelet/container" ) func getPodContainerID(pod *kapi.Pod) string { if len(pod.Status.ContainerStatuses) > 0 { - // Extract only container ID, pod.Status.ContainerStatuses[0].ContainerID is of the format: docker:// - if parts := strings.Split(pod.Status.ContainerStatuses[0].ContainerID, "://"); len(parts) > 1 { - return parts[1] - } + return kcontainer.ParseContainerID(pod.Status.ContainerStatuses[0].ContainerID).ID } return "" } diff --git a/pkg/sdn/plugin/node.go b/pkg/sdn/plugin/node.go index 1585a7e0cfdb..72750f3c0ca8 100644 --- a/pkg/sdn/plugin/node.go +++ b/pkg/sdn/plugin/node.go @@ -22,7 +22,6 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kclient "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/fields" - kubeletTypes "k8s.io/kubernetes/pkg/kubelet/container" knetwork "k8s.io/kubernetes/pkg/kubelet/network" "k8s.io/kubernetes/pkg/labels" kexec "k8s.io/kubernetes/pkg/util/exec" @@ -215,10 +214,9 @@ func (node *OsdnNode) Start() error { return err } for _, p := range pods { - containerID := getPodContainerID(&p) - err = node.UpdatePod(p.Namespace, p.Name, kubeletTypes.ContainerID{ID: containerID}) + err = node.UpdatePod(p) if err != nil { - log.Warningf("Could not update pod %q (%s): %s", p.Name, containerID, err) + log.Warningf("Could not update pod %q: %s", p.Name, err) } } } @@ -234,12 +232,12 @@ func (node *OsdnNode) Start() error { // FIXME: this should eventually go into kubelet via a CNI UPDATE/CHANGE action // See https://github.com/containernetworking/cni/issues/89 -func (node *OsdnNode) UpdatePod(namespace string, name string, id kubeletTypes.ContainerID) error { +func (node *OsdnNode) UpdatePod(pod kapi.Pod) error { req := &cniserver.PodRequest{ Command: cniserver.CNI_UPDATE, - PodNamespace: namespace, - PodName: name, - ContainerId: id.String(), + PodNamespace: pod.Namespace, + PodName: pod.Name, + ContainerId: getPodContainerID(&pod), // netns is read from docker if needed, since we don't get it from kubelet Result: make(chan *cniserver.PodResult), } diff --git a/pkg/sdn/plugin/pod_linux.go b/pkg/sdn/plugin/pod_linux.go index 7cd1149ea4fc..93e256373ea8 100644 --- a/pkg/sdn/plugin/pod_linux.go +++ b/pkg/sdn/plugin/pod_linux.go @@ -33,7 +33,6 @@ const ( sdnScript = "openshift-sdn-ovs" setUpCmd = "setup" tearDownCmd = "teardown" - statusCmd = "status" updateCmd = "update" AssignMacvlanAnnotation string = "pod.network.openshift.io/assign-macvlan" diff --git a/pkg/sdn/plugin/vnids_node.go b/pkg/sdn/plugin/vnids_node.go index b6aed18ec5da..88017f22ea71 100644 --- a/pkg/sdn/plugin/vnids_node.go +++ b/pkg/sdn/plugin/vnids_node.go @@ -9,7 +9,6 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/cache" - kubetypes "k8s.io/kubernetes/pkg/kubelet/container" kerrors "k8s.io/kubernetes/pkg/util/errors" "k8s.io/kubernetes/pkg/util/sets" utilwait "k8s.io/kubernetes/pkg/util/wait" @@ -167,7 +166,7 @@ func (node *OsdnNode) updatePodNetwork(namespace string, oldNetID, netID uint32) // Update OF rules for the existing/old pods in the namespace for _, pod := range pods { - err = node.UpdatePod(pod.Namespace, pod.Name, kubetypes.ContainerID{ID: getPodContainerID(&pod)}) + err = node.UpdatePod(pod) if err != nil { errList = append(errList, err) }