Documentation ¶
Index ¶
- func NeedsUpgrade(bdb *bolt.DB) (bool, error)
- func UpgradeAllocs(logger hclog.Logger, tx *boltdd.Tx) error
- type BoltStateDB
- func (s *BoltStateDB) Close() error
- func (s *BoltStateDB) DB() *boltdd.DB
- func (s *BoltStateDB) DeleteAllocationBucket(allocID string) error
- func (s *BoltStateDB) DeleteTaskBucket(allocID, taskName string) error
- func (s *BoltStateDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
- func (s *BoltStateDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
- func (s *BoltStateDB) GetDevicePluginState() (*dmstate.PluginState, error)
- func (s *BoltStateDB) GetDriverPluginState() (*driverstate.PluginState, error)
- func (s *BoltStateDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
- func (s *BoltStateDB) GetTaskRunnerState(allocID, taskName string) (*trstate.LocalState, *structs.TaskState, error)
- func (s *BoltStateDB) Name() string
- func (s *BoltStateDB) PutAllocation(alloc *structs.Allocation) error
- func (s *BoltStateDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
- func (s *BoltStateDB) PutDevicePluginState(ps *dmstate.PluginState) error
- func (s *BoltStateDB) PutDriverPluginState(ps *driverstate.PluginState) error
- func (s *BoltStateDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error
- func (s *BoltStateDB) PutTaskRunnerLocalState(allocID, taskName string, val *trstate.LocalState) error
- func (s *BoltStateDB) PutTaskState(allocID, taskName string, state *structs.TaskState) error
- func (s *BoltStateDB) Upgrade() error
- type ErrDB
- func (m *ErrDB) Close() error
- func (m *ErrDB) DeleteAllocationBucket(allocID string) error
- func (m *ErrDB) DeleteTaskBucket(allocID, taskName string) error
- func (m *ErrDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
- func (m *ErrDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
- func (m *ErrDB) GetDevicePluginState() (*dmstate.PluginState, error)
- func (m *ErrDB) GetDriverPluginState() (*driverstate.PluginState, error)
- func (m *ErrDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error)
- func (m *ErrDB) Name() string
- func (m *ErrDB) PutAllocation(alloc *structs.Allocation) error
- func (m *ErrDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
- func (m *ErrDB) PutDevicePluginState(ps *dmstate.PluginState) error
- func (m *ErrDB) PutDriverPluginState(ps *driverstate.PluginState) error
- func (m *ErrDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error
- func (m *ErrDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error
- func (m *ErrDB) Upgrade() error
- type MemDB
- func (m *MemDB) Close() error
- func (m *MemDB) DeleteAllocationBucket(allocID string) error
- func (m *MemDB) DeleteTaskBucket(allocID, taskName string) error
- func (m *MemDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
- func (m *MemDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
- func (m *MemDB) GetDevicePluginState() (*dmstate.PluginState, error)
- func (m *MemDB) GetDriverPluginState() (*driverstate.PluginState, error)
- func (m *MemDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
- func (m *MemDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error)
- func (m *MemDB) Name() string
- func (m *MemDB) PutAllocation(alloc *structs.Allocation) error
- func (m *MemDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
- func (m *MemDB) PutDevicePluginState(ps *dmstate.PluginState) error
- func (m *MemDB) PutDriverPluginState(ps *driverstate.PluginState) error
- func (m *MemDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error
- func (m *MemDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error
- func (m *MemDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error
- func (m *MemDB) Upgrade() error
- type NewStateDBFunc
- type NoopDB
- func (n NoopDB) Close() error
- func (n NoopDB) DeleteAllocationBucket(allocID string) error
- func (n NoopDB) DeleteTaskBucket(allocID, taskName string) error
- func (n NoopDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
- func (n NoopDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
- func (n NoopDB) GetDevicePluginState() (*dmstate.PluginState, error)
- func (n NoopDB) GetDriverPluginState() (*driverstate.PluginState, error)
- func (n NoopDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
- func (n NoopDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error)
- func (n NoopDB) Name() string
- func (n NoopDB) PutAllocation(*structs.Allocation) error
- func (n NoopDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
- func (n NoopDB) PutDevicePluginState(ps *dmstate.PluginState) error
- func (n NoopDB) PutDriverPluginState(ps *driverstate.PluginState) error
- func (n NoopDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error
- func (n NoopDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error
- func (n NoopDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error
- func (n NoopDB) Upgrade() error
- type StateDB
- type TaskRunnerHandle08
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NeedsUpgrade ¶
NeedsUpgrade returns true if the BoltDB needs upgrading or false if it is already up to date.
func UpgradeAllocs ¶
UpgradeSchema upgrades the boltdb schema. Example 0.8 schema:
- allocations
- 15d83e8a-74a2-b4da-3f17-ed5c12895ea8
- echo
- simple-all (342 bytes)
- alloc (2827 bytes)
- alloc-dir (166 bytes)
- immutable (15 bytes)
- mutable (1294 bytes)
Types ¶
type BoltStateDB ¶
type BoltStateDB struct {
// contains filtered or unexported fields
}
BoltStateDB persists and restores Nomad client state in a boltdb. All methods are safe for concurrent access.
func (*BoltStateDB) Close ¶
func (s *BoltStateDB) Close() error
Close releases all database resources and unlocks the database file on disk. All transactions must be closed before closing the database.
func (*BoltStateDB) DB ¶
func (s *BoltStateDB) DB() *boltdd.DB
DB allows access to the underlying BoltDB for testing purposes.
func (*BoltStateDB) DeleteAllocationBucket ¶
func (s *BoltStateDB) DeleteAllocationBucket(allocID string) error
DeleteAllocationBucket is used to delete an allocation bucket if it exists.
func (*BoltStateDB) DeleteTaskBucket ¶
func (s *BoltStateDB) DeleteTaskBucket(allocID, taskName string) error
DeleteTaskBucket is used to delete a task bucket if it exists.
func (*BoltStateDB) GetAllAllocations ¶
func (s *BoltStateDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)
GetAllAllocations gets all allocations persisted by this client and returns a map of alloc ids to errors for any allocations that could not be restored.
If a fatal error was encountered it will be returned and the other two values will be nil.
func (*BoltStateDB) GetDeploymentStatus ¶
func (s *BoltStateDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
GetDeploymentStatus retrieves an allocation's DeploymentStatus or returns an error.
func (*BoltStateDB) GetDevicePluginState ¶
func (s *BoltStateDB) GetDevicePluginState() (*dmstate.PluginState, error)
GetDevicePluginState stores the device manager's plugin state or returns an error.
func (*BoltStateDB) GetDriverPluginState ¶
func (s *BoltStateDB) GetDriverPluginState() (*driverstate.PluginState, error)
GetDriverPluginState stores the driver manager's plugin state or returns an error.
func (*BoltStateDB) GetDynamicPluginRegistryState ¶ added in v0.11.2
func (s *BoltStateDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
GetDynamicPluginRegistryState stores the dynamic plugin registry's registry state or returns an error.
func (*BoltStateDB) GetTaskRunnerState ¶
func (s *BoltStateDB) GetTaskRunnerState(allocID, taskName string) (*trstate.LocalState, *structs.TaskState, error)
GetTaskRunnerState returns the LocalState and TaskState for a TaskRunner. LocalState or TaskState will be nil if they do not exist.
If an error is encountered both LocalState and TaskState will be nil.
func (*BoltStateDB) Name ¶
func (s *BoltStateDB) Name() string
func (*BoltStateDB) PutAllocation ¶
func (s *BoltStateDB) PutAllocation(alloc *structs.Allocation) error
PutAllocation stores an allocation or returns an error.
func (*BoltStateDB) PutDeploymentStatus ¶
func (s *BoltStateDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
PutDeploymentStatus stores an allocation's DeploymentStatus or returns an error.
func (*BoltStateDB) PutDevicePluginState ¶
func (s *BoltStateDB) PutDevicePluginState(ps *dmstate.PluginState) error
PutDevicePluginState stores the device manager's plugin state or returns an error.
func (*BoltStateDB) PutDriverPluginState ¶
func (s *BoltStateDB) PutDriverPluginState(ps *driverstate.PluginState) error
PutDriverPluginState stores the driver manager's plugin state or returns an error.
func (*BoltStateDB) PutDynamicPluginRegistryState ¶ added in v0.11.2
func (s *BoltStateDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error
PutDynamicPluginRegistryState stores the dynamic plugin registry's state or returns an error.
func (*BoltStateDB) PutTaskRunnerLocalState ¶
func (s *BoltStateDB) PutTaskRunnerLocalState(allocID, taskName string, val *trstate.LocalState) error
PutTaskRunnerLocalState stores TaskRunner's LocalState or returns an error.
func (*BoltStateDB) PutTaskState ¶
func (s *BoltStateDB) PutTaskState(allocID, taskName string, state *structs.TaskState) error
PutTaskState stores a task's state or returns an error.
func (*BoltStateDB) Upgrade ¶
func (s *BoltStateDB) Upgrade() error
Upgrade bolt state db from 0.8 schema to 0.9 schema. Noop if already using 0.9 schema. Creates a backup before upgrading.
type ErrDB ¶
type ErrDB struct { // Allocs is a preset slice of allocations used in GetAllAllocations Allocs []*structs.Allocation }
ErrDB implements a StateDB that returns errors on restore methods, used for testing
func (*ErrDB) DeleteAllocationBucket ¶
func (*ErrDB) DeleteTaskBucket ¶
func (*ErrDB) GetAllAllocations ¶
func (*ErrDB) GetDeploymentStatus ¶
func (m *ErrDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
func (*ErrDB) GetDevicePluginState ¶
func (m *ErrDB) GetDevicePluginState() (*dmstate.PluginState, error)
GetDevicePluginState stores the device manager's plugin state or returns an error.
func (*ErrDB) GetDriverPluginState ¶
func (m *ErrDB) GetDriverPluginState() (*driverstate.PluginState, error)
func (*ErrDB) GetTaskRunnerState ¶
func (*ErrDB) PutAllocation ¶
func (m *ErrDB) PutAllocation(alloc *structs.Allocation) error
func (*ErrDB) PutDeploymentStatus ¶
func (m *ErrDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
func (*ErrDB) PutDevicePluginState ¶
func (m *ErrDB) PutDevicePluginState(ps *dmstate.PluginState) error
func (*ErrDB) PutDriverPluginState ¶
func (m *ErrDB) PutDriverPluginState(ps *driverstate.PluginState) error
func (*ErrDB) PutTaskRunnerLocalState ¶
func (*ErrDB) PutTaskState ¶
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
MemDB implements a StateDB that stores data in memory and should only be used for testing. All methods are safe for concurrent use.
func (*MemDB) DeleteAllocationBucket ¶
func (*MemDB) DeleteTaskBucket ¶
func (*MemDB) GetAllAllocations ¶
func (*MemDB) GetDeploymentStatus ¶
func (m *MemDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
func (*MemDB) GetDevicePluginState ¶
func (m *MemDB) GetDevicePluginState() (*dmstate.PluginState, error)
GetDevicePluginState stores the device manager's plugin state or returns an error.
func (*MemDB) GetDriverPluginState ¶
func (m *MemDB) GetDriverPluginState() (*driverstate.PluginState, error)
func (*MemDB) GetDynamicPluginRegistryState ¶ added in v0.11.2
func (m *MemDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
func (*MemDB) GetTaskRunnerState ¶
func (*MemDB) PutAllocation ¶
func (m *MemDB) PutAllocation(alloc *structs.Allocation) error
func (*MemDB) PutDeploymentStatus ¶
func (m *MemDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
func (*MemDB) PutDevicePluginState ¶
func (m *MemDB) PutDevicePluginState(ps *dmstate.PluginState) error
func (*MemDB) PutDriverPluginState ¶
func (m *MemDB) PutDriverPluginState(ps *driverstate.PluginState) error
func (*MemDB) PutDynamicPluginRegistryState ¶ added in v0.11.2
func (m *MemDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error
func (*MemDB) PutTaskRunnerLocalState ¶
func (*MemDB) PutTaskState ¶
type NewStateDBFunc ¶
NewStateDBFunc creates a StateDB given a state directory.
func GetStateDBFactory ¶
func GetStateDBFactory(devMode bool) NewStateDBFunc
GetStateDBFactory returns a func for creating a StateDB
type NoopDB ¶
type NoopDB struct{}
NoopDB implements a StateDB that does not persist any data.
func (NoopDB) DeleteAllocationBucket ¶
func (NoopDB) DeleteTaskBucket ¶
func (NoopDB) GetAllAllocations ¶
func (NoopDB) GetDeploymentStatus ¶
func (n NoopDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)
func (NoopDB) GetDevicePluginState ¶
func (n NoopDB) GetDevicePluginState() (*dmstate.PluginState, error)
func (NoopDB) GetDriverPluginState ¶
func (n NoopDB) GetDriverPluginState() (*driverstate.PluginState, error)
func (NoopDB) GetDynamicPluginRegistryState ¶ added in v0.11.2
func (n NoopDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)
func (NoopDB) GetTaskRunnerState ¶
func (NoopDB) PutAllocation ¶
func (n NoopDB) PutAllocation(*structs.Allocation) error
func (NoopDB) PutDeploymentStatus ¶
func (n NoopDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error
func (NoopDB) PutDevicePluginState ¶
func (n NoopDB) PutDevicePluginState(ps *dmstate.PluginState) error
func (NoopDB) PutDriverPluginState ¶
func (n NoopDB) PutDriverPluginState(ps *driverstate.PluginState) error
func (NoopDB) PutDynamicPluginRegistryState ¶ added in v0.11.2
func (n NoopDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error
func (NoopDB) PutTaskRunnerLocalState ¶
func (NoopDB) PutTaskState ¶
type StateDB ¶
type StateDB interface { // Name of implementation. Name() string // 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 // 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. GetAllAllocations() ([]*structs.Allocation, map[string]error, error) // PulAllocation stores an allocation or returns an error if it could // not be stored. PutAllocation(*structs.Allocation) error // 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 // 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. GetTaskRunnerState(allocID, taskName string) (*state.LocalState, *structs.TaskState, error) // 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. PutTaskState(allocID, taskName string, state *structs.TaskState) error // DeleteTaskBucket deletes a task's state bucket if it exists. No // error is returned if it does not exist. DeleteTaskBucket(allocID, taskName string) error // DeleteAllocationBucket deletes an allocation's state bucket if it // exists. No error is returned if it does not exist. DeleteAllocationBucket(allocID string) error // GetDevicePluginState is used to retrieve the device manager's plugin // state. GetDevicePluginState() (*dmstate.PluginState, error) // PutDevicePluginState is used to store the device manager's plugin // state. PutDevicePluginState(state *dmstate.PluginState) error // 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 // 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 // Close the database. Unsafe for further use after calling regardless // of return value. Close() error }
StateDB implementations store and load Nomad client state.
type TaskRunnerHandle08 ¶
type TaskRunnerHandle08 struct { // Docker specific handle info ContainerID string `json:"ContainerID"` Image string `json:"Image"` // LXC specific handle info ContainerName string `json:"ContainerName"` LxcPath string `json:"LxcPath"` // Executor reattach config PluginConfig struct { Pid int `json:"Pid"` AddrNet string `json:"AddrNet"` AddrName string `json:"AddrName"` } `json:"PluginConfig"` }
func UnmarshalPre09HandleID ¶
func UnmarshalPre09HandleID(raw []byte) (*TaskRunnerHandle08, error)
UnmarshalPre09HandleID decodes the pre09 json encoded handle ID
func (*TaskRunnerHandle08) ReattachConfig ¶
func (t *TaskRunnerHandle08) ReattachConfig() *pstructs.ReattachConfig