Whoops. Return an empty set in the event that there are multiple matches.
This commit is contained in:
parent
324215c842
commit
b241cfc7fd
|
@ -694,26 +694,34 @@ func (s *StateStore) NodeServices(ws memdb.WatchSet, nodeNameOrID string) (uint6
|
|||
return 0, nil, fmt.Errorf("node lookup failed: %s", err)
|
||||
}
|
||||
|
||||
if n == nil {
|
||||
if len(nodeNameOrID) >= minUUIDLookupLen {
|
||||
if n != nil {
|
||||
ws.Add(watchCh)
|
||||
} else {
|
||||
if len(nodeNameOrID) < minUUIDLookupLen {
|
||||
ws.Add(watchCh)
|
||||
return 0, nil, nil
|
||||
}
|
||||
|
||||
// Attempt to lookup the node by it's node ID
|
||||
var idWatchCh <-chan struct{}
|
||||
idWatchCh, n, err = tx.FirstWatch("nodes", "uuid_prefix", nodeNameOrID)
|
||||
iter, err := tx.Get("nodes", "uuid_prefix", nodeNameOrID)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("node ID lookup failed: %s", err)
|
||||
}
|
||||
n = iter.Next()
|
||||
if n == nil {
|
||||
ws.Add(watchCh)
|
||||
return 0, nil, nil
|
||||
} else {
|
||||
ws.Add(idWatchCh)
|
||||
}
|
||||
} else {
|
||||
|
||||
idWatchCh := iter.WatchCh()
|
||||
if iter.Next() != nil {
|
||||
// Watch on the channel that did a node name lookup if we don't find
|
||||
// anything when searching by Node ID.
|
||||
ws.Add(watchCh)
|
||||
return 0, nil, nil
|
||||
}
|
||||
} else {
|
||||
ws.Add(watchCh)
|
||||
|
||||
ws.Add(idWatchCh)
|
||||
}
|
||||
|
||||
node := n.(*structs.Node)
|
||||
|
|
Loading…
Reference in New Issue