Merge 8d2d1d09f4
into a8b73e7583
This commit is contained in:
commit
09dfc8390e
3 changed files with 16 additions and 17 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/Sirupsen/logrus"
|
||||
"github.com/containernetworking/cni/pkg/ns"
|
||||
"github.com/kubernetes-incubator/cri-o/utils"
|
||||
"github.com/kubernetes-incubator/cri-o/pkg/ocicni"
|
||||
"golang.org/x/sys/unix"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
|
@ -36,7 +37,7 @@ const (
|
|||
)
|
||||
|
||||
// New creates a new Runtime with options provided
|
||||
func New(runtimePath string, runtimeHostPrivilegedPath string, conmonPath string, conmonEnv []string, cgroupManager string) (*Runtime, error) {
|
||||
func New(runtimePath string, runtimeHostPrivilegedPath string, conmonPath string, conmonEnv []string, cgroupManager string, netPlugin ocicni.CNIPlugin) (*Runtime, error) {
|
||||
r := &Runtime{
|
||||
name: filepath.Base(runtimePath),
|
||||
path: runtimePath,
|
||||
|
@ -44,6 +45,7 @@ func New(runtimePath string, runtimeHostPrivilegedPath string, conmonPath string
|
|||
conmonPath: conmonPath,
|
||||
conmonEnv: conmonEnv,
|
||||
cgroupManager: cgroupManager,
|
||||
netPlugin: netPlugin,
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
@ -56,6 +58,7 @@ type Runtime struct {
|
|||
conmonPath string
|
||||
conmonEnv []string
|
||||
cgroupManager string
|
||||
netPlugin ocicni.CNIPlugin
|
||||
}
|
||||
|
||||
// syncInfo is used to return data from monitor process to daemon
|
||||
|
@ -642,5 +645,8 @@ func (r *Runtime) RuntimeReady() (bool, error) {
|
|||
// NetworkReady checks if the runtime network is up and ready to
|
||||
// accept containers which require container network.
|
||||
func (r *Runtime) NetworkReady() (bool, error) {
|
||||
if err := r.netPlugin.Status(); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"os/exec"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/containernetworking/cni/libcni"
|
||||
cnitypes "github.com/containernetworking/cni/pkg/types"
|
||||
|
@ -44,19 +43,10 @@ func InitCNI(pluginDir string, cniDirs ...string) (CNIPlugin, error) {
|
|||
// check if a default network exists, otherwise dump the CNI search and return a noop plugin
|
||||
_, err = getDefaultCNINetwork(plugin.pluginDir, plugin.cniDirs, plugin.vendorCNIDirPrefix)
|
||||
if err != nil {
|
||||
glog.Warningf("Error in finding usable CNI plugin - %v", err)
|
||||
// create a noop plugin instead
|
||||
return &cniNoOp{}, nil
|
||||
glog.Warningf("Error in finding usable CNI plugin; waiting for CNI network configuration")
|
||||
}
|
||||
|
||||
// sync network config from pluginDir periodically to detect network config updates
|
||||
go func() {
|
||||
t := time.NewTimer(10 * time.Second)
|
||||
for {
|
||||
plugin.syncNetworkConfig()
|
||||
<-t.C
|
||||
}
|
||||
}()
|
||||
plugin.syncNetworkConfig()
|
||||
return plugin, nil
|
||||
}
|
||||
|
||||
|
@ -268,5 +258,6 @@ func buildCNIRuntimeConf(podName string, podNs string, podInfraContainerID strin
|
|||
}
|
||||
|
||||
func (plugin *cniNetworkPlugin) Status() error {
|
||||
plugin.syncNetworkConfig()
|
||||
return plugin.checkInitialized()
|
||||
}
|
||||
|
|
|
@ -459,16 +459,18 @@ func New(config *Config) (*Server, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
r, err := oci.New(config.Runtime, config.RuntimeHostPrivileged, config.Conmon, config.ConmonEnv, config.CgroupManager)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sandboxes := make(map[string]*sandbox)
|
||||
containers := oci.NewMemoryStore()
|
||||
netPlugin, err := ocicni.InitCNI(config.NetworkDir, config.PluginDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r, err := oci.New(config.Runtime, config.RuntimeHostPrivileged, config.Conmon, config.ConmonEnv, config.CgroupManager, netPlugin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &Server{
|
||||
runtime: r,
|
||||
store: store,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue