Skip to content

Commit

Permalink
Fix flannel hang if lease expired
Browse files Browse the repository at this point in the history
  • Loading branch information
chenchun committed Aug 11, 2020
1 parent d5c4faf commit 0c26431
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 30 deletions.
9 changes: 5 additions & 4 deletions backend/extension/extension_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ func (n *network) Run(ctx context.Context) {

for {
select {
case evtBatch := <-evts:
case evtBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
n.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions backend/ipsec/ipsec_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ func (n *network) Run(ctx context.Context) {

for {
select {
case evtsBatch := <-evts:
case evtsBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
log.Info("Handling event")
n.handleSubnetEvents(evtsBatch)
case <-ctx.Done():
log.Info("Received DONE")
return
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions backend/route_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ func (n *RouteNetwork) Run(ctx context.Context) {

for {
select {
case evtBatch := <-evts:
case evtBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
n.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions backend/route_network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ func (n *RouteNetwork) Run(ctx context.Context) {

for {
select {
case evtBatch := <-evts:
case evtBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
return
}
n.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions backend/udp/udp_network_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ func (n *network) Run(ctx context.Context) {

for {
select {
case evtBatch := <-evts:
case evtBatch, ok := <-evts:
if !ok {
log.Infof("evts chan closed")
stopProxy(n.ctl)
return
}
n.processSubnetEvents(evtBatch)

case <-ctx.Done():
stopProxy(n.ctl)
return
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions backend/vxlan/vxlan_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ func (nw *network) Run(ctx context.Context) {

for {
select {
case evtBatch := <-events:
case evtBatch, ok := <-events:
if !ok {
log.Infof("evts chan closed")
return
}
nw.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions backend/vxlan/vxlan_network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ func (nw *network) Run(ctx context.Context) {

for {
select {
case evtBatch := <-events:
case evtBatch, ok := <-events:
if !ok {
log.Infof("evts chan closed")
return
}
nw.handleSubnetEvents(evtBatch)

case <-ctx.Done():
return
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion subnet/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (ksm *kubeSubnetManager) WatchLeases(ctx context.Context, cursor interface{
Events: []subnet.Event{event},
}, nil
case <-ctx.Done():
return subnet.LeaseWatchResult{}, nil
return subnet.LeaseWatchResult{}, ctx.Err()
}
}

Expand Down
2 changes: 2 additions & 0 deletions subnet/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func WatchLeases(ctx context.Context, sm Manager, ownLease *Lease, receiver chan
res, err := sm.WatchLeases(ctx, cursor)
if err != nil {
if err == context.Canceled || err == context.DeadlineExceeded {
log.Infof("%v, close receiver chan", err)
close(receiver)
return
}

Expand Down

0 comments on commit 0c26431

Please sign in to comment.