mirror of https://github.com/hashicorp/consul
Round the node lookup prefix down to the nearest modulo two size before
performing the lookup. Hat tip: @dadgarpull/2707/head
parent
fe49c0a0ab
commit
b94aac3a2c
|
@ -16,6 +16,16 @@ const (
|
|||
minUUIDLookupLen = 2
|
||||
)
|
||||
|
||||
func resizeNodeLookupKey(s string) string {
|
||||
l := len(s)
|
||||
|
||||
if l%2 != 0 {
|
||||
return s[0 : l-1]
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
// Nodes is used to pull the full list of nodes for use during snapshots.
|
||||
func (s *StateSnapshot) Nodes() (memdb.ResultIterator, error) {
|
||||
iter, err := s.tx.Get("nodes", "id")
|
||||
|
@ -703,7 +713,7 @@ func (s *StateStore) NodeServices(ws memdb.WatchSet, nodeNameOrID string) (uint6
|
|||
}
|
||||
|
||||
// Attempt to lookup the node by its node ID
|
||||
iter, err := tx.Get("nodes", "uuid_prefix", nodeNameOrID)
|
||||
iter, err := tx.Get("nodes", "uuid_prefix", resizeNodeLookupKey(nodeNameOrID))
|
||||
if err != nil {
|
||||
ws.Add(watchCh)
|
||||
// TODO(sean@): We could/should log an error re: the uuid_prefix lookup
|
||||
|
|
Loading…
Reference in New Issue