Skip to content

Commit 97e7c5c

Browse files
SDN should signal when it's ready for pods to run
Pods are not delivered to Kubelet until SDN indicates its seen itself configured
1 parent 417ffe1 commit 97e7c5c

File tree

6 files changed

+52
-44
lines changed

6 files changed

+52
-44
lines changed

pkg/cmd/server/kubernetes/node.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ func (c *NodeConfig) RunKubelet() {
136136
c.KubeletConfig.DockerClient = c.DockerClient
137137
// updated by NodeConfig.EnsureVolumeDir
138138
c.KubeletConfig.RootDirectory = c.VolumeDir
139-
glog.Fatal(c.KubeletServer.Run(c.KubeletConfig))
139+
140+
go glog.Fatal(c.KubeletServer.Run(c.KubeletConfig))
140141
}
141142

142143
// RunProxy starts the proxy

pkg/cmd/server/origin/master.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ func (c *MasterConfig) RunDeploymentImageChangeTriggerController() {
10961096
func (c *MasterConfig) RunSDNController() {
10971097
osclient, kclient := c.SDNControllerClients()
10981098
if c.Options.NetworkConfig.NetworkPluginName == osdn.NetworkPluginName() {
1099-
osdn.Master(*osclient, *kclient, c.Options.NetworkConfig.ClusterNetworkCIDR, c.Options.NetworkConfig.HostSubnetLength)
1099+
osdn.Master(osclient, kclient, c.Options.NetworkConfig.ClusterNetworkCIDR, c.Options.NetworkConfig.HostSubnetLength)
11001100
}
11011101
}
11021102

pkg/cmd/server/start/start_allinone.go

+2
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ func (o *AllInOneOptions) Complete() error {
193193
}
194194
o.MasterArgs.NodeList = nodeList.List()
195195

196+
o.MasterArgs.NetworkArgs.NetworkPluginName = o.NodeArgs.NetworkPluginName
197+
196198
masterAddr, err := o.MasterArgs.GetMasterAddress()
197199
if err != nil {
198200
return err

pkg/cmd/server/start/start_master.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ This command helps you launch an OpenShift master. Running
4444
4545
$ openshift start master
4646
47-
will start an OpenShift master listening on all interfaces, launch an etcd server to store
48-
persistent data, and launch the Kubernetes system components. The server will run in the
47+
will start an OpenShift master listening on all interfaces, launch an etcd server to store
48+
persistent data, and launch the Kubernetes system components. The server will run in the
4949
foreground until you terminate the process.
5050
5151
Note: starting OpenShift without passing the --master address will attempt to find the IP
@@ -169,6 +169,7 @@ func (o MasterOptions) StartMaster() error {
169169
return nil
170170
}
171171

172+
go daemon.SdNotify("READY=1")
172173
select {}
173174

174175
return nil
@@ -359,7 +360,6 @@ func StartMaster(openshiftMasterConfig *configapi.MasterConfig) error {
359360
}
360361

361362
openshiftConfig.Run([]origin.APIInstaller{kubeConfig}, unprotectedInstallers)
362-
go daemon.SdNotify("READY=1")
363363

364364
} else {
365365
_, kubeConfig, err := configapi.GetKubeClient(openshiftMasterConfig.MasterClients.ExternalKubernetesKubeConfig)
@@ -372,7 +372,6 @@ func StartMaster(openshiftMasterConfig *configapi.MasterConfig) error {
372372
}
373373

374374
openshiftConfig.Run([]origin.APIInstaller{proxy}, unprotectedInstallers)
375-
go daemon.SdNotify("READY=1")
376375
}
377376

378377
glog.Infof("Using images from %q", openshiftConfig.ImageFor("<component>"))
@@ -394,23 +393,30 @@ func StartMaster(openshiftMasterConfig *configapi.MasterConfig) error {
394393
// Start these first, because they provide credentials for other controllers' clients
395394
openshiftConfig.RunServiceAccountsController()
396395
openshiftConfig.RunServiceAccountTokensController()
396+
// used by admission controllers
397+
openshiftConfig.RunServiceAccountPullSecretsControllers()
398+
openshiftConfig.RunSecurityAllocationController()
397399

398400
if kubeConfig != nil {
399401
_, rcClient, err := openshiftConfig.GetServiceAccountClients(openshiftConfig.ReplicationControllerServiceAccount)
400402
if err != nil {
401403
glog.Fatalf("Could not get client for replication controller: %v", err)
402404
}
403405

406+
// called by admission control
407+
kubeConfig.RunResourceQuotaManager()
408+
409+
// no special order
410+
kubeConfig.RunNodeController()
404411
kubeConfig.RunScheduler()
405412
kubeConfig.RunReplicationController(rcClient)
406413
kubeConfig.RunEndpointController()
407-
kubeConfig.RunNodeController()
408-
kubeConfig.RunResourceQuotaManager()
409414
kubeConfig.RunNamespaceController()
410415
kubeConfig.RunPersistentVolumeClaimBinder()
411416
kubeConfig.RunPersistentVolumeClaimRecycler()
412417
}
413418

419+
// no special order
414420
openshiftConfig.RunBuildController()
415421
openshiftConfig.RunBuildPodController()
416422
openshiftConfig.RunBuildImageChangeTriggerController()
@@ -421,8 +427,6 @@ func StartMaster(openshiftMasterConfig *configapi.MasterConfig) error {
421427
openshiftConfig.RunDeploymentImageChangeTriggerController()
422428
openshiftConfig.RunImageImportController()
423429
openshiftConfig.RunOriginNamespaceController()
424-
openshiftConfig.RunSecurityAllocationController()
425-
openshiftConfig.RunServiceAccountPullSecretsControllers()
426430
openshiftConfig.RunSDNController()
427431
}()
428432
}

pkg/cmd/server/start/start_node.go

+28-27
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (o NodeOptions) StartNode() error {
125125
return nil
126126
}
127127

128+
go daemon.SdNotify("READY=1")
128129
select {}
129130

130131
return nil
@@ -207,6 +208,7 @@ func (o NodeOptions) CreateNodeConfig() error {
207208
DNSDomain: o.NodeArgs.ClusterDomain,
208209
DNSIP: dnsIP,
209210
ListenAddr: o.NodeArgs.ListenArg.ListenAddr,
211+
NetworkPluginName: o.NodeArgs.NetworkPluginName,
210212

211213
APIServerURL: masterAddr.String(),
212214
APIServerCAFile: getSignerOptions.CertFile,
@@ -225,40 +227,39 @@ func (o NodeOptions) CreateNodeConfig() error {
225227
return nil
226228
}
227229

228-
func RunSDNController(config configapi.NodeConfig) {
229-
if config.NetworkPluginName == osdn.NetworkPluginName() {
230-
kclient, _, err := configapi.GetKubeClient(config.MasterKubeConfig)
231-
if err != nil {
232-
glog.Fatal("Failed to get kube client for SDN")
233-
}
234-
oclient, _, err := configapi.GetOpenShiftClient(config.MasterKubeConfig)
235-
if err != nil {
236-
glog.Fatal("Failed to get kube client for SDN")
237-
}
238-
osdn.Node(*oclient, *kclient, config.NodeName, "")
230+
func (o NodeOptions) IsWriteConfigOnly() bool {
231+
return o.NodeArgs.ConfigDir.Provided()
232+
}
233+
234+
func (o NodeOptions) IsRunFromConfig() bool {
235+
return (len(o.ConfigFile) > 0)
236+
}
237+
238+
func RunSDNController(config *kubernetes.NodeConfig, nodeConfig configapi.NodeConfig) {
239+
if nodeConfig.NetworkPluginName != osdn.NetworkPluginName() {
240+
return
239241
}
242+
243+
oclient, _, err := configapi.GetOpenShiftClient(nodeConfig.MasterKubeConfig)
244+
if err != nil {
245+
glog.Fatal("Failed to get kube client for SDN")
246+
}
247+
ch := make(chan struct{})
248+
config.KubeletConfig.StartUpdates = ch
249+
go osdn.Node(oclient, config.Client, nodeConfig.NodeName, "", ch)
240250
}
241251

242-
func StartNode(config configapi.NodeConfig) error {
243-
nodeConfig, err := kubernetes.BuildKubernetesNodeConfig(config)
252+
func StartNode(nodeConfig configapi.NodeConfig) error {
253+
config, err := kubernetes.BuildKubernetesNodeConfig(nodeConfig)
244254
if err != nil {
245255
return err
246256
}
247257

248-
RunSDNController(config)
249-
nodeConfig.EnsureVolumeDir()
250-
nodeConfig.EnsureDocker(docker.NewHelper())
251-
nodeConfig.RunProxy()
252-
nodeConfig.RunKubelet()
253-
go daemon.SdNotify("READY=1")
258+
RunSDNController(config, nodeConfig)
259+
config.EnsureVolumeDir()
260+
config.EnsureDocker(docker.NewHelper())
261+
config.RunProxy()
262+
config.RunKubelet()
254263

255264
return nil
256265
}
257-
258-
func (o NodeOptions) IsWriteConfigOnly() bool {
259-
return o.NodeArgs.ConfigDir.Provided()
260-
}
261-
262-
func (o NodeOptions) IsRunFromConfig() bool {
263-
return (len(o.ConfigFile) > 0)
264-
}

plugins/osdn/osdn.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ func NetworkPluginName() string {
3232
return "redhat/openshift-ovs-subnet"
3333
}
3434

35-
func Master(osClient osclient.Client, kClient kclient.Client, clusterNetwork string, clusterNetworkLength uint) {
35+
func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork string, clusterNetworkLength uint) {
3636
osdnInterface := newOsdnRegistryInterface(osClient, kClient)
3737

38-
// get hostname
38+
// get hostname from the gateway
3939
output, err := exec.New().Command("hostname", "-f").CombinedOutput()
4040
if err != nil {
4141
glog.Fatalf("SDN initialization failed: %v", err)
4242
}
4343
host := strings.TrimSpace(string(output))
4444

45-
kc, err := ovssubnet.NewKubeController(&osdnInterface, host, "")
45+
kc, err := ovssubnet.NewKubeController(&osdnInterface, host, "", nil)
4646
if err != nil {
4747
glog.Fatalf("SDN initialization failed: %v", err)
4848
}
@@ -52,17 +52,17 @@ func Master(osClient osclient.Client, kClient kclient.Client, clusterNetwork str
5252
}
5353
}
5454

55-
func Node(osClient osclient.Client, kClient kclient.Client, hostname string, publicIP string) {
55+
func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}) {
5656
osdnInterface := newOsdnRegistryInterface(osClient, kClient)
57-
kc, err := ovssubnet.NewKubeController(&osdnInterface, hostname, publicIP)
57+
kc, err := ovssubnet.NewKubeController(&osdnInterface, hostname, publicIP, ready)
5858
if err != nil {
5959
glog.Fatalf("SDN initialization failed: %v", err)
6060
}
6161
kc.StartNode(false, false)
6262
}
6363

64-
func newOsdnRegistryInterface(osClient osclient.Client, kClient kclient.Client) OsdnRegistryInterface {
65-
return OsdnRegistryInterface{&osClient, &kClient}
64+
func newOsdnRegistryInterface(osClient *osclient.Client, kClient *kclient.Client) OsdnRegistryInterface {
65+
return OsdnRegistryInterface{osClient, kClient}
6666
}
6767

6868
func (oi *OsdnRegistryInterface) InitSubnets() error {

0 commit comments

Comments
 (0)