state

package
v0.0.0-...-ae3a0a2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableNamespaces           = "namespaces"
	TableServiceRegistrations = "service_registrations"
	TableVariables            = "variables"
	TableVariablesQuotas      = "variables_quota"
	TableRootKeyMeta          = "root_key_meta"
	TableACLRoles             = "acl_roles"
	TableACLAuthMethods       = "acl_auth_methods"
	TableACLBindingRules      = "acl_binding_rules"
	TableAllocs               = "allocs"
)
View Source
const (
	// NodeEligibilityEventPlanRejectThreshold is the message used when the node
	// is set to ineligible due to multiple plan failures.
	// This is a preventive measure to signal scheduler workers to not consider
	// the node for future placements.
	// Plan rejections for a node are expected due to the optimistic and
	// concurrent nature of the scheduling process, but repeated failures for
	// the same node may indicate an underlying issue not detected by Nomad.
	// The plan applier keeps track of plan rejection history and will mark
	// nodes as ineligible if they cross a given threshold.
	NodeEligibilityEventPlanRejectThreshold = "" /* 151-byte string literal not displayed */

	// NodeRegisterEventRegistered is the message used when the node becomes
	// registered.
	NodeRegisterEventRegistered = "Node registered"

	// NodeRegisterEventReregistered is the message used when the node becomes
	// re-registered.
	NodeRegisterEventReregistered = "Node re-registered"
)

Variables

View Source
var MsgTypeEvents = map[structs.MessageType]string{
	structs.NodeRegisterRequestType:                      structs.TypeNodeRegistration,
	structs.NodeDeregisterRequestType:                    structs.TypeNodeDeregistration,
	structs.UpsertNodeEventsType:                         structs.TypeNodeEvent,
	structs.EvalUpdateRequestType:                        structs.TypeEvalUpdated,
	structs.AllocClientUpdateRequestType:                 structs.TypeAllocationUpdated,
	structs.JobRegisterRequestType:                       structs.TypeJobRegistered,
	structs.NodeUpdateStatusRequestType:                  structs.TypeNodeEvent,
	structs.JobDeregisterRequestType:                     structs.TypeJobDeregistered,
	structs.JobBatchDeregisterRequestType:                structs.TypeJobBatchDeregistered,
	structs.AllocUpdateDesiredTransitionRequestType:      structs.TypeAllocationUpdateDesiredStatus,
	structs.NodeUpdateEligibilityRequestType:             structs.TypeNodeDrain,
	structs.NodeUpdateDrainRequestType:                   structs.TypeNodeDrain,
	structs.BatchNodeUpdateDrainRequestType:              structs.TypeNodeDrain,
	structs.DeploymentStatusUpdateRequestType:            structs.TypeDeploymentUpdate,
	structs.DeploymentPromoteRequestType:                 structs.TypeDeploymentPromotion,
	structs.DeploymentAllocHealthRequestType:             structs.TypeDeploymentAllocHealth,
	structs.ApplyPlanResultsRequestType:                  structs.TypePlanResult,
	structs.ACLTokenDeleteRequestType:                    structs.TypeACLTokenDeleted,
	structs.ACLTokenUpsertRequestType:                    structs.TypeACLTokenUpserted,
	structs.ACLPolicyDeleteRequestType:                   structs.TypeACLPolicyDeleted,
	structs.ACLPolicyUpsertRequestType:                   structs.TypeACLPolicyUpserted,
	structs.ACLRolesDeleteByIDRequestType:                structs.TypeACLRoleDeleted,
	structs.ACLRolesUpsertRequestType:                    structs.TypeACLRoleUpserted,
	structs.ACLAuthMethodsUpsertRequestType:              structs.TypeACLAuthMethodUpserted,
	structs.ACLAuthMethodsDeleteRequestType:              structs.TypeACLAuthMethodDeleted,
	structs.ACLBindingRulesUpsertRequestType:             structs.TypeACLBindingRuleUpserted,
	structs.ACLBindingRulesDeleteRequestType:             structs.TypeACLBindingRuleDeleted,
	structs.ServiceRegistrationUpsertRequestType:         structs.TypeServiceRegistration,
	structs.ServiceRegistrationDeleteByIDRequestType:     structs.TypeServiceDeregistration,
	structs.ServiceRegistrationDeleteByNodeIDRequestType: structs.TypeServiceDeregistration,
}

Functions

func CreateTestCSIPlugin

func CreateTestCSIPlugin(s *StateStore, id string) func()

CreateTestCSIPlugin is a helper that generates the node + fingerprint results necessary to create a CSIPlugin by directly inserting into the state store. The plugin requires a controller.

func CreateTestCSIPluginNodeOnly

func CreateTestCSIPluginNodeOnly(s *StateStore, id string) func()

CreateTestCSIPluginNodeOnly is a helper that generates the node + fingerprint results necessary to create a CSIPlugin by directly inserting into the state store. The plugin does not require a controller. In tests that exercise volume registration, this prevents an error attempting to RPC the node.

func NewChangeTrackerDB

func NewChangeTrackerDB(db *memdb.MemDB, publisher *stream.EventBroker, changesFn changeProcessor) *changeTrackerDB

func RegisterSchemaFactories

func RegisterSchemaFactories(factories ...SchemaFactory)

RegisterSchemaFactories is used to register a table schema.

func TestBadCSIState

func TestBadCSIState(t testing.TB, store *StateStore) error

Types

type ACLPolicyJobACLFieldIndex

type ACLPolicyJobACLFieldIndex struct{}

ACLPolicyJobACLFieldIndex is used to extract the policy's JobACL field and build an index on it.

func (*ACLPolicyJobACLFieldIndex) FromArgs

func (a *ACLPolicyJobACLFieldIndex) FromArgs(args ...interface{}) ([]byte, error)

FromArgs is used to build an exact index lookup based on arguments

func (*ACLPolicyJobACLFieldIndex) FromObject

func (a *ACLPolicyJobACLFieldIndex) FromObject(obj interface{}) (bool, []byte, error)

FromObject is used to extract an index value from an object or to indicate that the index value is missing.

func (*ACLPolicyJobACLFieldIndex) PrefixFromArgs

func (a *ACLPolicyJobACLFieldIndex) PrefixFromArgs(args ...interface{}) ([]byte, error)

PrefixFromArgs returns a prefix that should be used for scanning based on the arguments

type Changes

type Changes struct {
	// Index is the latest index at the time these changes were committed.
	Index   uint64
	Changes memdb.Changes
	MsgType structs.MessageType
}

Changes wraps a memdb.Changes to include the index at which these changes were made.

type IndexEntry

type IndexEntry struct {
	Key   string
	Value uint64
}

IndexEntry is used with the "index" table for managing the latest Raft index affecting a table.

type QueryFn

type QueryFn func(memdb.WatchSet, *StateStore) (resp interface{}, index uint64, err error)

QueryFn is the definition of a function that can be used to implement a basic blocking query against the state store.

type ReadTxn

type ReadTxn interface {
	Get(table, index string, args ...interface{}) (memdb.ResultIterator, error)
	First(table, index string, args ...interface{}) (interface{}, error)
	FirstWatch(table, index string, args ...interface{}) (<-chan struct{}, interface{}, error)
	Abort()
}

ReadTxn is implemented by memdb.Txn to perform read operations.

type ScalingPolicyTargetFieldIndex

type ScalingPolicyTargetFieldIndex struct {
	Field string

	// AllowMissing controls if the field should be ignored if the field is
	// not provided.
	AllowMissing bool
}

StringFieldIndex is used to extract a field from an object using reflection and builds an index on that field.

func (*ScalingPolicyTargetFieldIndex) FromArgs

func (s *ScalingPolicyTargetFieldIndex) FromArgs(args ...interface{}) ([]byte, error)

FromArgs is used to build an exact index lookup based on arguments

func (*ScalingPolicyTargetFieldIndex) FromObject

func (s *ScalingPolicyTargetFieldIndex) FromObject(obj interface{}) (bool, []byte, error)

FromObject is used to extract an index value from an object or to indicate that the index value is missing.

func (*ScalingPolicyTargetFieldIndex) PrefixFromArgs

func (s *ScalingPolicyTargetFieldIndex) PrefixFromArgs(args ...interface{}) ([]byte, error)

PrefixFromArgs returns a prefix that should be used for scanning based on the arguments

type SchemaFactories

type SchemaFactories []SchemaFactory

func GetFactories

func GetFactories() SchemaFactories

type SchemaFactory

type SchemaFactory func() *memdb.TableSchema

SchemaFactory is the factory method for returning a TableSchema

type SliceIterator

type SliceIterator struct {
	// contains filtered or unexported fields
}

func NewSliceIterator

func NewSliceIterator() *SliceIterator

func (*SliceIterator) Add

func (i *SliceIterator) Add(datum interface{})

func (*SliceIterator) Next

func (i *SliceIterator) Next() interface{}

func (*SliceIterator) WatchCh

func (i *SliceIterator) WatchCh() <-chan struct{}

type SortOption

type SortOption bool

SortOption represents how results can be sorted.

