Skip to content

Commit

Permalink
Merge pull request #11613 from dcbw/sdn-start-pod-manager-earlier
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Nov 2, 2016
2 parents fd5cffe + a311f01 commit 605a036
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions images/dind/dind-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ function enable-overlay-storage() {
}

mount --make-shared /
mount --make-shared /run
enable-overlay-storage
9 changes: 8 additions & 1 deletion pkg/sdn/plugin/cniserver/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (

"github.com/golang/glog"
"github.com/gorilla/mux"

utilruntime "k8s.io/kubernetes/pkg/util/runtime"
utilwait "k8s.io/kubernetes/pkg/util/wait"
)

// *** The CNIServer is PRIVATE API between OpenShift SDN components and may be
Expand Down Expand Up @@ -141,7 +144,11 @@ func (s *CNIServer) Start(requestFunc cniRequestFunc) error {
}

s.SetKeepAlivesEnabled(false)
go s.Serve(l)
go utilwait.Forever(func() {
if err := s.Serve(l); err != nil {
utilruntime.HandleError(fmt.Errorf("CNI server Serve() failed: %v", err))
}
}, 0)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (plugin *OsdnNode) alreadySetUp(localSubnetGatewayCIDR, clusterNetworkCIDR
}
found = false
for _, addr := range addrs {
if strings.Contains(addr, localSubnetGatewayCIDR+" ") {
if strings.Contains(addr, localSubnetGatewayCIDR) {
found = true
break
}
Expand Down
15 changes: 11 additions & 4 deletions pkg/sdn/plugin/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type OsdnNode struct {
localIP string
hostName string
podNetworkReady chan struct{}
kubeletInitReady chan struct{}
vnids *nodeVNIDMap
iptablesSyncPeriod time.Duration
mtu uint32
Expand Down Expand Up @@ -95,6 +96,7 @@ func NewNodePlugin(pluginName string, osClient *osclient.Client, kClient *kclien
hostName: hostname,
vnids: newNodeVNIDMap(),
podNetworkReady: make(chan struct{}),
kubeletInitReady: make(chan struct{}),
iptablesSyncPeriod: iptablesSyncPeriod,
mtu: mtu,
egressPolicies: make(map[uint32][]*osapi.EgressNetworkPolicy),
Expand Down Expand Up @@ -202,10 +204,18 @@ func (node *OsdnNode) Start() error {
}
}

log.V(5).Infof("Creating and initializing openshift-sdn pod manager")
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.mtu)
if err != nil {
return err
}
if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil {
return err
}

// Wait for kubelet to init the plugin so we get a knetwork.Host
log.V(5).Infof("Waiting for kubelet network plugin initialization")
<-node.kubeletInitReady

if networkChanged {
var pods []kapi.Pod
Expand All @@ -221,10 +231,7 @@ func (node *OsdnNode) Start() error {
}
}

if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil {
return err
}

log.V(5).Infof("openshift-sdn network plugin ready")
node.markPodNetworkReady()

return nil
Expand Down
10 changes: 9 additions & 1 deletion pkg/sdn/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
kcni "k8s.io/kubernetes/pkg/kubelet/network/cni"
utilsets "k8s.io/kubernetes/pkg/util/sets"

"github.com/golang/glog"
)

// This kubelet network plugin shim only exists to grab the knetwork.Host
Expand All @@ -22,7 +24,13 @@ func (node *OsdnNode) Init(host knetwork.Host, hairpinMode componentconfig.Hairp
node.host = host
node.kubeletCniPlugin = plugins[0]

return node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)
err := node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)

// Let initial pod updates happen if they need to
glog.V(5).Infof("openshift-sdn CNI plugin initialized")
close(node.kubeletInitReady)

return err
}

func (node *OsdnNode) Name() string {
Expand Down

0 comments on commit 605a036

Please sign in to comment.