state

package
v1.6.112 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2023 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedsUpgrade

func NeedsUpgrade(bdb *bbolt.DB) (upgradeTo09, upgradeTo13 bool, err error)

NeedsUpgrade returns true if the BoltDB needs upgrading or false if it is already up to date.

func UpgradeAllocs

func UpgradeAllocs(logger hclog.Logger, tx *boltdd.Tx) error

UpgradeAllocs 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)

func UpgradeDynamicPluginRegistry added in v1.6.105

func UpgradeDynamicPluginRegistry(logger hclog.Logger, tx *boltdd.Tx) error

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, opts ...WriteOption) error

DeleteAllocationBucket is used to delete an allocation bucket if it exists.

func (*BoltStateDB) DeleteCheckResults added in v1.6.105

func (s *BoltStateDB) DeleteCheckResults(allocID string, checkIDs []structs.CheckID) error

func (*BoltStateDB) DeleteTaskBucket

func (s *BoltStateDB) DeleteTaskBucket(allocID, taskName string) error

DeleteTaskBucket is used to delete a task bucket if it exists.

func (*BoltStateDB) GetAcknowledgedState added in v1.6.105

func (s *BoltStateDB) GetAcknowledgedState(allocID string) (*arstate.State, error)

GetAcknowledgedState retrieves an allocation's last acknowledged state

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) GetAllocVolumes added in v1.6.105

func (s *BoltStateDB) GetAllocVolumes(allocID string) (*arstate.AllocVolumes, error)

GetAllocVolumes retrieves stubs of an allocation's dynamic volume mounts so they can be restored.

func (*BoltStateDB) GetCheckResults added in v1.6.105

func (s *BoltStateDB) GetCheckResults() (checks.ClientResults, error)

GetCheckResults gets the check results associated with allocID from the state store.

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.0

func (s *BoltStateDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)

GetDynamicPluginRegistryState stores the dynamic plugin registry's registry state or returns an error.

func (*BoltStateDB) GetNetworkStatus added in v1.6.105

func (s *BoltStateDB) GetNetworkStatus(allocID string) (*structs.AllocNetworkStatus, error)

GetNetworkStatus retrieves an allocation's NetworkStatus or returns an error.

func (*BoltStateDB) GetNodeMeta added in v1.6.105

func (s *BoltStateDB) GetNodeMeta() (m map[string]*string, err error)

GetNodeMeta retrieves node metadata for merging with the copy from the Client's config.

func (*BoltStateDB) GetNodeRegistration added in v1.6.105

func (s *BoltStateDB) GetNodeRegistration() (*cstructs.NodeRegistration, 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) PurgeCheckResults added in v1.6.105

func (s *BoltStateDB) PurgeCheckResults(allocID string) error

func (*BoltStateDB) PutAcknowledgedState added in v1.6.105

func (s *BoltStateDB) PutAcknowledgedState(allocID string, state *arstate.State, opts ...WriteOption) error

PutAcknowledgedState stores an allocation's last acknowledged state or returns an error if it could not be stored.

func (*BoltStateDB) PutAllocVolumes added in v1.6.105

func (s *BoltStateDB) PutAllocVolumes(allocID string, state *arstate.AllocVolumes, opts ...WriteOption) error

PutAllocVolumes stores stubs of an allocation's dynamic volume mounts so they can be restored.

func (*BoltStateDB) PutAllocation

func (s *BoltStateDB) PutAllocation(alloc *structs.Allocation, opts ...WriteOption) error

PutAllocation stores an allocation or returns an error.

func (*BoltStateDB) PutCheckResult added in v1.6.105

func (s *BoltStateDB) PutCheckResult(allocID string, qr *structs.CheckQueryResult) error

PutCheckResult puts qr into the state store.

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.0