const (
	// SortDefault indicates that the result should be returned using the
	// default go-memdb ResultIterator order.
	SortDefault SortOption = false

	// SortReverse indicates that the result should be returned using the
	// reversed go-memdb ResultIterator order.
	SortReverse SortOption = true
)

type StateRestore

type StateRestore struct {
	// contains filtered or unexported fields
}

StateRestore is used to optimize the performance when restoring state by only using a single large transaction instead of thousands of sub transactions.

func (*StateRestore) ACLAuthMethodRestore

func (r *StateRestore) ACLAuthMethodRestore(aclAuthMethod *structs.ACLAuthMethod) error

ACLAuthMethodRestore is used to restore a single ACL auth method into the acl_auth_methods table.

func (*StateRestore) ACLBindingRuleRestore

func (r *StateRestore) ACLBindingRuleRestore(aclBindingRule *structs.ACLBindingRule) error

ACLBindingRuleRestore is used to restore a single ACL binding rule into the acl_binding_rules table.

func (*StateRestore) ACLPolicyRestore

func (r *StateRestore) ACLPolicyRestore(policy *structs.ACLPolicy) error

ACLPolicyRestore is used to restore an ACL policy

func (*StateRestore) ACLRoleRestore

func (r *StateRestore) ACLRoleRestore(aclRole *structs.ACLRole) error

ACLRoleRestore is used to restore a single ACL role into the acl_roles table.

func (*StateRestore) ACLTokenRestore

func (r *StateRestore) ACLTokenRestore(token *structs.ACLToken) error

ACLTokenRestore is used to restore an ACL token

func (*StateRestore) Abort

func (r *StateRestore) Abort()

Abort is used to abort the restore operation

func (*StateRestore) AllocRestore

func (r *StateRestore) AllocRestore(alloc *structs.Allocation) error

AllocRestore is used to restore an allocation

func (*StateRestore) CSIPluginRestore

func (r *StateRestore) CSIPluginRestore(plugin *structs.CSIPlugin) error

CSIPluginRestore is used to restore a CSI plugin

func (*StateRestore) CSIVolumeRestore

func (r *StateRestore) CSIVolumeRestore(volume *structs.CSIVolume) error

CSIVolumeRestore is used to restore a CSI volume

func (*StateRestore) ClusterMetadataRestore

func (r *StateRestore) ClusterMetadataRestore(meta *structs.ClusterMetadata) error

func (*StateRestore) Commit

func (r *StateRestore) Commit() error

Commit is used to commit the restore operation

func (*StateRestore) DeploymentRestore

func (r *StateRestore) DeploymentRestore(deployment *structs.Deployment) error

DeploymentRestore is used to restore a deployment

func (*StateRestore) EvalRestore

func (r *StateRestore) EvalRestore(eval *structs.Evaluation) error

EvalRestore is used to restore an evaluation

func (*StateRestore) IndexRestore

func (r *StateRestore) IndexRestore(idx *IndexEntry) error

IndexRestore is used to restore an index

func (*StateRestore) JobRestore

func (r *StateRestore) JobRestore(job *structs.Job) error

JobRestore is used to restore a job

func (*StateRestore) JobSummaryRestore

func (r *StateRestore) JobSummaryRestore(jobSummary *structs.JobSummary) error

JobSummaryRestore is used to restore a job summary

func (*StateRestore) JobVersionRestore

func (r *StateRestore) JobVersionRestore(version *structs.Job) error

JobVersionRestore is used to restore a job version

func (*StateRestore) NamespaceRestore

func (r *StateRestore) NamespaceRestore(ns *structs.Namespace) error

NamespaceRestore is used to restore a namespace

func (*StateRestore) NodeRestore

func (r *StateRestore) NodeRestore(node *structs.Node) error

NodeRestore is used to restore a node

func (*StateRestore) OneTimeTokenRestore

func (r *StateRestore) OneTimeTokenRestore(token *structs.OneTimeToken) error

OneTimeTokenRestore is used to restore a one-time token

func (*StateRestore) PeriodicLaunchRestore

func (r *StateRestore) PeriodicLaunchRestore(launch *structs.PeriodicLaunch) error

PeriodicLaunchRestore is used to restore a periodic launch.

func (*StateRestore) RootKeyMetaRestore

func (r *StateRestore) RootKeyMetaRestore(quota *structs.RootKeyMeta) error

RootKeyMetaQuotaRestore is used to restore a single root key meta into the root_key_meta table.

func (*StateRestore) SITokenAccessorRestore

func (r *StateRestore) SITokenAccessorRestore(accessor *structs.SITokenAccessor) error

SITokenAccessorRestore is used to restore an SI token accessor

func (*StateRestore) ScalingEventsRestore

func (r *StateRestore) ScalingEventsRestore(jobEvents *structs.JobScalingEvents) error

ScalingEventsRestore is used to restore scaling events for a job

func (*StateRestore) ScalingPolicyRestore

func (r *StateRestore) ScalingPolicyRestore(scalingPolicy *structs.ScalingPolicy) error

ScalingPolicyRestore is used to restore a scaling policy

func (*StateRestore) SchedulerConfigRestore

func (r *StateRestore) SchedulerConfigRestore(schedConfig *structs.SchedulerConfiguration) error

func (*StateRestore) ServiceRegistrationRestore

func (r *StateRestore) ServiceRegistrationRestore(service *structs.ServiceRegistration) error

ServiceRegistrationRestore is used to restore a single service registration into the service_registrations table.

func (*StateRestore) VariablesQuotaRestore

func (r *StateRestore) VariablesQuotaRestore(quota *structs.VariablesQuota) error

VariablesQuotaRestore is used to restore a single variable quota into the variables_quota table.

func (*StateRestore) VariablesRestore

func (r *StateRestore) VariablesRestore(variable *structs.VariableEncrypted) error

VariablesRestore is used to restore a single variable into the variables table.

func (*StateRestore) VaultAccessorRestore

func (r *StateRestore) VaultAccessorRestore(accessor *structs.VaultAccessor) error

VaultAccessorRestore is used to restore a vault accessor

type StateSnapshot

type StateSnapshot struct {
	StateStore
}

StateSnapshot is used to provide a point-in-time snapshot

func (*StateSnapshot) DenormalizeAllocationDiffSlice

func (s *StateSnapshot) DenormalizeAllocationDiffSlice(allocDiffs []*structs.AllocationDiff) ([]*structs.Allocation, error)

DenormalizeAllocationDiffSlice queries the Allocation for each AllocationDiff and merges the updated attributes with the existing Allocation, and attaches the Job provided.

This should only be called on terminal alloc, particularly stopped or preempted allocs

func (*StateSnapshot) DenormalizeAllocationSlice

func (s *StateSnapshot) DenormalizeAllocationSlice(allocs []*structs.Allocation) ([]*structs.Allocation, error)

DenormalizeAllocationSlice queries the Allocation for each allocation diff represented as an Allocation and merges the updated attributes with the existing Allocation, and attaches the Job provided.

This should only be called on terminal allocs, particularly stopped or preempted allocs

func (*StateSnapshot) DenormalizeAllocationsMap

func (s *StateSnapshot) DenormalizeAllocationsMap(nodeAllocations map[string][]*structs.Allocation) error

DenormalizeAllocationsMap takes in a map of nodes to allocations, and queries the Allocation for each of the Allocation diffs and merges the updated attributes with the existing Allocation, and attaches the Job provided

type StateStore

type StateStore struct {
	// contains filtered or unexported fields
}

The StateStore is responsible for maintaining all the Nomad state. It is manipulated by the FSM which maintains consistency through the use of Raft. The goals of the StateStore are to provide high concurrency for read operations without blocking writes, and to provide write availability in the face of reads. EVERY object returned as a result of a read against the state store should be considered a constant and NEVER modified in place.

func NewStateStore

func NewStateStore(config *StateStoreConfig) (*StateStore, error)

NewStateStore is used to create a new state store

func TestStateStore

func TestStateStore(t testing.TB) *StateStore

func TestStateStoreCfg

func TestStateStoreCfg(t testing.TB, cfg *StateStoreConfig) *StateStore

func (*StateStore) ACLPolicies

func (s *StateStore) ACLPolicies(ws memdb.WatchSet) (memdb.ResultIterator, error)

ACLPolicies returns an iterator over all the acl policies

func (*StateStore) ACLPolicyByJob

func (s *StateStore) ACLPolicyByJob(ws memdb.WatchSet, ns, jobID string) (memdb.ResultIterator, error)

ACLPolicyByJob is used to lookup policies that have been attached to a specific job

func (*StateStore) ACLPolicyByName

func (s *StateStore) ACLPolicyByName(ws memdb.WatchSet, name string) (*structs.ACLPolicy, error)

ACLPolicyByName is used to lookup a policy by name

func (*StateStore) ACLPolicyByNamePrefix

func (s *StateStore) ACLPolicyByNamePrefix(ws memdb.WatchSet, prefix string) (memdb.ResultIterator, error)

ACLPolicyByNamePrefix is used to lookup policies by prefix

