Skip to content

Commit

Permalink
Merge pull request #12662 from hashicorp/backport/csi-tolerate-nil-pl…
Browse files Browse the repository at this point in the history
…ugin-on-job-delete/grossly-driving-dog

This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core authored Apr 19, 2022
2 parents afd77c0 + bf9c478 commit b94a49c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/12114.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where purging a job with a missing plugin would fail
```
10 changes: 7 additions & 3 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,9 @@ func (s *StateStore) deleteJobFromPlugins(index uint64, txn Txn, job *structs.Jo
return fmt.Errorf("error getting plugin: %s, %v", x.pluginID, err)
}
if plug == nil {
return fmt.Errorf("plugin missing: %s %v", x.pluginID, err)
// plugin was never successfully registered or has been
// GC'd out from under us
continue
}
// only copy once, so we update the same plugin on each alloc
plugins[x.pluginID] = plug.Copy()
Expand All @@ -1444,8 +1446,10 @@ func (s *StateStore) deleteJobFromPlugins(index uint64, txn Txn, job *structs.Jo
}
}

if err = txn.Insert("index", &IndexEntry{"csi_plugins", index}); err != nil {
return fmt.Errorf("index update failed: %v", err)
if len(plugins) > 0 {
if err = txn.Insert("index", &IndexEntry{"csi_plugins", index}); err != nil {
return fmt.Errorf("index update failed: %v", err)
}
}

return nil
Expand Down

0 comments on commit b94a49c

Please sign in to comment.