@@ -425,6 +425,17 @@ func (m *Master) Start() error {
425
425
}
426
426
427
427
if m .api {
428
+ // start etcd if configured to run in process
429
+ if m .config .EtcdConfig != nil {
430
+ etcdserver .RunEtcd (m .config .EtcdConfig )
431
+ }
432
+
433
+ // ensure connectivity to etcd before calling BuildMasterConfig,
434
+ // which constructs storage whose etcd clients require connectivity to etcd at construction time
435
+ if err := testEtcdConnectivity (m .config .EtcdClientInfo ); err != nil {
436
+ return err
437
+ }
438
+
428
439
// informers are shared amongst all the various api components we build
429
440
// TODO the needs of the apiserver and the controllers are drifting. We should consider two different skins here
430
441
clientConfig , err := configapi .GetClientConfig (m .config .MasterClients .OpenShiftLoopbackKubeConfig , m .config .MasterClients .OpenShiftLoopbackClientConnectionOverrides )
@@ -461,20 +472,9 @@ func (m *Master) Start() error {
461
472
462
473
// StartAPI starts the components of the master that are considered part of the API - the Kubernetes
463
474
// API and core controllers, the Origin API, the group, policy, project, and authorization caches,
464
- // etcd, the asset server (for the UI), the OAuth server endpoints, and the DNS server.
475
+ // the asset server (for the UI), the OAuth server endpoints, and the DNS server.
465
476
// TODO: allow to be more granularly targeted
466
477
func StartAPI (oc * origin.MasterConfig ) error {
467
- // start etcd
468
- if oc .Options .EtcdConfig != nil {
469
- etcdserver .RunEtcd (oc .Options .EtcdConfig )
470
- }
471
-
472
- // verify we can connect to etcd with the provided config
473
- // TODO remove when this becomes a health check in 3.8
474
- if err := testEtcdConnectivity (oc .Options .EtcdClientInfo ); err != nil {
475
- return err
476
- }
477
-
478
478
// start DNS before the informers are started because it adds a ClusterIP index.
479
479
if oc .Options .DNSConfig != nil {
480
480
oc .RunDNSServer ()
@@ -493,6 +493,7 @@ func testEtcdConnectivity(etcdClientInfo configapi.EtcdConnectionInfo) error {
493
493
if err != nil {
494
494
return err
495
495
}
496
+ defer etcdClient3 .Close ()
496
497
if err := etcd .TestEtcdClientV3 (etcdClient3 ); err != nil {
497
498
return err
498
499
}
0 commit comments