func (*StateStore) ACLTokenByAccessorID

func (s *StateStore) ACLTokenByAccessorID(ws memdb.WatchSet, id string) (*structs.ACLToken, error)

ACLTokenByAccessorID is used to lookup a token by accessor ID

func (*StateStore) ACLTokenByAccessorIDPrefix

func (s *StateStore) ACLTokenByAccessorIDPrefix(ws memdb.WatchSet, prefix string, sort SortOption) (memdb.ResultIterator, error)

ACLTokenByAccessorIDPrefix is used to lookup tokens by prefix

func (*StateStore) ACLTokenBySecretID

func (s *StateStore) ACLTokenBySecretID(ws memdb.WatchSet, secretID string) (*structs.ACLToken, error)

ACLTokenBySecretID is used to lookup a token by secret ID

func (*StateStore) ACLTokens

func (s *StateStore) ACLTokens(ws memdb.WatchSet, sort SortOption) (memdb.ResultIterator, error)

ACLTokens returns an iterator over all the tokens

func (*StateStore) ACLTokensByExpired

func (s *StateStore) ACLTokensByExpired(global bool) (memdb.ResultIterator, error)

ACLTokensByExpired returns an array accessor IDs of expired ACL tokens. Their expiration is determined against the passed time.Time value.

The function handles global and local tokens independently as determined by the global boolean argument. The number of returned IDs can be limited by the max integer, which is useful to limit the number of tokens we attempt to delete in a single transaction.

func (*StateStore) ACLTokensByGlobal

func (s *StateStore) ACLTokensByGlobal(ws memdb.WatchSet, globalVal bool, sort SortOption) (memdb.ResultIterator, error)

ACLTokensByGlobal returns an iterator over all the tokens filtered by global value

func (*StateStore) Abandon

func (s *StateStore) Abandon()

Abandon is used to signal that the given state store has been abandoned. Calling this more than one time will panic.

func (*StateStore) AbandonCh

func (s *StateStore) AbandonCh() <-chan struct{}

AbandonCh returns a channel you can wait on to know if the state store was abandoned.

func (*StateStore) AllocByID

func (s *StateStore) AllocByID(ws memdb.WatchSet, id string) (*structs.Allocation, error)

AllocByID is used to lookup an allocation by its ID

func (*StateStore) Allocs

func (s *StateStore) Allocs(ws memdb.WatchSet, sort SortOption) (memdb.ResultIterator, error)

Allocs returns an iterator over all the evaluations.

func (*StateStore) AllocsByDeployment

func (s *StateStore) AllocsByDeployment(ws memdb.WatchSet, deploymentID string) ([]*structs.Allocation, error)

AllocsByDeployment returns all the allocations by deployment id

func (*StateStore) AllocsByEval

func (s *StateStore) AllocsByEval(ws memdb.WatchSet, evalID string) ([]*structs.Allocation, error)

AllocsByEval returns all the allocations by eval id

func (*StateStore) AllocsByIDPrefix

func (s *StateStore) AllocsByIDPrefix(ws memdb.WatchSet, namespace, id string, sort SortOption) (memdb.ResultIterator, error)

AllocsByIDPrefix is used to lookup allocs by prefix

func (*StateStore) AllocsByIDPrefixAllNSs

func (s *StateStore) AllocsByIDPrefixAllNSs(ws memdb.WatchSet, prefix string) (memdb.ResultIterator, error)

AllocsByIDPrefixAllNSs is used to lookup allocs by prefix.

func (*StateStore) AllocsByJob

func (s *StateStore) AllocsByJob(ws memdb.WatchSet, namespace, jobID string, anyCreateIndex bool) ([]*structs.Allocation, error)

AllocsByJob returns allocations by job id

func (*StateStore) AllocsByNamespace

func (s *StateStore) AllocsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error)

AllocsByNamespace returns an iterator over all the allocations in the namespace

func (*StateStore) AllocsByNamespaceOrdered

func (s *StateStore) AllocsByNamespaceOrdered(ws memdb.WatchSet, namespace string, sort SortOption) (memdb.ResultIterator, error)

func (*StateStore) AllocsByNode

func (s *StateStore) AllocsByNode(ws memdb.WatchSet, node string) ([]*structs.Allocation, error)

AllocsByNode returns all the allocations by node

func (*StateStore) AllocsByNodeTerminal

func (s *StateStore) AllocsByNodeTerminal(ws memdb.WatchSet, node string, terminal bool) ([]*structs.Allocation, error)

AllocsByNodeTerminal returns all the allocations by node and terminal status.

func (*StateStore) AutopilotCASConfig

func (s *StateStore) AutopilotCASConfig(index, cidx uint64, config *structs.AutopilotConfig) (bool, error)

AutopilotCASConfig is used to try updating the Autopilot configuration with a given Raft index. If the CAS index specified is not equal to the last observed index for the config, then the call is a noop,

func (*StateStore) AutopilotConfig

func (s *StateStore) AutopilotConfig() (uint64, *structs.AutopilotConfig, error)

AutopilotConfig is used to get the current Autopilot configuration.

func (*StateStore) AutopilotSetConfig

func (s *StateStore) AutopilotSetConfig(index uint64, config *structs.AutopilotConfig) error

AutopilotSetConfig is used to set the current Autopilot configuration.

func (*StateStore) BatchUpdateNodeDrain

func (s *StateStore) BatchUpdateNodeDrain(msgType structs.MessageType, index uint64, updatedAt int64,
	updates map[string]*structs.DrainUpdate, events map[string]*structs.NodeEvent) error

BatchUpdateNodeDrain is used to update the drain of a node set of nodes. This is currently only called when node drain is completed by the drainer.

func (*StateStore) BlockingQuery

func (s *StateStore) BlockingQuery(query QueryFn, minIndex uint64, ctx context.Context) (
	resp interface{}, index uint64, err error)

BlockingQuery takes a query function and runs the function until the minimum query index is met or until the passed context is cancelled.

func (*StateStore) BootstrapACLTokens

func (s *StateStore) BootstrapACLTokens(msgType structs.MessageType, index uint64, resetIndex uint64, token *structs.ACLToken) error

BootstrapACLTokens is used to create an initial ACL token.

func (*StateStore) CSIPluginByID

func (s *StateStore) CSIPluginByID(ws memdb.WatchSet, id string) (*structs.CSIPlugin, error)

CSIPluginByID returns a named CSIPlugin. This method creates a new transaction so you should not call it from within another transaction.

func (*StateStore) CSIPluginByIDTxn

func (s *StateStore) CSIPluginByIDTxn(txn Txn, ws memdb.WatchSet, id string) (*structs.CSIPlugin, error)

CSIPluginByIDTxn returns a named CSIPlugin

func (*StateStore) CSIPluginDenormalize

func (s *StateStore) CSIPluginDenormalize(ws memdb.WatchSet, plug *structs.CSIPlugin) (*structs.CSIPlugin, error)

CSIPluginDenormalize returns a CSIPlugin with allocation details. Always called on a copy of the plugin.

func (*StateStore) CSIPluginDenormalizeTxn

func (s *StateStore) CSIPluginDenormalizeTxn(txn Txn, ws memdb.WatchSet, plug *structs.CSIPlugin) (*structs.CSIPlugin, error)

func (*StateStore) CSIPlugins

func (s *StateStore) CSIPlugins(ws memdb.WatchSet) (memdb.ResultIterator, error)

CSIPlugins returns the unfiltered list of all plugin health status

func (*StateStore) CSIPluginsByIDPrefix

func (s *StateStore) CSIPluginsByIDPrefix(ws memdb.WatchSet, pluginID string) (memdb.ResultIterator, error)

CSIPluginsByIDPrefix supports search

func (*StateStore) CSIVolumeByID

func (s *StateStore) CSIVolumeByID(ws memdb.WatchSet, namespace, id string) (*structs.CSIVolume, error)

CSIVolumeByID is used to lookup a single volume. Returns a copy of the volume because its plugins and allocations are denormalized to provide accurate Health.

func (*StateStore) CSIVolumeClaim

func (s *StateStore) CSIVolumeClaim(index uint64, namespace, id string, claim *structs.CSIVolumeClaim) error

CSIVolumeClaim updates the volume's claim count and allocation list

func (*StateStore) CSIVolumeDenormalize

func (s *StateStore) CSIVolumeDenormalize(ws memdb.WatchSet, vol *structs.CSIVolume) (*structs.CSIVolume, error)

CSIVolumeDenormalize returns a CSIVolume with its current Allocations and Claims, including creating new PastClaims for terminal or garbage collected allocations. This ensures we have a consistent state. Note that it mutates the original volume and so should always be called on a Copy after reading from the state store.

func (*StateStore) CSIVolumeDenormalizePlugins

func (s *StateStore) CSIVolumeDenormalizePlugins(ws memdb.WatchSet, vol *structs.CSIVolume) (*structs.CSIVolume, error)

CSIVolumeDenormalizePlugins returns a CSIVolume with current health and plugins, but without allocations. Use this for current volume metadata, handling lists of volumes. Use CSIVolumeDenormalize for volumes containing both health and current allocations.

