Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Commit

Permalink
setting cni network plugins dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
heartlock committed Mar 27, 2017
1 parent c13151b commit 486c9cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
8 changes: 5 additions & 3 deletions pkg/hyper/hyper.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ func (h *Runtime) Status() (*kubeapi.RuntimeStatus, error) {
Type: kubeapi.RuntimeReady,
Status: true,
}
// Always set networkReady for now.
// TODO: get real network status when network plugin is enabled.
var netReady bool
if err := h.netPlugin.Status(); err == nil {
netReady = true
}
networkReady := &kubeapi.RuntimeCondition{
Type: kubeapi.NetworkReady,
Status: true,
Status: netReady,
}
conditions := []*kubeapi.RuntimeCondition{runtimeReady, networkReady}
if _, _, err := h.client.GetVersion(); err != nil {
Expand Down
22 changes: 2 additions & 20 deletions pkg/hyper/ocicni/ocicni.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"sort"
"sync"
"time"

"github.com/containernetworking/cni/libcni"
cnitypes "github.com/containernetworking/cni/pkg/types"
Expand All @@ -47,26 +46,8 @@ type cniNetwork struct {

func InitCNI(netDir string, pluginDirs ...string) (CNIPlugin, error) {
plugin := probeNetworkPluginsWithVendorCNIDirPrefix(netDir, pluginDirs, "")
var err error

// check if a default network exists, otherwise dump the CNI search and return a noop plugin
_, err = getDefaultCNINetwork(plugin.netDir, plugin.pluginDirs, plugin.vendorCNIDirPrefix)
if err != nil {
glog.Warningf("Error in finding usable CNI plugin - %v", err)
// create a noop plugin instead
return &cniNoOp{}, nil
}

// sync network config from netDir periodically to detect network config updates
go func() {
t := time.NewTimer(10 * time.Second)
for {
plugin.syncNetworkConfig()
select {
case <-t.C:
}
}
}()
plugin.syncNetworkConfig()
return plugin, nil
}

Expand Down Expand Up @@ -231,5 +212,6 @@ func buildCNIRuntimeConf(podNetnsPath string, podID string) (*libcni.RuntimeConf
}

func (plugin *cniNetworkPlugin) Status() error {
plugin.syncNetworkConfig()
return plugin.checkInitialized()
}

0 comments on commit 486c9cd

Please sign in to comment.