Skip to content

Commit

Permalink
remove redundant nil-check for watch
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Nov 25, 2020
1 parent 2188df3 commit 88a7e71
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1839,9 +1839,7 @@ func (s *StateStore) jobVersionByID(txn *txn, ws *memdb.WatchSet, namespace, id
return nil, err
}

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

var all []*structs.Job
for {
Expand Down Expand Up @@ -1884,9 +1882,7 @@ func (s *StateStore) jobByIDAndVersionImpl(ws memdb.WatchSet, namespace, id stri
return nil, err
}

if ws != nil {
ws.Add(watchCh)
}
ws.Add(watchCh)

if existing != nil {
job := existing.(*structs.Job)
Expand Down Expand Up @@ -2122,9 +2118,8 @@ func (s *StateStore) CSIVolumeByID(ws memdb.WatchSet, namespace, id string) (*st
if err != nil {
return nil, fmt.Errorf("volume lookup failed: %s %v", id, err)
}
if ws != nil {
ws.Add(watchCh)
}

ws.Add(watchCh)

if obj == nil {
return nil, nil
Expand Down Expand Up @@ -2170,6 +2165,7 @@ func (s *StateStore) CSIVolumesByIDPrefix(ws memdb.WatchSet, namespace, volumeID
}

ws.Add(iter.WatchCh())

return iter, nil
}

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

ws.Add(iter.WatchCh())

return iter, nil
Expand All @@ -2223,6 +2220,7 @@ 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())

return iter, nil
Expand Down Expand Up @@ -2519,9 +2517,8 @@ func (s *StateStore) CSIPluginByIDTxn(txn Txn, ws memdb.WatchSet, id string) (*s
if err != nil {
return nil, fmt.Errorf("csi_plugin lookup failed: %s %v", id, err)
}
if ws != nil {
ws.Add(watchCh)
}

ws.Add(watchCh)

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

0 comments on commit 88a7e71

Please sign in to comment.