Skip to content

Commit fd5cffe

Browse files
author
OpenShift Bot
authored
Merge pull request #11679 from pravisankar/fix-broken-join-network
Merged by openshift-bot
2 parents 49eea5f + bca9fd2 commit fd5cffe

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

pkg/sdn/plugin/common.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ import (
1414
kapi "k8s.io/kubernetes/pkg/api"
1515
kcache "k8s.io/kubernetes/pkg/client/cache"
1616
"k8s.io/kubernetes/pkg/fields"
17+
kcontainer "k8s.io/kubernetes/pkg/kubelet/container"
1718
)
1819

1920
func getPodContainerID(pod *kapi.Pod) string {
2021
if len(pod.Status.ContainerStatuses) > 0 {
21-
// Extract only container ID, pod.Status.ContainerStatuses[0].ContainerID is of the format: docker://<containerID>
22-
if parts := strings.Split(pod.Status.ContainerStatuses[0].ContainerID, "://"); len(parts) > 1 {
23-
return parts[1]
24-
}
22+
return kcontainer.ParseContainerID(pod.Status.ContainerStatuses[0].ContainerID).ID
2523
}
2624
return ""
2725
}

pkg/sdn/plugin/node.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
kapi "k8s.io/kubernetes/pkg/api"
2323
kclient "k8s.io/kubernetes/pkg/client/unversioned"
2424
"k8s.io/kubernetes/pkg/fields"
25-
kubeletTypes "k8s.io/kubernetes/pkg/kubelet/container"
2625
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
2726
"k8s.io/kubernetes/pkg/labels"
2827
kexec "k8s.io/kubernetes/pkg/util/exec"
@@ -215,10 +214,9 @@ func (node *OsdnNode) Start() error {
215214
return err
216215
}
217216
for _, p := range pods {
218-
containerID := getPodContainerID(&p)
219-
err = node.UpdatePod(p.Namespace, p.Name, kubeletTypes.ContainerID{ID: containerID})
217+
err = node.UpdatePod(p)
220218
if err != nil {
221-
log.Warningf("Could not update pod %q (%s): %s", p.Name, containerID, err)
219+
log.Warningf("Could not update pod %q: %s", p.Name, err)
222220
}
223221
}
224222
}
@@ -234,12 +232,12 @@ func (node *OsdnNode) Start() error {
234232

235233
// FIXME: this should eventually go into kubelet via a CNI UPDATE/CHANGE action
236234
// See https://github.com/containernetworking/cni/issues/89
237-
func (node *OsdnNode) UpdatePod(namespace string, name string, id kubeletTypes.ContainerID) error {
235+
func (node *OsdnNode) UpdatePod(pod kapi.Pod) error {
238236
req := &cniserver.PodRequest{
239237
Command: cniserver.CNI_UPDATE,
240-
PodNamespace: namespace,
241-
PodName: name,
242-
ContainerId: id.String(),
238+
PodNamespace: pod.Namespace,
239+
PodName: pod.Name,
240+
ContainerId: getPodContainerID(&pod),
243241
// netns is read from docker if needed, since we don't get it from kubelet
244242
Result: make(chan *cniserver.PodResult),
245243
}

pkg/sdn/plugin/pod_linux.go

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const (
3333
sdnScript = "openshift-sdn-ovs"
3434
setUpCmd = "setup"
3535
tearDownCmd = "teardown"
36-
statusCmd = "status"
3736
updateCmd = "update"
3837

3938
AssignMacvlanAnnotation string = "pod.network.openshift.io/assign-macvlan"

pkg/sdn/plugin/vnids_node.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
kapi "k8s.io/kubernetes/pkg/api"
1111
"k8s.io/kubernetes/pkg/client/cache"
12-
kubetypes "k8s.io/kubernetes/pkg/kubelet/container"
1312
kerrors "k8s.io/kubernetes/pkg/util/errors"
1413
"k8s.io/kubernetes/pkg/util/sets"
1514
utilwait "k8s.io/kubernetes/pkg/util/wait"
@@ -167,7 +166,7 @@ func (node *OsdnNode) updatePodNetwork(namespace string, oldNetID, netID uint32)
167166

168167
// Update OF rules for the existing/old pods in the namespace
169168
for _, pod := range pods {
170-
err = node.UpdatePod(pod.Namespace, pod.Name, kubetypes.ContainerID{ID: getPodContainerID(&pod)})
169+
err = node.UpdatePod(pod)
171170
if err != nil {
172171
errList = append(errList, err)
173172
}

0 commit comments

Comments
 (0)