func (s *BoltStateDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error

PutDynamicPluginRegistryState stores the dynamic plugin registry's state or returns an error.

func (*BoltStateDB) PutNetworkStatus added in v1.6.105

func (s *BoltStateDB) PutNetworkStatus(allocID string, ds *structs.AllocNetworkStatus, opts ...WriteOption) error

PutNetworkStatus stores an allocation's DeploymentStatus or returns an error.

func (*BoltStateDB) PutNodeMeta added in v1.6.105

func (s *BoltStateDB) PutNodeMeta(meta map[string]*string) error

PutNodeMeta sets dynamic node metadata for merging with the copy from the Client's config.

This overwrites existing dynamic node metadata entirely.

func (*BoltStateDB) PutNodeRegistration added in v1.6.105

func (s *BoltStateDB) PutNodeRegistration(reg *cstructs.NodeRegistration) 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) Close

func (m *ErrDB) Close() error

func (*ErrDB) DeleteAllocationBucket

func (m *ErrDB) DeleteAllocationBucket(allocID string, opts ...WriteOption) error

func (*ErrDB) DeleteCheckResults added in v1.6.105

func (m *ErrDB) DeleteCheckResults(allocID string, checkIDs []structs.CheckID) error

func (*ErrDB) DeleteTaskBucket

func (m *ErrDB) DeleteTaskBucket(allocID, taskName string) error

func (*ErrDB) GetAcknowledgedState added in v1.6.105

func (m *ErrDB) GetAcknowledgedState(allocID string) (*arstate.State, error)

func (*ErrDB) GetAllAllocations

func (m *ErrDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)

func (*ErrDB) GetAllocVolumes added in v1.6.105

func (m *ErrDB) GetAllocVolumes(allocID string) (*arstate.AllocVolumes, error)

func (*ErrDB) GetCheckResults added in v1.6.105

func (m *ErrDB) GetCheckResults() (checks.ClientResults, error)

func (*ErrDB) GetDeploymentStatus

func (m *ErrDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)

func (*ErrDB) GetDevicePluginState

func (m *ErrDB) GetDevicePluginState() (*dmstate.PluginState, error)

func (*ErrDB) GetDriverPluginState

func (m *ErrDB) GetDriverPluginState() (*driverstate.PluginState, error)

func (*ErrDB) GetDynamicPluginRegistryState added in v1.6.105

func (m *ErrDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)

func (*ErrDB) GetNetworkStatus added in v1.6.105

func (m *ErrDB) GetNetworkStatus(allocID string) (*structs.AllocNetworkStatus, error)

func (*ErrDB) GetNodeMeta added in v1.6.105

func (m *ErrDB) GetNodeMeta() (map[string]*string, error)

func (*ErrDB) GetNodeRegistration added in v1.6.105

func (m *ErrDB) GetNodeRegistration() (*cstructs.NodeRegistration, error)

func (*ErrDB) GetTaskRunnerState

func (m *ErrDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error)

func (*ErrDB) Name

func (m *ErrDB) Name() string

func (*ErrDB) PurgeCheckResults added in v1.6.105

func (m *ErrDB) PurgeCheckResults(allocID string) error

func (*ErrDB) PutAcknowledgedState added in v1.6.105

func (m *ErrDB) PutAcknowledgedState(allocID string, state *arstate.State, opts ...WriteOption) error

func (*ErrDB) PutAllocVolumes added in v1.6.105

func (m *ErrDB) PutAllocVolumes(allocID string, state *arstate.AllocVolumes, opts ...WriteOption) error

func (*ErrDB) PutAllocation

func (m *ErrDB) PutAllocation(alloc *structs.Allocation, opts ...WriteOption) error

func (*ErrDB) PutCheckResult added in v1.6.105

func (m *ErrDB) PutCheckResult(allocID string, qr *structs.CheckQueryResult) 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) PutDynamicPluginRegistryState added in v1.6.105

func (m *ErrDB) PutDynamicPluginRegistryState(state *dynamicplugins.RegistryState) error

