diff --git a/db/db.go b/db/db.go index 91edc796d..fb05dc5ec 100644 --- a/db/db.go +++ b/db/db.go @@ -145,16 +145,14 @@ func CreateManager(config config.Config) (err error) { return fmt.Errorf("DB drivers: %s not supported", config.DBType) } - var tryTime time.Duration for { - tryTime++ defaultManager, err = mysql.CreateManager(config) if err == nil { logrus.Infof("db manager is ready") break } - logrus.Errorf("get db manager failed, try time is %v,%s", tryTime, err.Error()) - time.Sleep((5 + tryTime*10) * time.Second) + logrus.Errorf("get db manager failed, try time is %d,%s", 10, err.Error()) + time.Sleep(10 * time.Second) } //TODO:etcd db plugin //defaultManager, err = etcd.CreateManager(config) diff --git a/util/etcd/client.go b/util/etcd/client.go index 2f9444a09..fc2dfb4d3 100644 --- a/util/etcd/client.go +++ b/util/etcd/client.go @@ -115,19 +115,16 @@ func NewClient(ctx context.Context, clientArgs *ClientArgs) (*v3.Client, error) } config.TLS = tlsConfig } - var tryTime time.Duration - tryTime = 0 var etcdClient *v3.Client var err error for { - tryTime++ etcdClient, err = clientv3.New(config) if err == nil { logrus.Infof("etcd.v3 client is ready") return etcdClient, nil } - logrus.Errorf("create etcd.v3 client failed, try time is %v,%s", tryTime, err.Error()) - time.Sleep((5 + tryTime*10) * time.Second) + logrus.Errorf("create etcd.v3 client failed, try time is %d,%s", 10, err.Error()) + time.Sleep(10 * time.Second) } return nil, err }