Skip to content

Commit

Permalink
minor docstring fixes and function defactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed May 4, 2020
1 parent 79e9107 commit 97871b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 5 additions & 10 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,11 @@ func deleteNodeCSIPlugins(txn *memdb.Txn, node *structs.Node, index uint64) erro
}

plug := raw.(*structs.CSIPlugin).Copy()
err = deleteNodeFromPlugin(txn, plug, node, index)
err = plug.DeleteNode(node.ID)
if err != nil {
return err
}
err = updateOrGCPlugin(index, txn, plug)
if err != nil {
return err
}
Expand All @@ -1169,14 +1173,6 @@ func deleteNodeCSIPlugins(txn *memdb.Txn, node *structs.Node, index uint64) erro
return nil
}

func deleteNodeFromPlugin(txn *memdb.Txn, plug *structs.CSIPlugin, node *structs.Node, index uint64) error {
err := plug.DeleteNode(node.ID)
if err != nil {
return err
}
return updateOrGCPlugin(index, txn, plug)
}

// updateOrGCPlugin updates a plugin but will delete it if the plugin is empty
func updateOrGCPlugin(index uint64, txn *memdb.Txn, plug *structs.CSIPlugin) error {
plug.ModifyIndex = index
Expand Down Expand Up @@ -1213,7 +1209,6 @@ func (s *StateStore) deleteJobFromPlugin(index uint64, txn *memdb.Txn, job *stru
plugins := map[string]*structs.CSIPlugin{}

for _, a := range allocs {
// if its nil, we can just panic
tg := a.Job.LookupTaskGroup(a.TaskGroup)
for _, t := range tg.Tasks {
if t.CSIPluginConfig != nil {
Expand Down
4 changes: 4 additions & 0 deletions nomad/structs/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ func (p *CSIPlugin) AddPlugin(nodeID string, info *CSIInfo) error {
p.ControllersHealthy -= 1
}
}
// note: for this to work as expected, only a single
// controller for a given plugin can be on a given Nomad
// client, they also conflict on the client so this should be
// ok
p.Controllers[nodeID] = info
if info.Healthy {
p.ControllersHealthy += 1
Expand Down

0 comments on commit 97871b9

Please sign in to comment.