func (*StateStore) CSIVolumeDeregister

func (s *StateStore) CSIVolumeDeregister(index uint64, namespace string, ids []string, force bool) error

CSIVolumeDeregister removes the volume from the server

func (*StateStore) CSIVolumes

func (s *StateStore) CSIVolumes(ws memdb.WatchSet) (memdb.ResultIterator, error)

CSIVolumes returns the unfiltered list of all volumes. Caller should snapshot if it wants to also denormalize the plugins.

func (*StateStore) CSIVolumesByIDPrefix

func (s *StateStore) CSIVolumesByIDPrefix(ws memdb.WatchSet, namespace, volumeID string) (memdb.ResultIterator, error)

CSIVolumesByIDPrefix supports search. Caller should snapshot if it wants to also denormalize the plugins. If using a prefix with the wildcard namespace, the results will not use the index prefix.

func (*StateStore) CSIVolumesByNamespace

func (s *StateStore) CSIVolumesByNamespace(ws memdb.WatchSet, namespace, prefix string) (memdb.ResultIterator, error)

CSIVolumesByNamespace looks up the entire csi_volumes table

func (*StateStore) CSIVolumesByNodeID

func (s *StateStore) CSIVolumesByNodeID(ws memdb.WatchSet, prefix, nodeID string) (memdb.ResultIterator, error)

CSIVolumesByNodeID looks up CSIVolumes in use on a node. Caller should snapshot if it wants to also denormalize the plugins.

func (*StateStore) CSIVolumesByPluginID

func (s *StateStore) CSIVolumesByPluginID(ws memdb.WatchSet, namespace, prefix, pluginID string) (memdb.ResultIterator, error)

CSIVolumesByPluginID looks up csi_volumes by pluginID. Caller should snapshot if it wants to also denormalize the plugins.

func (*StateStore) CanBootstrapACLToken

func (s *StateStore) CanBootstrapACLToken() (bool, uint64, error)

CanBootstrapACLToken checks if bootstrapping is possible and returns the reset index

func (*StateStore) ClusterMetadata

func (s *StateStore) ClusterMetadata(ws memdb.WatchSet) (*structs.ClusterMetadata, error)

func (*StateStore) ClusterSetMetadata

func (s *StateStore) ClusterSetMetadata(index uint64, meta *structs.ClusterMetadata) error

func (*StateStore) Config

func (s *StateStore) Config() *StateStoreConfig

Config returns the state store configuration.

func (*StateStore) DeleteACLAuthMethods

func (s *StateStore) DeleteACLAuthMethods(index uint64, authMethodNames []string) error

DeleteACLAuthMethods is responsible for batch deleting ACL methods. It uses a single write transaction for efficiency, however, any error means no entries will be committed. An error is produced if a method is not found within state which has been passed within the array.

func (*StateStore) DeleteACLBindingRules

func (s *StateStore) DeleteACLBindingRules(index uint64, bindingRuleIDs []string) error

DeleteACLBindingRules is responsible for batch deleting ACL binding rules. It uses a single write transaction for efficiency, however, any error means no entries will be committed. An error is produced if a rule is not found within state which has been passed within the array.

func (*StateStore) DeleteACLPolicies

func (s *StateStore) DeleteACLPolicies(msgType structs.MessageType, index uint64, names []string) error

DeleteACLPolicies deletes the policies with the given names

func (*StateStore) DeleteACLRolesByID

func (s *StateStore) DeleteACLRolesByID(
	msgType structs.MessageType, index uint64, roleIDs []string) error

DeleteACLRolesByID is responsible for batch deleting ACL roles based on their ID. It uses a single write transaction for efficiency, however, any error means no entries will be committed. An error is produced if a role is not found within state which has been passed within the array.

func (*StateStore) DeleteACLTokens

func (s *StateStore) DeleteACLTokens(msgType structs.MessageType, index uint64, ids []string) error

DeleteACLTokens deletes the tokens with the given accessor ids

func (*StateStore) DeleteCSIPlugin

func (s *StateStore) DeleteCSIPlugin(index uint64, id string) error

DeleteCSIPlugin deletes the plugin if it's not in use.

func (*StateStore) DeleteDeployment

func (s *StateStore) DeleteDeployment(index uint64, deploymentIDs []string) error

DeleteDeployment is used to delete a set of deployments by ID

func (*StateStore) DeleteEval

func (s *StateStore) DeleteEval(index uint64, evals, allocs []string, userInitiated bool) error

DeleteEval is used to delete an evaluation

func (*StateStore) DeleteEvalsByFilter

func (s *StateStore) DeleteEvalsByFilter(index uint64, filterExpr string, pageToken string, perPage int32) error

DeleteEvalsByFilter is used to delete all evals that are both safe to delete and match a filter.

func (*StateStore) DeleteJob

func (s *StateStore) DeleteJob(index uint64, namespace, jobID string) error

DeleteJob is used to deregister a job

func (*StateStore) DeleteJobSummary

func (s *StateStore) DeleteJobSummary(index uint64, namespace, id string) error

DeleteJobSummary deletes the job summary with the given ID. This is for testing purposes only.

func (*StateStore) DeleteJobTxn

func (s *StateStore) DeleteJobTxn(index uint64, namespace, jobID string, txn Txn) error

DeleteJobTxn is used to deregister a job, like DeleteJob, but in a transaction. Useful for when making multiple modifications atomically

func (*StateStore) DeleteNamespaces

func (s *StateStore) DeleteNamespaces(index uint64, names []string) error

DeleteNamespaces is used to remove a set of namespaces

func (*StateStore) DeleteNode

func (s *StateStore) DeleteNode(msgType structs.MessageType, index uint64, nodes []string) error

DeleteNode deregisters a batch of nodes

func (*StateStore) DeleteOneTimeTokens

func (s *StateStore) DeleteOneTimeTokens(msgType structs.MessageType, index uint64, ids []string) error

DeleteOneTimeTokens deletes the tokens with the given ACLToken Accessor IDs

func (*StateStore) DeletePeriodicLaunch

func (s *StateStore) DeletePeriodicLaunch(index uint64, namespace, jobID string) error

DeletePeriodicLaunch is used to delete the periodic launch

func (*StateStore) DeletePeriodicLaunchTxn

func (s *StateStore) DeletePeriodicLaunchTxn(index uint64, namespace, jobID string, txn Txn) error

DeletePeriodicLaunchTxn is used to delete the periodic launch, like DeletePeriodicLaunch but in a transaction. Useful for when making multiple modifications atomically

func (*StateStore) DeleteRootKeyMeta

func (s *StateStore) DeleteRootKeyMeta(index uint64, keyID string) error

DeleteRootKeyMeta deletes a single root key, or returns an error if it doesn't exist.

func (*StateStore) DeleteSITokenAccessors

func (s *StateStore) DeleteSITokenAccessors(index uint64, accessors []*structs.SITokenAccessor) error

DeleteSITokenAccessors is used to delete a set of Service Identity token accessors.

func (*StateStore) DeleteScalingPolicies

func (s *StateStore) DeleteScalingPolicies(index uint64, ids []string) error

func (*StateStore) DeleteScalingPoliciesTxn

func (s *StateStore) DeleteScalingPoliciesTxn(index uint64, ids []string, txn *txn) error

DeleteScalingPoliciesTxn is used to delete a set of scaling policies by ID.

func (*StateStore) DeleteServiceRegistrationByID

func (s *StateStore) DeleteServiceRegistrationByID(
	msgType structs.MessageType, index uint64, namespace, id string) error

DeleteServiceRegistrationByID is responsible for deleting a single service registration based on it's ID and namespace. If the service registration is not found within state, an error will be returned.

func (*StateStore) DeleteServiceRegistrationByNodeID

func (s *StateStore) DeleteServiceRegistrationByNodeID(
	msgType structs.MessageType, index uint64, nodeID string) error

DeleteServiceRegistrationByNodeID deletes all service registrations that belong on a single node. If there are no registrations tied to the nodeID, the call will noop without an error.

func (*StateStore) DeleteVaultAccessors

func (s *StateStore) DeleteVaultAccessors(index uint64, accessors []*structs.VaultAccessor) error

DeleteVaultAccessors is used to delete a set of Vault Accessors

func (*StateStore) DeploymentByID

func (s *StateStore) DeploymentByID(ws memdb.WatchSet, deploymentID string) (*structs.Deployment, error)

func (*StateStore) Deployments

func (s *StateStore) Deployments(ws memdb.WatchSet, sort SortOption) (memdb.ResultIterator, error)

func (*StateStore) DeploymentsByIDPrefix

func (s *StateStore) DeploymentsByIDPrefix(ws memdb.WatchSet, namespace, deploymentID string, sort SortOption) (memdb.ResultIterator, error)

func (*StateStore) DeploymentsByJobID

func (s *StateStore) DeploymentsByJobID(ws memdb.WatchSet, namespace, jobID string, all bool) ([]*structs.Deployment, error)

func (*StateStore) DeploymentsByNamespace

func (s *StateStore) DeploymentsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error)

func (*StateStore) DeploymentsByNamespaceOrdered

func (s *StateStore) DeploymentsByNamespaceOrdered(ws memdb.WatchSet, namespace string, sort SortOption) (memdb.ResultIterator, error)

func (*StateStore) EvalByID

func (s *StateStore) EvalByID(ws memdb.WatchSet, id string) (*structs.Evaluation, error)

EvalByID is used to lookup an eval by its ID

func (*StateStore) EvalIsUserDeleteSafe

func (s *StateStore) EvalIsUserDeleteSafe(ws memdb.WatchSet, eval *structs.Evaluation) (bool, error)

EvalIsUserDeleteSafe ensures an evaluation is safe to delete based on its related allocation and job information. This follows similar, but different rules to the eval reap checking, to ensure evaluations for running allocs or allocs which need the evaluation detail are not deleted.

Returns both a bool and an error so that error in querying the related objects can be differentiated from reporting that the eval isn't safe to delete.

func (*StateStore) Evals

func (s *StateStore) Evals(ws memdb.WatchSet, sort SortOption) (memdb.ResultIterator, error)

Evals returns an iterator over all the evaluations in ascending or descending order of CreationIndex as determined by the reverse parameter.

func (*StateStore) EvalsByIDPrefix

func (s *StateStore) EvalsByIDPrefix(ws memdb.WatchSet, namespace, id string, sort SortOption) (memdb.ResultIterator, error)

EvalsByIDPrefix is used to lookup evaluations by prefix in a particular namespace

func (*StateStore) EvalsByJob

func (s *StateStore) EvalsByJob(ws memdb.WatchSet, namespace, jobID string) ([]*structs.Evaluation, error)

EvalsByJob returns all the evaluations by job id

func (*StateStore) EvalsByNamespace

func (s *StateStore) EvalsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error)

EvalsByNamespace returns an iterator over all evaluations in no particular order.

todo(shoenig): can this be removed?

func (*StateStore) EvalsByNamespaceOrdered

func (s *StateStore) EvalsByNamespaceOrdered(ws memdb.WatchSet, namespace string, sort SortOption) (memdb.ResultIterator, error)

func (*StateStore) EvalsRelatedToID

func (s *StateStore) EvalsRelatedToID(ws memdb.WatchSet, id string) ([]*structs.EvaluationStub, error)

EvalsRelatedToID is used to retrieve the evals that are related (next, previous, or blocked) to the provided eval ID.

func (*StateStore) EventBroker

func (s *StateStore) EventBroker() (*stream.EventBroker, error)

func (*StateStore) ExpireOneTimeTokens

func (s *StateStore) ExpireOneTimeTokens(msgType structs.MessageType, index uint64, timestamp time.Time) error

ExpireOneTimeTokens deletes tokens that have expired

func (*StateStore) GetACLAuthMethodByName

func (s *StateStore) GetACLAuthMethodByName(ws memdb.WatchSet, authMethod string) (*structs.ACLAuthMethod, error)

GetACLAuthMethodByName returns a single ACL auth method specified by the input name. The auth method object will be nil, if no matching entry was found; it is the responsibility of the caller to check for this.

func (*StateStore) GetACLAuthMethods

func (s *StateStore) GetACLAuthMethods(ws memdb.WatchSet) (memdb.ResultIterator, error)

GetACLAuthMethods returns an iterator that contains all ACL auth methods stored within state.

func (*StateStore) GetACLBindingRule

func (s *StateStore) GetACLBindingRule(ws memdb.WatchSet, ruleID string) (*structs.ACLBindingRule, error)

GetACLBindingRule returns a single ACL binding rule specified by the input ID. The binding rule object will be nil, if no matching entry was found; it is the responsibility of the caller to check for this.

func (*StateStore) GetACLBindingRules

func (s *StateStore) GetACLBindingRules(ws memdb.WatchSet) (memdb.ResultIterator, error)

GetACLBindingRules returns an iterator that contains all ACL binding rules stored within state.

func (*StateStore) GetACLBindingRulesByAuthMethod

func (s *StateStore) GetACLBindingRulesByAuthMethod(
	ws memdb.WatchSet, authMethod string) (memdb.ResultIterator, error)

GetACLBindingRulesByAuthMethod returns an iterator with all binding rules associated with the named authentication method.

func (*StateStore) GetACLRoleByID

func (s *StateStore) GetACLRoleByID(ws memdb.WatchSet, roleID string) (*structs.ACLRole, error)

GetACLRoleByID returns a single ACL role specified by the input ID. The role object will be nil, if no matching entry was found; it is the responsibility of the caller to check for this.

func (*StateStore) GetACLRoleByIDPrefix

func (s *StateStore) GetACLRoleByIDPrefix(ws memdb.WatchSet, idPrefix string) (memdb.ResultIterator, error)

GetACLRoleByIDPrefix is used to lookup ACL policies using a prefix to match on the ID.

func (*StateStore) GetACLRoleByName

func (s *StateStore) GetACLRoleByName(ws memdb.WatchSet, roleName string) (*structs.ACLRole, error)

GetACLRoleByName returns a single ACL role specified by the input name. The role object will be nil, if no matching entry was found; it is the responsibility of the caller to check for this.

func (*StateStore) GetACLRoles

func (s *StateStore) GetACLRoles(ws memdb.WatchSet) (memdb.ResultIterator, error)

GetACLRoles returns an iterator that contains all ACL roles stored within state.

func (*StateStore) GetActiveRootKeyMeta

func (s *StateStore) GetActiveRootKeyMeta(ws memdb.WatchSet) (*structs.RootKeyMeta, error)

GetActiveRootKeyMeta returns the metadata for the currently active root key

func (*StateStore) GetDefaultACLAuthMethodByType

func (s *StateStore) GetDefaultACLAuthMethodByType(ws memdb.WatchSet, methodType string) (*structs.ACLAuthMethod, error)

GetDefaultACLAuthMethodByType returns a default ACL Auth Methods for a given auth type. Since we only want 1 default auth method per type, this function is used during upserts to facilitate that check.

func (*StateStore) GetServiceRegistrationByID

func (s *StateStore) GetServiceRegistrationByID(
	ws memdb.WatchSet, namespace, id string) (*structs.ServiceRegistration, error)

GetServiceRegistrationByID returns a single registration. The registration will be nil, if no matching entry was found; it is the responsibility of the caller to check for this.

func (*StateStore) GetServiceRegistrationByName

func (s *StateStore) GetServiceRegistrationByName(
	ws memdb.WatchSet, namespace, name string) (memdb.ResultIterator, error)

GetServiceRegistrationByName returns an iterator that contains all service registrations whose namespace and name match the input parameters. This func therefore represents how to identify a single, collection of services that are logically grouped together.

func (*StateStore) GetServiceRegistrations

func (s *StateStore) GetServiceRegistrations(ws memdb.WatchSet) (memdb.ResultIterator, error)

GetServiceRegistrations returns an iterator that contains all service registrations stored within state. This is primarily useful when performing listings which use the namespace wildcard operator. The caller is responsible for ensuring ACL access is confirmed, or filtering is performed before responding.

func (*StateStore) GetServiceRegistrationsByAllocID

func (s *StateStore) GetServiceRegistrationsByAllocID(
	ws memdb.WatchSet, allocID string) (memdb.ResultIterator, error)

GetServiceRegistrationsByAllocID returns an iterator containing all the service registrations corresponding to a single allocation.

func (*StateStore) GetServiceRegistrationsByJobID

func (s *StateStore) GetServiceRegistrationsByJobID(
	ws memdb.WatchSet, namespace, jobID string) (memdb.ResultIterator, error)

GetServiceRegistrationsByJobID returns an iterator containing all the service registrations corresponding to a single job.

func (*StateStore) GetServiceRegistrationsByNamespace

func (s *StateStore) GetServiceRegistrationsByNamespace(
	ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error)

GetServiceRegistrationsByNamespace returns an iterator that contains all registrations belonging to the provided namespace.

func (*StateStore) GetServiceRegistrationsByNodeID

func (s *StateStore) GetServiceRegistrationsByNodeID(
	ws memdb.WatchSet, nodeID string) ([]*structs.ServiceRegistration, error)

GetServiceRegistrationsByNodeID identifies all service registrations tied to the specified nodeID. This is useful for performing an in-memory lookup in order to avoid calling DeleteServiceRegistrationByNodeID via a Raft message.

func (*StateStore) GetVariable

func (s *StateStore) GetVariable(
	ws memdb.WatchSet, namespace, path string) (*structs.VariableEncrypted, error)

GetVariable returns a single variable at a given namespace and path.

func (*StateStore) GetVariablesByKeyID

func (s *StateStore) GetVariablesByKeyID(
	ws memdb.WatchSet, keyID string) (memdb.ResultIterator, error)

GetVariablesByKeyID returns an iterator that contains all variables that were encrypted with a particular key

func (*StateStore) GetVariablesByNamespace

func (s *StateStore) GetVariablesByNamespace(
	ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error)

GetVariablesByNamespace returns an iterator that contains all variables belonging to the provided namespace.

