Skip to content

Commit

Permalink
fix: unblock events watch on context cancel
Browse files Browse the repository at this point in the history
Fixes #4653

This fixes an issue when `etcd` get stuck in `Pre` state so that even
`bootstrap` request doesn't kill it. This looks like a cluster which
fails to bootstrap itself and get stuck on reboot.

Even though `Watch()` aborts on cancel, channel receive will block
forever as no events are delivered.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
(cherry picked from commit 58892cd)
  • Loading branch information
smira committed Nov 22, 2021
1 parent 8b5fcb1 commit f375ba1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/app/machined/pkg/system/services/etcd.go
Expand Up @@ -267,7 +267,11 @@ func generatePKI(r runtime.Runtime) (err error) {
var event state.Event

for {
event = <-watchCh
select {
case <-ctx.Done():
return ctx.Err()
case event = <-watchCh:
}

if event.Type == state.Created || event.Type == state.Updated {
break
Expand Down

0 comments on commit f375ba1

Please sign in to comment.