func (*ErrDB) PutNetworkStatus added in v1.6.105

func (m *ErrDB) PutNetworkStatus(allocID string, ns *structs.AllocNetworkStatus, opts ...WriteOption) error

func (*ErrDB) PutNodeMeta added in v1.6.105

func (m *ErrDB) PutNodeMeta(map[string]*string) error

func (*ErrDB) PutNodeRegistration added in v1.6.105

func (m *ErrDB) PutNodeRegistration(reg *cstructs.NodeRegistration) error

func (*ErrDB) PutTaskRunnerLocalState

func (m *ErrDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error

func (*ErrDB) PutTaskState

func (m *ErrDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error

func (*ErrDB) Upgrade

func (m *ErrDB) Upgrade() error

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 NewMemDB

func NewMemDB(logger hclog.Logger) *MemDB

func (*MemDB) Close

func (m *MemDB) Close() error

func (*MemDB) DeleteAllocationBucket

func (m *MemDB) DeleteAllocationBucket(allocID string, _ ...WriteOption) error

func (*MemDB) DeleteCheckResults added in v1.6.105

func (m *MemDB) DeleteCheckResults(allocID string, checkIDs []structs.CheckID) error

func (*MemDB) DeleteTaskBucket

func (m *MemDB) DeleteTaskBucket(allocID, taskName string) error

func (*MemDB) GetAcknowledgedState added in v1.6.105

func (m *MemDB) GetAcknowledgedState(allocID string) (*arstate.State, error)

func (*MemDB) GetAllAllocations

func (m *MemDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)

func (*MemDB) GetAllocVolumes added in v1.6.105

func (m *MemDB) GetAllocVolumes(allocID string) (*arstate.AllocVolumes, error)

func (*MemDB) GetCheckResults added in v1.6.105

func (m *MemDB) GetCheckResults() (checks.ClientResults, error)

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.0

func (m *MemDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)

func (*MemDB) GetNetworkStatus added in v1.6.105

func (m *MemDB) GetNetworkStatus(allocID string) (*structs.AllocNetworkStatus, error)

func (*MemDB) GetNodeMeta added in v1.6.105

func (m *MemDB) GetNodeMeta() (map[string]*string, error)

func (*MemDB) GetNodeRegistration added in v1.6.105

func (m *MemDB) GetNodeRegistration() (*cstructs.NodeRegistration, error)

func (*MemDB) GetTaskRunnerState

func (m *MemDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error)

func (*MemDB) Name

func (m *MemDB) Name() string

func (*MemDB) PurgeCheckResults added in v1.6.105

func (m *MemDB) PurgeCheckResults(allocID string) error

func (*MemDB) PutAcknowledgedState added in v1.6.105

func (m *MemDB) PutAcknowledgedState(allocID string, state *arstate.State, opts ...WriteOption) error

func (*MemDB) PutAllocVolumes added in v1.6.105

func (m *MemDB) PutAllocVolumes(allocID string, state *arstate.AllocVolumes, opts ...WriteOption) error

func (*MemDB) PutAllocation

func (m *MemDB) PutAllocation(alloc *structs.Allocation, _ ...WriteOption) error

func (*MemDB) PutCheckResult added in v1.6.105

func (m *MemDB) PutCheckResult(allocID string, qr *structs.CheckQueryResult) 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.0

func (m *MemDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error

func (*MemDB) PutNetworkStatus added in v1.6.105

func (m *MemDB) PutNetworkStatus(allocID string, ns *structs.AllocNetworkStatus, _ ...WriteOption) error

func (*MemDB) PutNodeMeta added in v1.6.105

func (m *MemDB) PutNodeMeta(nm map[string]*string) error

func (*MemDB) PutNodeRegistration added in v1.6.105

func (m *MemDB) PutNodeRegistration(reg *cstructs.NodeRegistration) error

func (*MemDB) PutTaskRunnerLocalState

func (m *MemDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error

func (*MemDB) PutTaskState

func (m *MemDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error

func (*MemDB) Upgrade

func (m *MemDB) Upgrade() error

type NewStateDBFunc

type NewStateDBFunc func(logger hclog.Logger, stateDir string) (StateDB, error)

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) Close

func (n NoopDB) Close() error

func (NoopDB) DeleteAllocationBucket

func (n NoopDB) DeleteAllocationBucket(allocID string, opts ...WriteOption) error

func (NoopDB) DeleteCheckResults added in v1.6.105

func (n NoopDB) DeleteCheckResults(allocID string, checkIDs []structs.CheckID) error

func (NoopDB) DeleteTaskBucket

func (n NoopDB) DeleteTaskBucket(allocID, taskName string) error

func (NoopDB) GetAcknowledgedState added in v1.6.105

func (n NoopDB) GetAcknowledgedState(allocID string) (*arstate.State, error)

func (NoopDB) GetAllAllocations

func (n NoopDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error)

func (NoopDB) GetAllocVolumes added in v1.6.105

func (n NoopDB) GetAllocVolumes(allocID string) (*arstate.AllocVolumes, error)

func (NoopDB) GetCheckResults added in v1.6.105

func (n NoopDB) GetCheckResults() (checks.ClientResults, error)

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.0

func (n NoopDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error)

func (NoopDB) GetNetworkStatus added in v1.6.105

func (n NoopDB) GetNetworkStatus(allocID string) (*structs.AllocNetworkStatus, error)

func (NoopDB) GetNodeMeta added in v1.6.105

func (n NoopDB) GetNodeMeta() (map[string]*string, error)

func (NoopDB) GetNodeRegistration added in v1.6.105

func (n NoopDB) GetNodeRegistration() (*cstructs.NodeRegistration, error)

func (NoopDB) GetTaskRunnerState

func (n NoopDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error)

func (NoopDB) Name

func (n NoopDB) Name() string

func (NoopDB) PurgeCheckResults added in v1.6.105

func (n NoopDB) PurgeCheckResults(allocID string) error

func (NoopDB) PutAcknowledgedState added in v1.6.105

func (n NoopDB) PutAcknowledgedState(allocID string, state *arstate.State, opts ...WriteOption) error

func (NoopDB) PutAllocVolumes added in v1.6.105

func (n NoopDB) PutAllocVolumes(allocID string, state *arstate.AllocVolumes, opts ...WriteOption) error

func (NoopDB) PutAllocation

func (n NoopDB) PutAllocation(alloc *structs.Allocation, opts ...WriteOption) error

func (NoopDB) PutCheckResult added in v1.6.105

func (n NoopDB) PutCheckResult(allocID string, qr *structs.CheckQueryResult) 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.0

func (n NoopDB) PutDynamicPluginRegistryState(ps *dynamicplugins.RegistryState) error

func (NoopDB) PutNetworkStatus added in v1.6.105

func (n NoopDB) PutNetworkStatus(allocID string, ds *structs.AllocNetworkStatus, opts ...WriteOption) error

func (NoopDB) PutNodeMeta added in v1.6.105

func (n NoopDB) PutNodeMeta(map[string]*string) error

func (NoopDB) PutNodeRegistration added in v1.6.105

func (n NoopDB) PutNodeRegistration(reg *cstructs.NodeRegistration) error

func (NoopDB) PutTaskRunnerLocalState

func (n NoopDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error

func (NoopDB) PutTaskState

func (n NoopDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error

func (NoopDB) Upgrade

func (n NoopDB) Upgrade() error

type RegistryState12 added in v1.6.105

type RegistryState12 struct {
	Plugins map[string]map[string]*dynamicplugins.PluginInfo
}

RegistryState12 is the dynamic plugin registry state persisted before 1.3.0.

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)

	// PutAllocation stores an allocation or returns an error if it could
	// not be stored.
	PutAllocation(*structs.Allocation, ...WriteOption) error

	// GetDeploymentStatus gets the allocation's deployment status. It may be nil.
	GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error)

	// PutDeploymentStatus sets the allocation's deployment status. It may be nil.
	PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error

	// GetNetworkStatus gets the allocation's network status. It may be nil.
	GetNetworkStatus(allocID string) (*structs.AllocNetworkStatus, error)

	// PutNetworkStatus puts the allocation's network status. It may be nil.
	PutNetworkStatus(allocID string, ns *structs.AllocNetworkStatus, opts ...WriteOption) error

	// PutAcknowledgedState stores an allocation's last acknowledged state or
	// returns an error if it could not be stored.
	PutAcknowledgedState(string, *arstate.State, ...WriteOption) error

	// GetAcknowledgedState retrieves an allocation's last acknowledged
	// state. It may be nil even if there's no error
	GetAcknowledgedState(string) (*arstate.State, error)

	// PutAllocVolumes stores stubs of an allocation's dynamic volume mounts so
	// they can be restored.
	PutAllocVolumes(allocID string, state *arstate.AllocVolumes, opts ...WriteOption) error

	// GetAllocVolumes retrieves stubs of an allocation's dynamic volume mounts
	// so they can be restored.
	GetAllocVolumes(allocID string) (*arstate.AllocVolumes, 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)

	// PutTaskRunnerLocalState 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, opts ...WriteOption) 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 manager's state.
	PutDynamicPluginRegistryState(state *dynamicplugins.RegistryState) error

	// PutCheckResult sets the query result for the check implied in qr.
	PutCheckResult(allocID string, qr *structs.CheckQueryResult) error

	// DeleteCheckResults removes the given set of check results.
	DeleteCheckResults(allocID string, checkIDs []structs.CheckID) error

	// PurgeCheckResults removes all check results of the given allocation.
	PurgeCheckResults(allocID string) error

	// GetCheckResults is used to restore the set of check results on this Client.
	GetCheckResults() (checks.ClientResults, error)

	// PutNodeMeta sets dynamic node metadata for merging with the copy from the
	// Client's config.
	//
	// This overwrites existing dynamic node metadata entirely.
	PutNodeMeta(map[string]*string) error

	// GetNodeMeta retrieves node metadata for merging with the copy from
	// the Client's config.
	GetNodeMeta() (map[string]*string, error)

	PutNodeRegistration(*cstructs.NodeRegistration) error
	GetNodeRegistration() (*cstructs.NodeRegistration, error)

	// Close the database. Unsafe for further use after calling regardless
	// of return value.
	Close() error
}

StateDB implementations store and load Nomad client state.

func NewBoltStateDB

func NewBoltStateDB(logger hclog.Logger, stateDir string) (StateDB, error)

NewBoltStateDB creates or opens an existing boltdb state file or returns an error.

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

type WriteOption added in v1.6.105

type WriteOption func(*WriteOptions)

WriteOption is a function that modifies WriteOptions struct above.

func WithBatchMode added in v1.6.105

func WithBatchMode() WriteOption

WithBatchMode enables Batch mode for write requests (Put* and Delete* operations above).

type WriteOptions added in v1.6.105

type WriteOptions struct {
	// In Batch mode, concurrent writes (Put* and Delete* operations above) are
	// coalesced into a single transaction, increasing write performance. To benefit
	// from this mode, writes must happen concurrently in goroutines, as every write
	// request still waits for the shared transaction to commit before returning.
	// See https://github.com/boltdb/bolt#batch-read-write-transactions for details.
	// This mode is only supported for BoltDB state backend and is ignored in other backends.
	BatchMode bool
}

WriteOptions adjusts the way the data is persisted by the StateDB above. Default is zero/false values for all fields. To provide different values, use With* functions below, like this: statedb.PutAllocation(alloc, WithBatchMode())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL