Skip to content

Commit 605a036

Browse files
author
OpenShift Bot
authored
Merge pull request #11613 from dcbw/sdn-start-pod-manager-earlier
Merged by openshift-bot
2 parents fd5cffe + a311f01 commit 605a036

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

images/dind/dind-setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ function enable-overlay-storage() {
4242
}
4343

4444
mount --make-shared /
45+
mount --make-shared /run
4546
enable-overlay-storage

pkg/sdn/plugin/cniserver/cniserver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212

1313
"github.com/golang/glog"
1414
"github.com/gorilla/mux"
15+
16+
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
17+
utilwait "k8s.io/kubernetes/pkg/util/wait"
1518
)
1619

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

143146
s.SetKeepAlivesEnabled(false)
144-
go s.Serve(l)
147+
go utilwait.Forever(func() {
148+
if err := s.Serve(l); err != nil {
149+
utilruntime.HandleError(fmt.Errorf("CNI server Serve() failed: %v", err))
150+
}
151+
}, 0)
145152
return nil
146153
}
147154

pkg/sdn/plugin/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (plugin *OsdnNode) alreadySetUp(localSubnetGatewayCIDR, clusterNetworkCIDR
9090
}
9191
found = false
9292
for _, addr := range addrs {
93-
if strings.Contains(addr, localSubnetGatewayCIDR+" ") {
93+
if strings.Contains(addr, localSubnetGatewayCIDR) {
9494
found = true
9595
break
9696
}

pkg/sdn/plugin/node.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type OsdnNode struct {
4040
localIP string
4141
hostName string
4242
podNetworkReady chan struct{}
43+
kubeletInitReady chan struct{}
4344
vnids *nodeVNIDMap
4445
iptablesSyncPeriod time.Duration
4546
mtu uint32
@@ -95,6 +96,7 @@ func NewNodePlugin(pluginName string, osClient *osclient.Client, kClient *kclien
9596
hostName: hostname,
9697
vnids: newNodeVNIDMap(),
9798
podNetworkReady: make(chan struct{}),
99+
kubeletInitReady: make(chan struct{}),
98100
iptablesSyncPeriod: iptablesSyncPeriod,
99101
mtu: mtu,
100102
egressPolicies: make(map[uint32][]*osapi.EgressNetworkPolicy),
@@ -202,10 +204,18 @@ func (node *OsdnNode) Start() error {
202204
}
203205
}
204206

207+
log.V(5).Infof("Creating and initializing openshift-sdn pod manager")
205208
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.mtu)
206209
if err != nil {
207210
return err
208211
}
212+
if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil {
213+
return err
214+
}
215+
216+
// Wait for kubelet to init the plugin so we get a knetwork.Host
217+
log.V(5).Infof("Waiting for kubelet network plugin initialization")
218+
<-node.kubeletInitReady
209219

210220
if networkChanged {
211221
var pods []kapi.Pod
@@ -221,10 +231,7 @@ func (node *OsdnNode) Start() error {
221231
}
222232
}
223233

224-
if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil {
225-
return err
226-
}
227-
234+
log.V(5).Infof("openshift-sdn network plugin ready")
228235
node.markPodNetworkReady()
229236

230237
return nil

pkg/sdn/plugin/plugin.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
99
kcni "k8s.io/kubernetes/pkg/kubelet/network/cni"
1010
utilsets "k8s.io/kubernetes/pkg/util/sets"
11+
12+
"github.com/golang/glog"
1113
)
1214

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

25-
return node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)
27+
err := node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)
28+
29+
// Let initial pod updates happen if they need to
30+
glog.V(5).Infof("openshift-sdn CNI plugin initialized")
31+
close(node.kubeletInitReady)
32+
33+
return err
2634
}
2735

2836
func (node *OsdnNode) Name() string {

0 commit comments

Comments
 (0)