Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
subnets: move forward the cursor to skip illegal subnet
Browse files Browse the repository at this point in the history
This PR fixs an issue when flannel gets illegal subnet event in
watching leases, it doesn't move forward the etcd cursor and
will stuck in the same invalid event forever.
  • Loading branch information
Sen666666 authored and huangxuesen committed Nov 11, 2020
1 parent 0b1012f commit 1a1b6f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions subnet/etcdv2/local_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ func (m *LocalManager) WatchLeases(ctx context.Context, cursor interface{}) (Lea
log.Warning("Watch of subnet leases failed because etcd index outside history window")
return m.leasesWatchReset(ctx)

case index != 0:
return LeaseWatchResult{Cursor: watchCursor{index}}, err

default:
return LeaseWatchResult{}, err
}
Expand Down
4 changes: 4 additions & 0 deletions subnet/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func WatchLeases(ctx context.Context, sm Manager, ownLease *Lease, receiver chan
return
}

if res.Cursor != nil {
cursor = res.Cursor
}

log.Errorf("Watch subnets: %v", err)
time.Sleep(time.Second)
continue
Expand Down

0 comments on commit 1a1b6f1

Please sign in to comment.