csi: tolerate missing plugins on job delete (#12114)

If a plugin job fails before successfully fingerprinting the plugins,
the plugin will not exist when we try to delete the job. Tolerate
missing plugins.
This commit is contained in:
Tim Gross 2022-02-24 08:53:15 -05:00 committed by GitHub
parent 246db87a74
commit 5b7b9fdafb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

3
.changelog/12114.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where purging a job with a missing plugin would fail
```

View File

@ -1460,7 +1460,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()
@ -1484,9 +1486,11 @@ func (s *StateStore) deleteJobFromPlugins(index uint64, txn Txn, job *structs.Jo
}
}
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
}