func (*StateStore) GetVariablesByNamespaceAndPrefix

func (s *StateStore) GetVariablesByNamespaceAndPrefix(
	ws memdb.WatchSet, namespace, prefix string) (memdb.ResultIterator, error)

GetVariablesByNamespaceAndPrefix returns an iterator that contains all variables belonging to the provided namespace that match the prefix.

func (*StateStore) GetVariablesByPrefix

func (s *StateStore) GetVariablesByPrefix(
	ws memdb.WatchSet, prefix string) (memdb.ResultIterator, error)

GetVariablesByPrefix returns an iterator that contains all variables that match the prefix in any namespace. Namespace filtering is the responsibility of the caller.

func (*StateStore) Index

func (s *StateStore) Index(name string) (uint64, error)

Index finds the matching index value

func (*StateStore) Indexes

func (s *StateStore) Indexes() (memdb.ResultIterator, error)

Indexes returns an iterator over all the indexes

func (*StateStore) IsRootKeyMetaInUse

func (s *StateStore) IsRootKeyMetaInUse(keyID string) (bool, error)

IsRootKeyMetaInUse determines whether a key has been used to sign a workload identity for a live allocation or encrypt any variables

func (*StateStore) JobByID

func (s *StateStore) JobByID(ws memdb.WatchSet, namespace, id string) (*structs.Job, error)

JobByID is used to lookup a job by its ID. JobByID returns the current/latest job version.

func (*StateStore) JobByIDAndVersion

func (s *StateStore) JobByIDAndVersion(ws memdb.WatchSet, namespace, id string, version uint64) (*structs.Job, error)

JobByIDAndVersion returns the job identified by its ID and Version. The passed watchset may be nil.

func (*StateStore) JobByIDTxn

func (s *StateStore) JobByIDTxn(ws memdb.WatchSet, namespace, id string, txn Txn) (*structs.Job, error)

JobByIDTxn is used to lookup a job by its ID, like JobByID. JobByID returns the job version accessible through in the transaction

func (*StateStore) JobSummaries

func (s *StateStore) JobSummaries(ws memdb.WatchSet) (memdb.ResultIterator, error)

JobSummaries walks the entire job summary table and returns all the job summary objects

func (*StateStore) JobSummaryByID

func (s *StateStore) JobSummaryByID(ws memdb.WatchSet, namespace, jobID string) (*structs.JobSummary, error)

JobSummaryByID returns a job summary object which matches a specific id.

func (*StateStore) JobSummaryByPrefix

func (s *StateStore) JobSummaryByPrefix(ws memdb.WatchSet, namespace, id string) (memdb.ResultIterator, error)

JobSummaryByPrefix is used to look up Job Summary by id prefix

func (*StateStore) JobVersions

func (s *StateStore) JobVersions(ws memdb.WatchSet) (memdb.ResultIterator, error)

func (*StateStore) JobVersionsByID

func (s *StateStore) JobVersionsByID(ws memdb.WatchSet, namespace, id string) ([]*structs.Job, error)

JobVersionsByID returns all the tracked versions of a job.

func (*StateStore) Jobs

func (s *StateStore) Jobs(ws memdb.WatchSet) (memdb.ResultIterator, error)

Jobs returns an iterator over all the jobs

func (*StateStore) JobsByGC

func (s *StateStore) JobsByGC(ws memdb.WatchSet, gc bool) (memdb.ResultIterator, error)

JobsByGC returns an iterator over all jobs eligible or ineligible for garbage collection.

func (*StateStore) JobsByIDPrefix

func (s *StateStore) JobsByIDPrefix(ws memdb.WatchSet, namespace, id string) (memdb.ResultIterator, error)

JobsByIDPrefix is used to lookup a job by prefix. If querying all namespaces the prefix will not be filtered by an index.

func (*StateStore) JobsByNamespace

func (s *StateStore) JobsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error)

JobsByNamespace returns an iterator over all the jobs for the given namespace

func (*StateStore) JobsByPeriodic

func (s *StateStore) JobsByPeriodic(ws memdb.WatchSet, periodic bool) (memdb.ResultIterator, error)

JobsByPeriodic returns an iterator over all the periodic or non-periodic jobs.

func (*StateStore) JobsByScheduler

func (s *StateStore) JobsByScheduler(ws memdb.WatchSet, schedulerType string) (memdb.ResultIterator, error)

JobsByScheduler returns an iterator over all the jobs with the specific scheduler type.

func (*StateStore) LatestDeploymentByJobID

func (s *StateStore) LatestDeploymentByJobID(ws memdb.WatchSet, namespace, jobID string) (*structs.Deployment, error)

LatestDeploymentByJobID returns the latest deployment for the given job. The latest is determined strictly by CreateIndex.

func (*StateStore) LatestIndex

func (s *StateStore) LatestIndex() (uint64, error)

LatestIndex returns the greatest index value for all indexes.

func (*StateStore) NamespaceByName

func (s *StateStore) NamespaceByName(ws memdb.WatchSet, name string) (*structs.Namespace, error)

NamespaceByName is used to lookup a namespace by name

func (*StateStore) NamespaceNames

func (s *StateStore) NamespaceNames() ([]string, error)

func (*StateStore) Namespaces

func (s *StateStore) Namespaces(ws memdb.WatchSet) (memdb.ResultIterator, error)

Namespaces returns an iterator over all the namespaces

func (*StateStore) NamespacesByNamePrefix

func (s *StateStore) NamespacesByNamePrefix(ws memdb.WatchSet, namePrefix string) (memdb.ResultIterator, error)

NamespacesByNamePrefix is used to lookup namespaces by prefix

func (*StateStore) NewWatchSet

func (s *StateStore) NewWatchSet() memdb.WatchSet

NewWatchSet returns a new memdb.WatchSet that adds the state stores abandonCh as a watcher. This is important in that it will notify when this specific state store is no longer valid, usually due to a new snapshot being loaded

func (*StateStore) NodeByID

func (s *StateStore) NodeByID(ws memdb.WatchSet, nodeID string) (*structs.Node, error)

NodeByID is used to lookup a node by ID

func (*StateStore) NodeBySecretID

func (s *StateStore) NodeBySecretID(ws memdb.WatchSet, secretID string) (*structs.Node, error)

NodeBySecretID is used to lookup a node by SecretID

func (*StateStore) Nodes

func (s *StateStore) Nodes(ws memdb.WatchSet) (memdb.ResultIterator, error)

Nodes returns an iterator over all the nodes

func (*StateStore) NodesByIDPrefix

func (s *StateStore) NodesByIDPrefix(ws memdb.WatchSet, nodeID string) (memdb.ResultIterator, error)

NodesByIDPrefix is used to lookup nodes by prefix

func (*StateStore) OneTimeTokenBySecret

func (s *StateStore) OneTimeTokenBySecret(ws memdb.WatchSet, secret string) (*structs.OneTimeToken, error)

OneTimeTokenBySecret is used to lookup a token by secret

func (*StateStore) PeriodicLaunchByID

func (s *StateStore) PeriodicLaunchByID(ws memdb.WatchSet, namespace, id string) (*structs.PeriodicLaunch, error)

PeriodicLaunchByID is used to lookup a periodic launch by the periodic job ID.

func (*StateStore) PeriodicLaunches

func (s *StateStore) PeriodicLaunches(ws memdb.WatchSet) (memdb.ResultIterator, error)

PeriodicLaunches returns an iterator over all the periodic launches

func (*StateStore) ReconcileJobSummaries

func (s *StateStore) ReconcileJobSummaries(index uint64) error

ReconcileJobSummaries re-creates summaries for all jobs present in the state store

func (*StateStore) Restore

func (s *StateStore) Restore() (*StateRestore, error)

Restore is used to optimize the efficiency of rebuilding state by minimizing the number of transactions and checking overhead.

func (*StateStore) RootKeyMetaByID

func (s *StateStore) RootKeyMetaByID(ws memdb.WatchSet, id string) (*structs.RootKeyMeta, error)

RootKeyMetaByID returns a specific root key meta

func (*StateStore) RootKeyMetas

func (s *StateStore) RootKeyMetas(ws memdb.WatchSet) (memdb.ResultIterator, error)

RootKeyMetas returns an iterator over all root key metadata

func (*StateStore) SITokenAccessor

func (s *StateStore) SITokenAccessor(ws memdb.WatchSet, accessorID string) (*structs.SITokenAccessor, error)

SITokenAccessor returns the given Service Identity token accessor.

func (*StateStore) SITokenAccessors

func (s *StateStore) SITokenAccessors(ws memdb.WatchSet) (memdb.ResultIterator, error)

SITokenAccessors returns an iterator of Service Identity token accessors.

func (*StateStore) SITokenAccessorsByAlloc

func (s *StateStore) SITokenAccessorsByAlloc(ws memdb.WatchSet, allocID string) ([]*structs.SITokenAccessor, error)

SITokenAccessorsByAlloc returns all the Service Identity token accessors by alloc ID.

func (*StateStore) SITokenAccessorsByNode

