Skip to content

Commit 116b179

Browse files
Merge pull request #19953 from liggitt/etcd-dial-timeout
Set etcd DialTimeout, fix etcd start order in all-in-one
2 parents 166c5f7 + 0a6ead4 commit 116b179

File tree

2 files changed

+18
-14
lines changed
  • pkg/cmd/server/start
  • vendor/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory

2 files changed

+18
-14
lines changed

pkg/cmd/server/start/start_master.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,17 @@ func (m *Master) Start() error {
425425
}
426426

427427
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+
428439
// informers are shared amongst all the various api components we build
429440
// TODO the needs of the apiserver and the controllers are drifting. We should consider two different skins here
430441
clientConfig, err := configapi.GetClientConfig(m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.MasterClients.OpenShiftLoopbackClientConnectionOverrides)
@@ -461,20 +472,9 @@ func (m *Master) Start() error {
461472

462473
// StartAPI starts the components of the master that are considered part of the API - the Kubernetes
463474
// 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.
465476
// TODO: allow to be more granularly targeted
466477
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-
478478
// start DNS before the informers are started because it adds a ClusterIP index.
479479
if oc.Options.DNSConfig != nil {
480480
oc.RunDNSServer()
@@ -493,6 +493,7 @@ func testEtcdConnectivity(etcdClientInfo configapi.EtcdConnectionInfo) error {
493493
if err != nil {
494494
return err
495495
}
496+
defer etcdClient3.Close()
496497
if err := etcd.TestEtcdClientV3(etcdClient3); err != nil {
497498
return err
498499
}

vendor/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)