Skip to content

Commit

Permalink
etcdutil, leadership: avoid redundant created watch channel (#7352) (#…
Browse files Browse the repository at this point in the history
…7353)

close #7351

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: lhy1024 <admin@liudos.us>
  • Loading branch information
ti-chi-bot and lhy1024 authored Nov 10, 2023
1 parent d09a4f5 commit d0a17ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/election/leadership.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func (ls *Leadership) Watch(serverCtx context.Context, revision int64) {
continue
}
}
lastReceivedResponseTime = time.Now()
log.Info("watch channel is created", zap.Int64("revision", revision), zap.String("leader-key", ls.leaderKey), zap.String("purpose", ls.purpose))

watchChanLoop:
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,6 @@ func (lw *LoopWatcher) watch(ctx context.Context, revision int64) (nextRevision
}()
ticker := time.NewTicker(RequestProgressInterval)
defer ticker.Stop()
lastReceivedResponseTime := time.Now()

for {
if watcherCancel != nil {
Expand Down Expand Up @@ -736,8 +735,10 @@ func (lw *LoopWatcher) watch(ctx context.Context, revision int64) (nextRevision
continue
}
}
lastReceivedResponseTime := time.Now()
log.Info("watch channel is created in watch loop",
zap.Int64("revision", revision), zap.String("name", lw.name), zap.String("key", lw.key))

watchChanLoop:
select {
case <-ctx.Done():
Expand Down

0 comments on commit d0a17ca

Please sign in to comment.