func (s *StateStore) SITokenAccessorsByNode(ws memdb.WatchSet, nodeID string) ([]*structs.SITokenAccessor, error)

SITokenAccessorsByNode returns all the Service Identity token accessors by node ID.

func (*StateStore) ScalingEvents

func (s *StateStore) ScalingEvents(ws memdb.WatchSet) (memdb.ResultIterator, error)

ScalingEvents returns an iterator over all the job scaling events

func (*StateStore) ScalingEventsByJob

func (s *StateStore) ScalingEventsByJob(ws memdb.WatchSet, namespace, jobID string) (map[string][]*structs.ScalingEvent, uint64, error)

func (*StateStore) ScalingPolicies

func (s *StateStore) ScalingPolicies(ws memdb.WatchSet) (memdb.ResultIterator, error)

ScalingPolicies returns an iterator over all the scaling policies

func (*StateStore) ScalingPoliciesByIDPrefix

func (s *StateStore) ScalingPoliciesByIDPrefix(ws memdb.WatchSet, namespace string, prefix string) (memdb.ResultIterator, error)

func (*StateStore) ScalingPoliciesByJob

func (s *StateStore) ScalingPoliciesByJob(ws memdb.WatchSet, namespace, jobID, policyType string) (memdb.ResultIterator,
	error)

func (*StateStore) ScalingPoliciesByJobTxn

func (s *StateStore) ScalingPoliciesByJobTxn(ws memdb.WatchSet, namespace, jobID string,
	txn *txn) (memdb.ResultIterator, error)

func (*StateStore) ScalingPoliciesByNamespace

func (s *StateStore) ScalingPoliciesByNamespace(ws memdb.WatchSet, namespace, typ string) (memdb.ResultIterator, error)

func (*StateStore) ScalingPoliciesByTypePrefix

func (s *StateStore) ScalingPoliciesByTypePrefix(ws memdb.WatchSet, t string) (memdb.ResultIterator, error)

ScalingPoliciesByTypePrefix returns an iterator over scaling policies with a certain type prefix.

func (*StateStore) ScalingPolicyByID

func (s *StateStore) ScalingPolicyByID(ws memdb.WatchSet, id string) (*structs.ScalingPolicy, error)

func (*StateStore) ScalingPolicyByTargetAndType

func (s *StateStore) ScalingPolicyByTargetAndType(ws memdb.WatchSet, target map[string]string, typ string) (*structs.ScalingPolicy,
	error)

ScalingPolicyByTargetAndType returns a fully-qualified policy against a target and policy type, or nil if it does not exist. This method does not honor the watchset on the policy type, just the target.

func (*StateStore) SchedulerCASConfig

func (s *StateStore) SchedulerCASConfig(index, cidx uint64, config *structs.SchedulerConfiguration) (bool, error)

SchedulerCASConfig is used to update the scheduler configuration with a given Raft index. If the CAS index specified is not equal to the last observed index for the config, then the call is a noop.

func (*StateStore) SchedulerConfig

func (s *StateStore) SchedulerConfig() (uint64, *structs.SchedulerConfiguration, error)

SchedulerConfig is used to get the current Scheduler configuration.

func (*StateStore) SchedulerSetConfig

func (s *StateStore) SchedulerSetConfig(index uint64, config *structs.SchedulerConfiguration) error

SchedulerSetConfig is used to set the current Scheduler configuration.

func (*StateStore) Snapshot

func (s *StateStore) Snapshot() (*StateSnapshot, error)

Snapshot is used to create a point in time snapshot. Because we use MemDB, we just need to snapshot the state of the underlying database.

func (*StateStore) SnapshotMinIndex

func (s *StateStore) SnapshotMinIndex(ctx context.Context, index uint64) (*StateSnapshot, error)

SnapshotMinIndex is used to create a state snapshot where the index is guaranteed to be greater than or equal to the index parameter.

Some server operations (such as scheduling) exchange objects via RPC concurrent with Raft log application, so they must ensure the state store snapshot they are operating on is at or after the index the objects retrieved via RPC were applied to the Raft log at.

Callers should maintain their own timer metric as the time this method blocks indicates Raft log application latency relative to scheduling.

func (*StateStore) StopEventBroker

func (s *StateStore) StopEventBroker()

StopEventBroker calls the cancel func for the state stores event publisher. It should be called during server shutdown.

func (*StateStore) UpdateAllocDesiredTransitionTxn

func (s *StateStore) UpdateAllocDesiredTransitionTxn(
	txn *txn, index uint64, allocID string,
	transition *structs.DesiredTransition) error

UpdateAllocDesiredTransitionTxn is used to nest an update of an allocations desired transition

func (*StateStore) UpdateAllocsDesiredTransitions

func (s *StateStore) UpdateAllocsDesiredTransitions(msgType structs.MessageType, index uint64, allocs map[string]*structs.DesiredTransition,
	evals []*structs.Evaluation) error

UpdateAllocsDesiredTransitions is used to update a set of allocations desired transitions.

func (*StateStore) UpdateAllocsFromClient

func (s *StateStore) UpdateAllocsFromClient(msgType structs.MessageType, index uint64, allocs []*structs.Allocation) error

UpdateAllocsFromClient is used to update an allocation based on input from a client. While the schedulers are the authority on the allocation for most things, some updates are authoritative from the client. Specifically, the desired state comes from the schedulers, while the actual state comes from clients.

func (*StateStore) UpdateDeploymentAllocHealth

func (s *StateStore) UpdateDeploymentAllocHealth(msgType structs.MessageType, index uint64, req *structs.ApplyDeploymentAllocHealthRequest) error

UpdateDeploymentAllocHealth is used to update the health of allocations as part of the deployment and potentially make a evaluation

func (*StateStore) UpdateDeploymentPromotion

func (s *StateStore) UpdateDeploymentPromotion(msgType structs.MessageType, index uint64, req *structs.ApplyDeploymentPromoteRequest) error

UpdateDeploymentPromotion is used to promote canaries in a deployment and potentially make a evaluation

func (*StateStore) UpdateDeploymentStatus

func (s *StateStore) UpdateDeploymentStatus(msgType structs.MessageType, index uint64, req *structs.DeploymentStatusUpdateRequest) error

UpdateDeploymentStatus is used to make deployment status updates and potentially make a evaluation

func (*StateStore) UpdateJobStability

func (s *StateStore) UpdateJobStability(index uint64, namespace, jobID string, jobVersion uint64, stable bool) error

UpdateJobStability updates the stability of the given job and version to the desired status.

func (*StateStore) UpdateNodeDrain

func (s *StateStore) UpdateNodeDrain(msgType structs.MessageType, index uint64, nodeID string,
	drain *structs.DrainStrategy, markEligible bool, updatedAt int64,
	event *structs.NodeEvent, drainMeta map[string]string, accessorId string) error

UpdateNodeDrain is used to update the drain of a node

func (*StateStore) UpdateNodeEligibility

func (s *StateStore) UpdateNodeEligibility(msgType structs.MessageType, index uint64, nodeID string, eligibility string, updatedAt int64, event *structs.NodeEvent) error

UpdateNodeEligibility is used to update the scheduling eligibility of a node

func (*StateStore) UpdateNodeStatus

func (s *StateStore) UpdateNodeStatus(msgType structs.MessageType, index uint64, nodeID, status string, updatedAt int64, event *structs.NodeEvent) error

UpdateNodeStatus is used to update the status of a node

func (*StateStore) UpsertACLAuthMethods

func (s *StateStore) UpsertACLAuthMethods(index uint64, aclAuthMethods []*structs.ACLAuthMethod) error

UpsertACLAuthMethods is used to insert a number of ACL auth methods into the state store. It uses a single write transaction for efficiency, however, any error means no entries will be committed.

func (*StateStore) UpsertACLBindingRules

func (s *StateStore) UpsertACLBindingRules(
	index uint64, bindingRules []*structs.ACLBindingRule, allowMissingAuthMethod bool) error

UpsertACLBindingRules is used to insert a number of ACL binding rules into the state store. It uses a single write transaction for efficiency, however, any error means no entries will be committed.

func (*StateStore) UpsertACLPolicies

func (s *StateStore) UpsertACLPolicies(msgType structs.MessageType, index uint64, policies []*structs.ACLPolicy) error

UpsertACLPolicies is used to create or update a set of ACL policies

func (*StateStore) UpsertACLRoles

func (s *StateStore) UpsertACLRoles(
	msgType structs.MessageType, index uint64, roles []*structs.ACLRole, allowMissingPolicies bool) error

UpsertACLRoles is used to insert a number of ACL roles into the state store. It uses a single write transaction for efficiency, however, any error means no entries will be committed.

func (*StateStore) UpsertACLTokens

func (s *StateStore) UpsertACLTokens(msgType structs.MessageType, index uint64, tokens []*structs.ACLToken) error

UpsertACLTokens is used to create or update a set of ACL tokens

func (*StateStore) UpsertAllocs

func (s *StateStore) UpsertAllocs(msgType structs.MessageType, index uint64, allocs []*structs.Allocation) error

