Skip to content

Commit

Permalink
ensure watches have nil checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Nov 25, 2020
1 parent 2188df3 commit 20d66a5
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2106,9 +2106,9 @@ func (s *StateStore) CSIVolumes(ws memdb.WatchSet) (memdb.ResultIterator, error)
if err != nil {
return nil, fmt.Errorf("csi_volumes lookup failed: %v", err)
}

ws.Add(iter.WatchCh())

if ws != nil {
ws.Add(iter.WatchCh())
}
return iter, nil
}

Expand All @@ -2125,7 +2125,6 @@ func (s *StateStore) CSIVolumeByID(ws memdb.WatchSet, namespace, id string) (*st
if ws != nil {
ws.Add(watchCh)
}

if obj == nil {
return nil, nil
}
Expand Down Expand Up @@ -2168,8 +2167,9 @@ func (s *StateStore) CSIVolumesByIDPrefix(ws memdb.WatchSet, namespace, volumeID
if err != nil {
return nil, err
}

ws.Add(iter.WatchCh())
if ws != nil {
ws.Add(iter.WatchCh())
}
return iter, nil
}

Expand Down Expand Up @@ -2210,8 +2210,9 @@ func (s *StateStore) CSIVolumesByNodeID(ws memdb.WatchSet, nodeID string) (memdb
}
iter.Add(raw)
}
ws.Add(iter.WatchCh())

if ws != nil {
ws.Add(iter.WatchCh())
}
return iter, nil
}

Expand All @@ -2223,8 +2224,9 @@ func (s *StateStore) CSIVolumesByNamespace(ws memdb.WatchSet, namespace string)
if err != nil {
return nil, fmt.Errorf("volume lookup failed: %v", err)
}
ws.Add(iter.WatchCh())

if ws != nil {
ws.Add(iter.WatchCh())
}
return iter, nil
}

Expand Down Expand Up @@ -2481,9 +2483,9 @@ func (s *StateStore) CSIPlugins(ws memdb.WatchSet) (memdb.ResultIterator, error)
if err != nil {
return nil, fmt.Errorf("csi_plugins lookup failed: %v", err)
}

ws.Add(iter.WatchCh())

if ws != nil {
ws.Add(iter.WatchCh())
}
return iter, nil
}

Expand All @@ -2495,9 +2497,9 @@ func (s *StateStore) CSIPluginsByIDPrefix(ws memdb.WatchSet, pluginID string) (m
if err != nil {
return nil, err
}

ws.Add(iter.WatchCh())

if ws != nil {
ws.Add(iter.WatchCh())
}
return iter, nil
}

Expand All @@ -2522,7 +2524,6 @@ func (s *StateStore) CSIPluginByIDTxn(txn Txn, ws memdb.WatchSet, id string) (*s
if ws != nil {
ws.Add(watchCh)
}

if obj != nil {
return obj.(*structs.CSIPlugin), nil
}
Expand Down

0 comments on commit 20d66a5

Please sign in to comment.