浏览代码

Merge pull request #1368 from Sen666666/fix/invalid-subnet

subnets: move forward the cursor to skip illegal subnet
Rajat Chopra 4 年之前
父节点
当前提交
6ac551d31a
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 3 0
      subnet/etcdv2/local_manager.go
  2. 4 0
      subnet/watch.go

+ 3 - 0
subnet/etcdv2/local_manager.go

@@ -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
 	}

+ 4 - 0
subnet/watch.go

@@ -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