mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #10710 from zexi/fix/decouple-region-etcd
fix(region): decouple region and etcd service
This commit is contained in:
@@ -140,8 +140,6 @@ type ComputeOptions struct {
|
||||
EnableHostHealthCheck bool `help:"enable host health check" default:"true"`
|
||||
HostHealthTimeout int `help:"second of wait host reconnect" default:"60"`
|
||||
|
||||
FetchEtcdServiceInfoAndUseEtcdLock bool `default:"false" help:"fetch etcd service info and use etcd lock"`
|
||||
|
||||
GuestTemplateCheckInterval int `help:"interval between two consecutive inspections of Guest Template in hour unit" default:"12"`
|
||||
|
||||
ScheduledTaskQueueSize int `help:"the maximum number of scheduled tasks that are being executed simultaneously" default:"100"`
|
||||
|
||||
@@ -70,11 +70,9 @@ func StartService() {
|
||||
log.Fatalf("unable to init esxi configs: %v", err)
|
||||
}
|
||||
|
||||
if opts.FetchEtcdServiceInfoAndUseEtcdLock {
|
||||
err := initEtcdLockOpts(opts)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
// always try to init etcd options
|
||||
if err := initEtcdLockOpts(opts); err != nil {
|
||||
log.Errorf("try to init etcd options error: %v", err)
|
||||
}
|
||||
|
||||
app := app_common.InitApp(baseOpts, true)
|
||||
@@ -179,13 +177,23 @@ func initDefaultEtcdClient(opts *common_options.DBOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
onKeepaliveFailure := func() {
|
||||
cli := etcd.Default()
|
||||
if opts.LockmanMethod == common_options.LockMethodEtcd {
|
||||
log.Fatalf("etcd keepalive failed and exit when lockman_method is %s", common_options.LockMethodEtcd)
|
||||
}
|
||||
if err := cli.RestartSession(); err != nil {
|
||||
log.Errorf("restart default session error: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
err = etcd.InitDefaultEtcdClient(&etcd.SEtcdOptions{
|
||||
EtcdEndpoint: opts.EtcdEndpoints,
|
||||
EtcdUsername: opts.EtcdUsername,
|
||||
EtcdPassword: opts.EtcdPassword,
|
||||
EtcdEnabldSsl: opts.EtcdUseTLS,
|
||||
TLSConfig: tlsConfig,
|
||||
}, nil)
|
||||
}, onKeepaliveFailure)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "init default etcd client")
|
||||
}
|
||||
@@ -202,7 +210,6 @@ func initEtcdLockOpts(opts *options.ComputeOptions) error {
|
||||
}
|
||||
if etcdEndpoint != nil {
|
||||
opts.EtcdEndpoints = []string{etcdEndpoint.Url}
|
||||
opts.LockmanMethod = common_options.LockMethodEtcd
|
||||
if len(etcdEndpoint.CertId) > 0 {
|
||||
dir, err := ioutil.TempDir("", "etcd-cluster-tls")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user