2019-01-09 16:16:33 +00:00
|
|
|
package state
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-01-11 20:53:14 +00:00
|
|
|
|
2019-01-09 16:16:33 +00:00
|
|
|
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/state"
|
|
|
|
dmstate "github.com/hashicorp/nomad/client/devicemanager/state"
|
2020-10-20 20:15:37 +00:00
|
|
|
"github.com/hashicorp/nomad/client/dynamicplugins"
|
2019-01-09 16:16:33 +00:00
|
|
|
driverstate "github.com/hashicorp/nomad/client/pluginmanager/drivermanager/state"
|
2022-06-07 14:18:19 +00:00
|
|
|
"github.com/hashicorp/nomad/client/serviceregistration/checks"
|
2019-01-09 16:16:33 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ErrDB implements a StateDB that returns errors on restore methods, used for testing
|
|
|
|
type ErrDB struct {
|
|
|
|
// Allocs is a preset slice of allocations used in GetAllAllocations
|
|
|
|
Allocs []*structs.Allocation
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) Name() string {
|
|
|
|
return "errdb"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) Upgrade() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error) {
|
|
|
|
return m.Allocs, nil, nil
|
|
|
|
}
|
|
|
|
|
2020-10-20 20:15:37 +00:00
|
|
|
func (m *ErrDB) PutAllocation(alloc *structs.Allocation, opts ...WriteOption) error {
|
2019-01-09 16:16:33 +00:00
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error) {
|
|
|
|
return nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2020-10-12 17:43:04 +00:00
|
|
|
func (m *ErrDB) GetNetworkStatus(allocID string) (*structs.AllocNetworkStatus, error) {
|
|
|
|
return nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2020-10-20 20:15:37 +00:00
|
|
|
func (m *ErrDB) PutNetworkStatus(allocID string, ns *structs.AllocNetworkStatus, opts ...WriteOption) error {
|
2020-10-12 17:43:04 +00:00
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:16:33 +00:00
|
|
|
func (m *ErrDB) GetTaskRunnerState(allocID string, taskName string) (*state.LocalState, *structs.TaskState, error) {
|
|
|
|
return nil, nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) PutTaskRunnerLocalState(allocID string, taskName string, val *state.LocalState) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) PutTaskState(allocID string, taskName string, state *structs.TaskState) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) DeleteTaskBucket(allocID, taskName string) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2020-10-20 20:15:37 +00:00
|
|
|
func (m *ErrDB) DeleteAllocationBucket(allocID string, opts ...WriteOption) error {
|
2019-01-09 16:16:33 +00:00
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) PutDevicePluginState(ps *dmstate.PluginState) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2020-10-20 20:15:37 +00:00
|
|
|
func (m *ErrDB) GetDynamicPluginRegistryState() (*dynamicplugins.RegistryState, error) {
|
|
|
|
return nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) PutDynamicPluginRegistryState(state *dynamicplugins.RegistryState) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:16:33 +00:00
|
|
|
func (m *ErrDB) GetDevicePluginState() (*dmstate.PluginState, error) {
|
|
|
|
return nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) GetDriverPluginState() (*driverstate.PluginState, error) {
|
|
|
|
return nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) PutDriverPluginState(ps *driverstate.PluginState) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
2022-06-07 14:18:19 +00:00
|
|
|
func (m *ErrDB) PutCheckResult(allocID string, qr *structs.CheckQueryResult) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) GetCheckResults() (checks.ClientResults, error) {
|
|
|
|
return nil, fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) DeleteCheckResults(allocID string, checkIDs []structs.CheckID) error {
|
2019-01-09 16:16:33 +00:00
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
2020-10-20 20:15:37 +00:00
|
|
|
|
2022-06-07 14:18:19 +00:00
|
|
|
func (m *ErrDB) PurgeCheckResults(allocID string) error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ErrDB) Close() error {
|
|
|
|
return fmt.Errorf("Error!")
|
|
|
|
}
|