check if etcd is health before register session (#6215)

Signed-off-by: yefu.chen <yefu.chen@zilliz.com>
This commit is contained in:
neza2017 2021-06-30 14:12:15 +08:00 committed by GitHub
parent 115608afe4
commit 4e4ab4adc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,11 @@ func NewSession(ctx context.Context, metaRoot string, etcdEndpoints []string) *S
if err != nil {
return err
}
ctx2, cancel2 := context.WithTimeout(session.ctx, 5*time.Second)
defer cancel2()
if _, err = etcdCli.Get(ctx2, "health"); err != nil {
return err
}
session.etcdCli = etcdCli
return nil
}