2018-08-08 00:46:37 +00:00
|
|
|
package state
|
|
|
|
|
|
|
|
import (
|
2018-10-04 23:22:01 +00:00
|
|
|
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/state"
|
2018-11-01 01:00:30 +00:00
|
|
|
dmstate "github.com/hashicorp/nomad/client/devicemanager/state"
|
2020-03-12 20:24:58 +00:00
|
|
|
"github.com/hashicorp/nomad/client/dynamicplugins"
|
2018-11-28 03:42:22 +00:00
|
|
|
driverstate "github.com/hashicorp/nomad/client/pluginmanager/drivermanager/state"
|
2018-08-08 00:46:37 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// StateDB implementations store and load Nomad client state.
|
|
|
|
type StateDB interface {
|
2018-10-16 22:17:36 +00:00
|
|
|
// Name of implementation.
|
|
|
|
Name() string
|
|
|
|
|
2018-12-07 01:24:43 +00:00
|
|
|
// Upgrade ensures the layout of the database is at the latest version
|
|
|
|
// or returns an error. Corrupt data will be dropped when possible.
|
|
|
|
// Errors should be considered critical and unrecoverable.
|
|
|
|
Upgrade() error
|
|
|
|
|
2018-10-16 22:17:36 +00:00
|
|
|
// GetAllAllocations returns all valid allocations and a map of
|
|
|
|
// allocation IDs to retrieval errors.
|
|
|
|
//
|
|
|
|
// If a single error is returned then both allocations and the map will be nil.
|
2018-08-08 00:46:37 +00:00
|
|
|
GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
|
2018-10-16 22:17:36 +00:00
|
|
|
|
|
|
|
// PulAllocation stores an allocation or returns an error if it could
|
|
|
|
// not be stored.
|
2018-08-08 00:46:37 +00:00
|
|
|
PutAllocation(*structs.Allocation) error
|
2018-10-16 22:17:36 +00:00
|
|
|
|
2018-12-07 01:24:43 +00:00
|
|
|
// Get/Put DeploymentStatus get and put the allocation's deployment
|
|
|
|
// status. It may be nil.
|
|
|
|
GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
|
|
|
|
PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
|
|
|
|
|
2018-10-16 22:17:36 +00:00
|
|
|
// GetTaskRunnerState returns the LocalState and TaskState for a
|
|
|
|
// TaskRunner. Either state may be nil if it is not found, but if an
|
|
|
|
// error is encountered only the error will be non-nil.
|
2018-08-08 00:46:37 +00:00
|
|
|
GetTaskRunnerState(allocID, taskName string) (*state.LocalState, *structs.TaskState, error)
|
2018-10-16 22:17:36 +00:00
|
|
|
|
|
|
|
// PutTaskRunnerLocalTask stores the LocalState for a TaskRunner or
|
|
|
|
// returns an error.
|
|
|
|
PutTaskRunnerLocalState(allocID, taskName string, val *state.LocalState) error
|
|
|
|
|
|
|
|
// PutTaskState stores the TaskState for a TaskRunner or returns an
|
|
|
|
// error.
|
2018-08-08 00:46:37 +00:00
|
|
|
PutTaskState(allocID, taskName string, state *structs.TaskState) error
|
2018-10-16 22:17:36 +00:00
|
|
|
|
|
|
|
// DeleteTaskBucket deletes a task's state bucket if it exists. No
|
|
|
|
// error is returned if it does not exist.
|
2018-08-23 19:03:17 +00:00
|
|
|
DeleteTaskBucket(allocID, taskName string) error
|
2018-10-16 22:17:36 +00:00
|
|
|
|
|
|
|
// DeleteAllocationBucket deletes an allocation's state bucket if it
|
|
|
|
// exists. No error is returned if it does not exist.
|
2018-08-23 19:03:17 +00:00
|
|
|
DeleteAllocationBucket(allocID string) error
|
2018-10-16 22:17:36 +00:00
|
|
|
|
2018-09-28 17:09:01 +00:00
|
|
|
// GetDevicePluginState is used to retrieve the device manager's plugin
|
|
|
|
// state.
|
2018-11-01 01:00:30 +00:00
|
|
|
GetDevicePluginState() (*dmstate.PluginState, error)
|
2018-09-28 17:09:01 +00:00
|
|
|
|
|
|
|
// PutDevicePluginState is used to store the device manager's plugin
|
|
|
|
// state.
|
2018-11-01 01:00:30 +00:00
|
|
|
PutDevicePluginState(state *dmstate.PluginState) error
|
2018-09-28 17:09:01 +00:00
|
|
|
|
2018-11-28 03:42:22 +00:00
|
|
|
// GetDriverPluginState is used to retrieve the driver manager's plugin
|
|
|
|
// state.
|
|
|
|
GetDriverPluginState() (*driverstate.PluginState, error)
|
|
|
|
|
|
|
|
// PutDriverPluginState is used to store the driver manager's plugin
|
|
|
|
// state.
|
|
|
|
PutDriverPluginState(state *driverstate.PluginState) error
|
|
|
|
|
2020-03-12 20:24:58 +00:00
|
|
|
// GetDynamicPluginRegistryState is used to retrieve a dynamic plugin manager's state.
|
|
|
|
GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
|
|
|
|
|
|
|
|
// PutDynamicPluginRegistryState is used to store the dynamic plugin managers's state.
|
|
|
|
PutDynamicPluginRegistryState(state *dynamicplugins.RegistryState) error
|
|
|
|
|
2018-10-16 22:17:36 +00:00
|
|
|
// Close the database. Unsafe for further use after calling regardless
|
|
|
|
// of return value.
|
2018-08-08 00:46:37 +00:00
|
|
|
Close() error
|
|
|
|
}
|