UpsertAllocs is used to evict a set of allocations and allocate new ones at the same time.

func (*StateStore) UpsertCSIPlugin

func (s *StateStore) UpsertCSIPlugin(index uint64, plug *structs.CSIPlugin) error

UpsertCSIPlugin writes the plugin to the state store. Note: there is currently no raft message for this, as it's intended to support testing use cases.

func (*StateStore) UpsertCSIVolume

func (s *StateStore) UpsertCSIVolume(index uint64, volumes []*structs.CSIVolume) error

UpsertCSIVolume inserts a volume in the state store.

func (*StateStore) UpsertDeployment

func (s *StateStore) UpsertDeployment(index uint64, deployment *structs.Deployment) error

UpsertDeployment is used to insert or update a new deployment.

func (*StateStore) UpsertEvals

func (s *StateStore) UpsertEvals(msgType structs.MessageType, index uint64, evals []*structs.Evaluation) error

UpsertEvals is used to upsert a set of evaluations

func (*StateStore) UpsertEvalsTxn

func (s *StateStore) UpsertEvalsTxn(index uint64, evals []*structs.Evaluation, txn Txn) error

UpsertEvalsTxn is used to upsert a set of evaluations, like UpsertEvals but in a transaction. Useful for when making multiple modifications atomically.

func (*StateStore) UpsertJob

func (s *StateStore) UpsertJob(msgType structs.MessageType, index uint64, job *structs.Job) error

UpsertJob is used to register a job or update a job definition

func (*StateStore) UpsertJobSummary

func (s *StateStore) UpsertJobSummary(index uint64, jobSummary *structs.JobSummary) error

UpsertJobSummary upserts a job summary into the state store.

func (*StateStore) UpsertJobTxn

func (s *StateStore) UpsertJobTxn(index uint64, job *structs.Job, txn Txn) error

UpsertJobTxn is used to register a job or update a job definition, like UpsertJob, but in a transaction. Useful for when making multiple modifications atomically

func (*StateStore) UpsertNamespaces

func (s *StateStore) UpsertNamespaces(index uint64, namespaces []*structs.Namespace) error

UpsertNamespaces is used to register or update a set of namespaces.

func (*StateStore) UpsertNode

func (s *StateStore) UpsertNode(msgType structs.MessageType, index uint64, node *structs.Node) error

UpsertNode is used to register a node or update a node definition This is assumed to be triggered by the client, so we retain the value of drain/eligibility which is set by the scheduler.

func (*StateStore) UpsertNodeEvents

func (s *StateStore) UpsertNodeEvents(msgType structs.MessageType, index uint64, nodeEvents map[string][]*structs.NodeEvent) error

UpsertNodeEvents adds the node events to the nodes, rotating events as necessary.

func (*StateStore) UpsertOneTimeToken

func (s *StateStore) UpsertOneTimeToken(msgType structs.MessageType, index uint64, token *structs.OneTimeToken) error

UpsertOneTimeToken is used to create or update a set of ACL tokens. Validating that we're not upserting an already-expired token is made the responsibility of the caller to facilitate testing.

func (*StateStore) UpsertPeriodicLaunch

func (s *StateStore) UpsertPeriodicLaunch(index uint64, launch *structs.PeriodicLaunch) error

UpsertPeriodicLaunch is used to register a launch or update it.

func (*StateStore) UpsertPlanResults

func (s *StateStore) UpsertPlanResults(msgType structs.MessageType, index uint64, results *structs.ApplyPlanResultsRequest) error

UpsertPlanResults is used to upsert the results of a plan.

func (*StateStore) UpsertRootKeyMeta

func (s *StateStore) UpsertRootKeyMeta(index uint64, rootKeyMeta *structs.RootKeyMeta, rekey bool) error

UpsertRootKeyMeta saves root key meta or updates it in-place.

func (*StateStore) UpsertSITokenAccessors

func (s *StateStore) UpsertSITokenAccessors(index uint64, accessors []*structs.SITokenAccessor) error

UpsertSITokenAccessors is used to register a set of Service Identity token accessors.

func (*StateStore) UpsertScalingEvent

func (s *StateStore) UpsertScalingEvent(index uint64, req *structs.ScalingEventRequest) error

UpsertScalingEvent is used to insert a new scaling event. Only the most recent JobTrackedScalingEvents will be kept.

func (*StateStore) UpsertScalingPolicies

func (s *StateStore) UpsertScalingPolicies(index uint64, scalingPolicies []*structs.ScalingPolicy) error

UpsertScalingPolicies is used to insert a new scaling policy.

func (*StateStore) UpsertScalingPoliciesTxn

func (s *StateStore) UpsertScalingPoliciesTxn(index uint64, scalingPolicies []*structs.ScalingPolicy,
	txn *txn) error

UpsertScalingPoliciesTxn is used to insert a new scaling policy.

func (*StateStore) UpsertServiceRegistrations

func (s *StateStore) UpsertServiceRegistrations(
	msgType structs.MessageType, index uint64, services []*structs.ServiceRegistration) error

UpsertServiceRegistrations is used to insert a number of service registrations into the state store. It uses a single write transaction for efficiency, however, any error means no entries will be committed.

func (*StateStore) UpsertVaultAccessor

func (s *StateStore) UpsertVaultAccessor(index uint64, accessors []*structs.VaultAccessor) error

UpsertVaultAccessor is used to register a set of Vault Accessors.

func (*StateStore) VarDelete

VarDelete is used to delete a single variable in the the state store.

func (*StateStore) VarDeleteCAS

VarDeleteCAS is used to conditionally delete a variable if and only if it has a given modify index. If the CAS index (cidx) specified is not equal to the last observed index for the given variable, then the call is a noop, otherwise a normal delete is invoked.

func (*StateStore) VarGet

func (s *StateStore) VarGet(ws memdb.WatchSet, namespace, path string) (uint64, *structs.VariableEncrypted, error)

VarGet is used to retrieve a key/value pair from the state store.

func (*StateStore) VarSet

VarSet is used to store a variable object.

func (*StateStore) VarSetCAS

VarSetCAS is used to do a check-and-set operation on a variable. The ModifyIndex in the provided entry is used to determine if we should write the entry to the state store or not.

func (*StateStore) Variables

func (s *StateStore) Variables(ws memdb.WatchSet) (memdb.ResultIterator, error)

Variables queries all the variables and is used only for snapshot/restore and key rotation

func (*StateStore) VariablesQuotaByNamespace

func (s *StateStore) VariablesQuotaByNamespace(ws memdb.WatchSet, namespace string) (*structs.VariablesQuota, error)

VariablesQuotaByNamespace queries for quotas for a particular namespace

func (*StateStore) VariablesQuotas

func (s *StateStore) VariablesQuotas(ws memdb.WatchSet) (memdb.ResultIterator, error)

VariablesQuotas queries all the quotas and is used only for snapshot/restore and key rotation

func (*StateStore) VaultAccessor

func (s *StateStore) VaultAccessor(ws memdb.WatchSet, accessor string) (*structs.VaultAccessor, error)

VaultAccessor returns the given Vault accessor

func (*StateStore) VaultAccessors

func (s *StateStore) VaultAccessors(ws memdb.WatchSet) (memdb.ResultIterator, error)

VaultAccessors returns an iterator of Vault accessors.

func (*StateStore) VaultAccessorsByAlloc

func (s *StateStore) VaultAccessorsByAlloc(ws memdb.WatchSet, allocID string) ([]*structs.VaultAccessor, error)

VaultAccessorsByAlloc returns all the Vault accessors by alloc id

func (*StateStore) VaultAccessorsByNode

func (s *StateStore) VaultAccessorsByNode(ws memdb.WatchSet, nodeID string) ([]*structs.VaultAccessor, error)

VaultAccessorsByNode returns all the Vault accessors by node id

func (*StateStore) WithWriteTransaction

func (s *StateStore) WithWriteTransaction(msgType structs.MessageType, index uint64, fn func(Txn) error) error

WithWriteTransaction executes the passed function within a write transaction, and returns its result. If the invocation returns no error, the transaction is committed; otherwise, it's aborted.

type StateStoreConfig

type StateStoreConfig struct {
	// Logger is used to output the state store's logs
	Logger hclog.Logger

	// Region is the region of the server embedding the state store.
	Region string

	// EnablePublisher is used to enable or disable the event publisher
	EnablePublisher bool

	// EventBufferSize configures the amount of events to hold in memory
	EventBufferSize int64
}

StateStoreConfig is used to configure a new state store

func TestStateStorePublisher

func TestStateStorePublisher(t testing.TB) *StateStoreConfig

type Txn

type Txn = *txn

Txn is a transaction against a state store. This can be a read or write transaction.

type WriteTxn

type WriteTxn interface {
	ReadTxn
	Defer(func())
	Delete(table string, obj interface{}) error
	DeleteAll(table, index string, args ...interface{}) (int, error)
	DeletePrefix(table string, index string, prefix string) (bool, error)
	Insert(table string, obj interface{}) error
}

WriteTxn is implemented by memdb.Txn to perform write operations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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