From b09fafb16007b242235fcddbc702fad4bdc240d3 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Mon, 4 May 2020 10:44:33 -0400 Subject: [PATCH] function defactor --- nomad/state/state_store.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 0b6b3de80f6..1e498d1078f 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -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 } @@ -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 @@ -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 {