Skip to content

Commit

Permalink
fix: fix the zk tips
Browse files Browse the repository at this point in the history
  • Loading branch information
luhaoling committed Jan 5, 2024
1 parent 48bea6e commit c9e63cd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions discoveryregistry/zookeeper/zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,19 @@ Connected:
client.zkRoot += zkRoot
client.eventChan = eventChan
client.conn = conn
time.Sleep(time.Second * 5)
if err := client.ensureRoot(); err != nil {
client.Close()
log.ZError(context.Background(), "zk client ensure root bug", err)
return nil, err

var errZK error
for i := 0; i < 300; i++ {
if errZK = client.ensureRoot(); errZK != nil {
log.ZWarn(context.Background(), "zk client ensure root bug: ", errZK, "try: ", i)
time.Sleep(time.Second * 1)
} else {
break
}
}
if errZK != nil {
log.ZError(context.Background(), "zk client ensure root bug", errZK)
return nil, errZK
}
resolver.Register(client)
go client.refresh()
Expand Down

0 comments on commit c9e63cd

Please sign in to comment.