Fix etcd watch regression in IAM subsystem (#8224)

Fixes #8223
master
Harshavardhana 5 years ago committed by kannappanr
parent 5512baab21
commit 475df52a19
  1. 13
      cmd/iam-etcd-store.go

@ -503,23 +503,29 @@ func (ies *IAMEtcdStore) deleteGroupInfo(name string) error {
func (ies *IAMEtcdStore) watch(sys *IAMSys) {
watchEtcd := func() {
// Refresh IAMSys with etcd watch.
for {
outerLoop:
// Refresh IAMSys with etcd watch.
watchCh := ies.client.Watch(context.Background(),
iamConfigPrefix, etcd.WithPrefix(), etcd.WithKeysOnly())
for {
select {
case <-GlobalServiceDoneCh:
return
case watchResp, ok := <-watchCh:
if !ok {
time.Sleep(1 * time.Second)
continue
// Upon an error on watch channel
// re-init the watch channel.
goto outerLoop
}
if err := watchResp.Err(); err != nil {
logger.LogIf(context.Background(), err)
// log and retry.
time.Sleep(1 * time.Second)
continue
// Upon an error on watch channel
// re-init the watch channel.
goto outerLoop
}
for _, event := range watchResp.Events {
sys.Lock()
@ -529,6 +535,7 @@ func (ies *IAMEtcdStore) watch(sys *IAMSys) {
}
}
}
}
go watchEtcd()
}

Loading…
Cancel
Save