Use new ocicni.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2017-09-07 00:14:12 +00:00
parent 1c0385a650
commit f36ef46b35
6 changed files with 18 additions and 9 deletions

View File

@ -22,7 +22,7 @@ import (
"strings" "strings"
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/cri-o/ocicni" "github.com/cri-o/ocicni/pkg/ocicni"
"github.com/golang/glog" "github.com/golang/glog"
imagespec "github.com/opencontainers/image-spec/specs-go/v1" imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtimespec "github.com/opencontainers/runtime-spec/specs-go"

View File

@ -20,7 +20,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/cri-o/ocicni" "github.com/cri-o/ocicni/pkg/ocicni"
imagespec "github.com/opencontainers/image-spec/specs-go/v1" imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View File

@ -22,6 +22,7 @@ import (
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/golang/glog" "github.com/golang/glog"
"golang.org/x/net/context" "golang.org/x/net/context"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
@ -57,7 +58,15 @@ func (c *criContainerdService) PodSandboxStatus(ctx context.Context, r *runtime.
state = runtime.PodSandboxState_SANDBOX_READY state = runtime.PodSandboxState_SANDBOX_READY
} }
} }
ip, err := c.netPlugin.GetPodNetworkStatus(sandbox.NetNSPath) config := sandbox.Config
podNetwork := ocicni.PodNetwork{
Name: config.GetMetadata().GetName(),
Namespace: config.GetMetadata().GetNamespace(),
ID: id,
NetNS: sandbox.NetNSPath,
PortMappings: toCNIPortMappings(config.GetPortMappings()),
}
ip, err := c.netPlugin.GetPodNetworkStatus(podNetwork)
if err != nil { if err != nil {
// Ignore the error on network status // Ignore the error on network status
ip = "" ip = ""

View File

@ -22,7 +22,7 @@ import (
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/errdefs"
"github.com/cri-o/ocicni" "github.com/cri-o/ocicni/pkg/ocicni"
"github.com/golang/glog" "github.com/golang/glog"
"golang.org/x/net/context" "golang.org/x/net/context"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"

View File

@ -26,7 +26,7 @@ import (
"github.com/containerd/containerd/api/services/tasks/v1" "github.com/containerd/containerd/api/services/tasks/v1"
"github.com/containerd/containerd/content" "github.com/containerd/containerd/content"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/cri-o/ocicni" "github.com/cri-o/ocicni/pkg/ocicni"
"github.com/golang/glog" "github.com/golang/glog"
"google.golang.org/grpc" "google.golang.org/grpc"
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"

View File

@ -23,7 +23,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/cri-o/ocicni" "github.com/cri-o/ocicni/pkg/ocicni"
) )
// CalledDetail is the struct contains called function name and arguments. // CalledDetail is the struct contains called function name and arguments.
@ -148,14 +148,14 @@ func (f *FakeCNIPlugin) TearDownPod(podNetwork ocicni.PodNetwork) error {
} }
// GetPodNetworkStatus get the status of network. // GetPodNetworkStatus get the status of network.
func (f *FakeCNIPlugin) GetPodNetworkStatus(netnsPath string) (string, error) { func (f *FakeCNIPlugin) GetPodNetworkStatus(podNetwork ocicni.PodNetwork) (string, error) {
f.Lock() f.Lock()
defer f.Unlock() defer f.Unlock()
f.appendCalled("GetPodNetworkStatus", netnsPath) f.appendCalled("GetPodNetworkStatus", podNetwork)
if err := f.getError("GetPodNetworkStatus"); err != nil { if err := f.getError("GetPodNetworkStatus"); err != nil {
return "", err return "", err
} }
ip, ok := f.IPMap[netnsPath] ip, ok := f.IPMap[podNetwork.NetNS]
if !ok { if !ok {
return "", fmt.Errorf("failed to find the IP") return "", fmt.Errorf("failed to find the IP")
} }