Documentation ¶
Index ¶
- Constants
- Variables
- func NewBatchFuture() *batchFuture
- func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
- func NewCoreScheduler(srv *Server, snap *state.StateSnapshot) scheduler.Scheduler
- func NewFSM(evalBroker *EvalBroker, periodic *PeriodicDispatch, blocked *BlockedEvals, ...) (*nomadFSM, error)
- func NewPeriodicHeap() *periodicHeap
- func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec
- func NewVaultClient(c *config.VaultConfig, logger *log.Logger, purgeFn PurgeVaultAccessorFn) (*vaultClient, error)
- func PoliciesFrom(s *vapi.Secret) ([]string, error)
- func RuntimeStats() map[string]string
- type Alloc
- type BlockedEvals
- func (b *BlockedEvals) Block(eval *structs.Evaluation)
- func (b *BlockedEvals) EmitStats(period time.Duration, stopCh chan struct{})
- func (b *BlockedEvals) Enabled() bool
- func (b *BlockedEvals) Flush()
- func (b *BlockedEvals) GetDuplicates(timeout time.Duration) []*structs.Evaluation
- func (b *BlockedEvals) Reblock(eval *structs.Evaluation, token string)
- func (b *BlockedEvals) SetEnabled(enabled bool)
- func (b *BlockedEvals) Stats() *BlockedStats
- func (b *BlockedEvals) Unblock(computedClass string, index uint64)
- func (b *BlockedEvals) UnblockFailed()
- func (b *BlockedEvals) Untrack(jobID string)
- type BlockedStats
- type BrokerStats
- type Config
- type Conn
- type ConnPool
- type CoreScheduler
- type Eval
- func (e *Eval) Ack(args *structs.EvalAckRequest, reply *structs.GenericResponse) error
- func (e *Eval) Allocations(args *structs.EvalSpecificRequest, reply *structs.EvalAllocationsResponse) error
- func (e *Eval) Create(args *structs.EvalUpdateRequest, reply *structs.GenericResponse) error
- func (e *Eval) Dequeue(args *structs.EvalDequeueRequest, reply *structs.EvalDequeueResponse) error
- func (e *Eval) GetEval(args *structs.EvalSpecificRequest, reply *structs.SingleEvalResponse) error
- func (e *Eval) List(args *structs.EvalListRequest, reply *structs.EvalListResponse) error
- func (e *Eval) Nack(args *structs.EvalAckRequest, reply *structs.GenericResponse) error
- func (e *Eval) Reap(args *structs.EvalDeleteRequest, reply *structs.GenericResponse) error
- func (e *Eval) Reblock(args *structs.EvalUpdateRequest, reply *structs.GenericResponse) error
- func (e *Eval) Update(args *structs.EvalUpdateRequest, reply *structs.GenericResponse) error
- type EvalBroker
- func (b *EvalBroker) Ack(evalID, token string) error
- func (b *EvalBroker) Dequeue(schedulers []string, timeout time.Duration) (*structs.Evaluation, string, error)
- func (b *EvalBroker) EmitStats(period time.Duration, stopCh chan struct{})
- func (b *EvalBroker) Enabled() bool
- func (b *EvalBroker) Enqueue(eval *structs.Evaluation)
- func (b *EvalBroker) EnqueueAll(evals map[*structs.Evaluation]string)
- func (b *EvalBroker) Flush()
- func (b *EvalBroker) Nack(evalID, token string) error
- func (b *EvalBroker) Outstanding(evalID string) (string, bool)
- func (b *EvalBroker) OutstandingReset(evalID, token string) error
- func (b *EvalBroker) PauseNackTimeout(evalID, token string) error
- func (b *EvalBroker) ResumeNackTimeout(evalID, token string) error
- func (b *EvalBroker) SetEnabled(enabled bool)
- func (b *EvalBroker) Stats() *BrokerStats
- type EvaluatePool
- type Job
- func (j *Job) Allocations(args *structs.JobSpecificRequest, reply *structs.JobAllocationsResponse) error
- func (j *Job) Deregister(args *structs.JobDeregisterRequest, reply *structs.JobDeregisterResponse) error
- func (j *Job) Dispatch(args *structs.JobDispatchRequest, reply *structs.JobDispatchResponse) error
- func (j *Job) Evaluate(args *structs.JobEvaluateRequest, reply *structs.JobRegisterResponse) error
- func (j *Job) Evaluations(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error
- func (j *Job) GetJob(args *structs.JobSpecificRequest, reply *structs.SingleJobResponse) error
- func (j *Job) List(args *structs.JobListRequest, reply *structs.JobListResponse) error
- func (j *Job) Plan(args *structs.JobPlanRequest, reply *structs.JobPlanResponse) error
- func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegisterResponse) error
- func (j *Job) Summary(args *structs.JobSummaryRequest, reply *structs.JobSummaryResponse) error
- func (j *Job) Validate(args *structs.JobValidateRequest, reply *structs.JobValidateResponse) error
- type JobEvalDispatcher
- type Node
- func (n *Node) Deregister(args *structs.NodeDeregisterRequest, reply *structs.NodeUpdateResponse) error
- func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest, reply *structs.DeriveVaultTokenResponse) error
- func (n *Node) Evaluate(args *structs.NodeEvaluateRequest, reply *structs.NodeUpdateResponse) error
- func (n *Node) GetAllocs(args *structs.NodeSpecificRequest, reply *structs.NodeAllocsResponse) error
- func (n *Node) GetClientAllocs(args *structs.NodeSpecificRequest, reply *structs.NodeClientAllocsResponse) error
- func (n *Node) GetNode(args *structs.NodeSpecificRequest, reply *structs.SingleNodeResponse) error
- func (n *Node) List(args *structs.NodeListRequest, reply *structs.NodeListResponse) error
- func (n *Node) Register(args *structs.NodeRegisterRequest, reply *structs.NodeUpdateResponse) error
- func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.GenericResponse) error
- func (n *Node) UpdateDrain(args *structs.NodeUpdateDrainRequest, reply *structs.NodeDrainUpdateResponse) error
- func (n *Node) UpdateStatus(args *structs.NodeUpdateStatusRequest, reply *structs.NodeUpdateResponse) error
- type Operator
- type PendingEvaluations
- type PendingPlans
- type Periodic
- type PeriodicDispatch
- func (p *PeriodicDispatch) Add(job *structs.Job) error
- func (p *PeriodicDispatch) Flush()
- func (p *PeriodicDispatch) ForceRun(jobID string) (*structs.Evaluation, error)
- func (p *PeriodicDispatch) LaunchTime(jobID string) (time.Time, error)
- func (p *PeriodicDispatch) Remove(jobID string) error
- func (p *PeriodicDispatch) SetEnabled(enabled bool)
- func (p *PeriodicDispatch) Start()
- func (p *PeriodicDispatch) Tracked() []*structs.Job
- type Plan
- type PlanFuture
- type PlanQueue
- func (q *PlanQueue) Dequeue(timeout time.Duration) (*pendingPlan, error)
- func (q *PlanQueue) EmitStats(period time.Duration, stopCh chan struct{})
- func (q *PlanQueue) Enabled() bool
- func (q *PlanQueue) Enqueue(plan *structs.Plan) (PlanFuture, error)
- func (q *PlanQueue) Flush()
- func (q *PlanQueue) SetEnabled(enabled bool)
- func (q *PlanQueue) Stats() *QueueStats
- type PurgeVaultAccessorFn
- type QueueStats
- type RPCType
- type RaftLayer
- type Region
- type SchedulerStats
- type Server
- func (s *Server) Datacenter() string
- func (s *Server) DispatchJob(job *structs.Job) (*structs.Evaluation, error)
- func (s *Server) Encrypted() bool
- func (s *Server) GetConfig() *Config
- func (s *Server) IsLeader() bool
- func (s *Server) IsShutdown() bool
- func (s *Server) Join(addrs []string) (int, error)
- func (s *Server) KeyManager() *serf.KeyManager
- func (s *Server) Leave() error
- func (c *Server) LocalMember() serf.Member
- func (s *Server) Members() []serf.Member
- func (s *Server) RPC(method string, args interface{}, reply interface{}) error
- func (s *Server) Region() string
- func (s *Server) Regions() []string
- func (s *Server) Reload(config *Config) error
- func (s *Server) RemoveFailedNode(node string) error
- func (s *Server) RunningChildren(job *structs.Job) (bool, error)
- func (s *Server) Shutdown() error
- func (s *Server) State() *state.StateStore
- func (s *Server) Stats() map[string]map[string]string
- type SnapshotType
- type Status
- func (s *Status) Leader(args *structs.GenericRequest, reply *string) error
- func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error
- func (s *Status) Peers(args *structs.GenericRequest, reply *[]string) error
- func (s *Status) Ping(args struct{}, reply *struct{}) error
- func (s *Status) Version(args *structs.GenericRequest, reply *structs.VersionResponse) error
- type StreamClient
- type System
- type TestVaultClient
- func (v *TestVaultClient) CreateToken(ctx context.Context, a *structs.Allocation, task string) (*vapi.Secret, error)
- func (v *TestVaultClient) EmitStats(period time.Duration, stopCh chan struct{})
- func (v *TestVaultClient) LookupToken(ctx context.Context, token string) (*vapi.Secret, error)
- func (v *TestVaultClient) RevokeTokens(ctx context.Context, accessors []*structs.VaultAccessor, committed bool) error
- func (v *TestVaultClient) Running() bool
- func (v *TestVaultClient) SetActive(enabled bool)
- func (v *TestVaultClient) SetConfig(config *config.VaultConfig) error
- func (v *TestVaultClient) SetCreateTokenError(allocID, task string, err error)
- func (v *TestVaultClient) SetCreateTokenSecret(allocID, task string, secret *vapi.Secret)
- func (v *TestVaultClient) SetLookupTokenAllowedPolicies(token string, policies []string)
- func (v *TestVaultClient) SetLookupTokenError(token string, err error)
- func (v *TestVaultClient) SetLookupTokenSecret(token string, secret *vapi.Secret)
- func (v *TestVaultClient) Stats() *VaultStats
- func (v *TestVaultClient) Stop()
- type TimeTable
- type TimeTableEntry
- type VaultClient
- type VaultStats
- type Worker
- func (w *Worker) CreateEval(eval *structs.Evaluation) error
- func (w *Worker) ReblockEval(eval *structs.Evaluation) error
- func (w *Worker) SetPause(p bool)
- func (w *Worker) SubmitPlan(plan *structs.Plan) (*structs.PlanResult, scheduler.State, error)
- func (w *Worker) UpdateEval(eval *structs.Evaluation) error
Constants ¶
const ( DefaultRegion = "global" DefaultDC = "dc1" DefaultSerfPort = 4648 )
const ( ProtocolVersionMin uint8 = 1 ProtocolVersionMax = 1 )
These are the protocol versions that Nomad can understand
const ( // RegisterEnforceIndexErrPrefix is the prefix to use in errors caused by // enforcing the job modify index during registers. RegisterEnforceIndexErrPrefix = "Enforcing job modify index" // DispatchPayloadSizeLimit is the maximum size of the uncompressed input // data payload. DispatchPayloadSizeLimit = 16 * 1024 )
const ( // DefaultDequeueTimeout is used if no dequeue timeout is provided DefaultDequeueTimeout = time.Second )
const ( // StatusReap is used to update the status of a node if we // are handling a EventMemberReap StatusReap = serf.MemberStatus(-1) )
Variables ¶
var ( // ErrNotOutstanding is returned if an evaluation is not outstanding ErrNotOutstanding = errors.New("evaluation is not outstanding") // ErrTokenMismatch is the outstanding eval has a different token ErrTokenMismatch = errors.New("evaluation token does not match") // ErrNackTimeoutReached is returned if an expired evaluation is reset ErrNackTimeoutReached = errors.New("evaluation nack timeout reached") )
var (
DefaultRPCAddr = &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 4647}
)
Functions ¶
func NewBatchFuture ¶ added in v0.3.0
func NewBatchFuture() *batchFuture
NewBatchFuture creates a new batch future
func NewClientCodec ¶ added in v0.2.0
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
NewClientCodec returns a new rpc.ClientCodec to be used to make RPC calls to the Nomad Server.
func NewCoreScheduler ¶
func NewCoreScheduler(srv *Server, snap *state.StateSnapshot) scheduler.Scheduler
NewCoreScheduler is used to return a new system scheduler instance
func NewFSM ¶
func NewFSM(evalBroker *EvalBroker, periodic *PeriodicDispatch, blocked *BlockedEvals, logOutput io.Writer) (*nomadFSM, error)
NewFSMPath is used to construct a new FSM with a blank state
func NewPeriodicHeap ¶ added in v0.3.0
func NewPeriodicHeap() *periodicHeap
func NewServerCodec ¶ added in v0.2.0
func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec
NewServerCodec returns a new rpc.ServerCodec to be used by the Nomad Server to handle rpcs.
func NewVaultClient ¶ added in v0.5.0
func NewVaultClient(c *config.VaultConfig, logger *log.Logger, purgeFn PurgeVaultAccessorFn) (*vaultClient, error)
NewVaultClient returns a Vault client from the given config. If the client couldn't be made an error is returned.
func PoliciesFrom ¶ added in v0.5.0
PoliciesFrom parses the set of policies returned by a token lookup.
func RuntimeStats ¶
RuntimeStats is used to return various runtime information
Types ¶
type Alloc ¶
type Alloc struct {
// contains filtered or unexported fields
}
Alloc endpoint is used for manipulating allocations
func (*Alloc) GetAlloc ¶
func (a *Alloc) GetAlloc(args *structs.AllocSpecificRequest, reply *structs.SingleAllocResponse) error
GetAlloc is used to lookup a particular allocation
func (*Alloc) GetAllocs ¶ added in v0.3.0
func (a *Alloc) GetAllocs(args *structs.AllocsGetRequest, reply *structs.AllocsGetResponse) error
GetAllocs is used to lookup a set of allocations
func (*Alloc) List ¶
func (a *Alloc) List(args *structs.AllocListRequest, reply *structs.AllocListResponse) error
List is used to list the allocations in the system
type BlockedEvals ¶ added in v0.3.0
type BlockedEvals struct {
// contains filtered or unexported fields
}
BlockedEvals is used to track evaluations that shouldn't be queued until a certain class of nodes becomes available. An evaluation is put into the blocked state when it is run through the scheduler and produced failed allocations. It is unblocked when the capacity of a node that could run the failed allocation becomes available.
func NewBlockedEvals ¶ added in v0.3.0
func NewBlockedEvals(evalBroker *EvalBroker) *BlockedEvals
NewBlockedEvals creates a new blocked eval tracker that will enqueue unblocked evals into the passed broker.
func (*BlockedEvals) Block ¶ added in v0.3.0
func (b *BlockedEvals) Block(eval *structs.Evaluation)
Block tracks the passed evaluation and enqueues it into the eval broker when a suitable node calls unblock.
func (*BlockedEvals) EmitStats ¶ added in v0.3.0
func (b *BlockedEvals) EmitStats(period time.Duration, stopCh chan struct{})
EmitStats is used to export metrics about the blocked eval tracker while enabled
func (*BlockedEvals) Enabled ¶ added in v0.3.0
func (b *BlockedEvals) Enabled() bool
Enabled is used to check if the broker is enabled.
func (*BlockedEvals) Flush ¶ added in v0.3.0
func (b *BlockedEvals) Flush()
Flush is used to clear the state of blocked evaluations.
func (*BlockedEvals) GetDuplicates ¶ added in v0.3.0
func (b *BlockedEvals) GetDuplicates(timeout time.Duration) []*structs.Evaluation
GetDuplicates returns all the duplicate evaluations and blocks until the passed timeout.
func (*BlockedEvals) Reblock ¶ added in v0.4.0
func (b *BlockedEvals) Reblock(eval *structs.Evaluation, token string)
Reblock tracks the passed evaluation and enqueues it into the eval broker when a suitable node calls unblock. Reblock should be used over Block when the blocking is occurring by an outstanding evaluation. The token is the evaluation's token.
func (*BlockedEvals) SetEnabled ¶ added in v0.3.0
func (b *BlockedEvals) SetEnabled(enabled bool)
SetEnabled is used to control if the blocked eval tracker is enabled. The tracker should only be enabled on the active leader.
func (*BlockedEvals) Stats ¶ added in v0.3.0
func (b *BlockedEvals) Stats() *BlockedStats
Stats is used to query the state of the blocked eval tracker.
func (*BlockedEvals) Unblock ¶ added in v0.3.0
func (b *BlockedEvals) Unblock(computedClass string, index uint64)
Unblock causes any evaluation that could potentially make progress on a capacity change on the passed computed node class to be enqueued into the eval broker.
func (*BlockedEvals) UnblockFailed ¶ added in v0.4.0
func (b *BlockedEvals) UnblockFailed()
UnblockFailed unblocks all blocked evaluation that were due to scheduler failure.
func (*BlockedEvals) Untrack ¶ added in v0.5.3
func (b *BlockedEvals) Untrack(jobID string)
Untrack causes any blocked evaluation for the passed job to be no longer tracked. Untrack is called when there is a successful evaluation for the job and a blocked evaluation is no longer needed.
type BlockedStats ¶ added in v0.3.0
type BlockedStats struct { // TotalEscaped is the total number of blocked evaluations that have escaped // computed node classes. TotalEscaped int // TotalBlocked is the total number of blocked evaluations. TotalBlocked int }
BlockedStats returns all the stats about the blocked eval tracker.
type BrokerStats ¶
type BrokerStats struct { TotalReady int TotalUnacked int TotalBlocked int TotalWaiting int ByScheduler map[string]*SchedulerStats }
BrokerStats returns all the stats about the broker
type Config ¶
type Config struct { // Bootstrap mode is used to bring up the first Nomad server. It is // required so that it can elect a leader without any other nodes // being present Bootstrap bool // BootstrapExpect mode is used to automatically bring up a // collection of Nomad servers. This can be used to automatically // bring up a collection of nodes. All operations on BootstrapExpect // must be handled via `atomic.*Int32()` calls. BootstrapExpect int32 // DataDir is the directory to store our state in DataDir string // DevMode is used for development purposes only and limits the // use of persistence or state. DevMode bool // DevDisableBootstrap is used to disable bootstrap mode while // in DevMode. This is largely used for testing. DevDisableBootstrap bool // LogOutput is the location to write logs to. If this is not set, // logs will go to stderr. LogOutput io.Writer // ProtocolVersion is the protocol version to speak. This must be between // ProtocolVersionMin and ProtocolVersionMax. ProtocolVersion uint8 // RPCAddr is the RPC address used by Nomad. This should be reachable // by the other servers and clients RPCAddr *net.TCPAddr // RPCAdvertise is the address that is advertised to other nodes for // the RPC endpoint. This can differ from the RPC address, if for example // the RPCAddr is unspecified "0.0.0.0:4646", but this address must be // reachable RPCAdvertise *net.TCPAddr // RaftConfig is the configuration used for Raft in the local DC RaftConfig *raft.Config // RaftTimeout is applied to any network traffic for raft. Defaults to 10s. RaftTimeout time.Duration // RequireTLS ensures that all RPC traffic is protected with TLS RequireTLS bool // SerfConfig is the configuration for the serf cluster SerfConfig *serf.Config // Node name is the name we use to advertise. Defaults to hostname. NodeName string // Region is the region this Nomad server belongs to. Region string // Datacenter is the datacenter this Nomad server belongs to. Datacenter string // Build is a string that is gossiped around, and can be used to help // operators track which versions are actively deployed Build string // NumSchedulers is the number of scheduler thread that are run. // This can be as many as one per core, or zero to disable this server // from doing any scheduling work. NumSchedulers int // EnabledSchedulers controls the set of sub-schedulers that are // enabled for this server to handle. This will restrict the evaluations // that the workers dequeue for processing. EnabledSchedulers []string // ReconcileInterval controls how often we reconcile the strongly // consistent store with the Serf info. This is used to handle nodes // that are force removed, as well as intermittent unavailability during // leader election. ReconcileInterval time.Duration // EvalGCInterval is how often we dispatch a job to GC evaluations EvalGCInterval time.Duration // EvalGCThreshold is how "old" an evaluation must be to be eligible // for GC. This gives users some time to debug a failed evaluation. EvalGCThreshold time.Duration // JobGCInterval is how often we dispatch a job to GC jobs that are // available for garbage collection. JobGCInterval time.Duration // JobGCThreshold is how old a job must be before it eligible for GC. This gives // the user time to inspect the job. JobGCThreshold time.Duration // NodeGCInterval is how often we dispatch a job to GC failed nodes. NodeGCInterval time.Duration // NodeGCThreshold is how "old" a nodemust be to be eligible // for GC. This gives users some time to view and debug a failed nodes. NodeGCThreshold time.Duration // EvalNackTimeout controls how long we allow a sub-scheduler to // work on an evaluation before we consider it failed and Nack it. // This allows that evaluation to be handed to another sub-scheduler // to work on. Defaults to 60 seconds. This should be long enough that // no evaluation hits it unless the sub-scheduler has failed. EvalNackTimeout time.Duration // EvalDeliveryLimit is the limit of attempts we make to deliver and // process an evaluation. This is used so that an eval that will never // complete eventually fails out of the system. EvalDeliveryLimit int // MinHeartbeatTTL is the minimum time between heartbeats. // This is used as a floor to prevent excessive updates. MinHeartbeatTTL time.Duration // MaxHeartbeatsPerSecond is the maximum target rate of heartbeats // being processed per second. This allows the TTL to be increased // to meet the target rate. MaxHeartbeatsPerSecond float64 // HeartbeatGrace is the additional time given as a grace period // beyond the TTL to account for network and processing delays // as well as clock skew. HeartbeatGrace time.Duration // FailoverHeartbeatTTL is the TTL applied to heartbeats after // a new leader is elected, since we no longer know the status // of all the heartbeats. FailoverHeartbeatTTL time.Duration // ConsulConfig is this Agent's Consul configuration ConsulConfig *config.ConsulConfig // VaultConfig is this Agent's Vault configuration VaultConfig *config.VaultConfig // RPCHoldTimeout is how long an RPC can be "held" before it is errored. // This is used to paper over a loss of leadership by instead holding RPCs, // so that the caller experiences a slow response rather than an error. // This period is meant to be long enough for a leader election to take // place, and a small jitter is applied to avoid a thundering herd. RPCHoldTimeout time.Duration // TLSConfig holds various TLS related configurations TLSConfig *config.TLSConfig }
Config is used to parameterize the server
func (*Config) CheckVersion ¶
CheckVersion is used to check if the ProtocolVersion is valid
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a pooled connection to a Nomad server
type ConnPool ¶
ConnPool is used to maintain a connection pool to other Nomad servers. This is used to reduce the latency of RPC requests between servers. It is only used to pool connections in the rpcNomad mode. Raft connections are pooled separately.
func NewPool ¶
func NewPool(logOutput io.Writer, maxTime time.Duration, maxStreams int, tlsWrap tlsutil.RegionWrapper) *ConnPool
NewPool is used to make a new connection pool Maintain at most one connection per host, for up to maxTime. Set maxTime to 0 to disable reaping. maxStreams is used to control the number of idle streams allowed. If TLS settings are provided outgoing connections use TLS.
func (*ConnPool) PingNomadServer ¶ added in v0.4.0
PingNomadServer sends a Status.Ping message to the specified server and returns true if healthy, false if an error occurred
type CoreScheduler ¶
type CoreScheduler struct {
// contains filtered or unexported fields
}
CoreScheduler is a special "scheduler" that is registered as "_core". It is used to run various administrative work across the cluster.
func (*CoreScheduler) Process ¶
func (c *CoreScheduler) Process(eval *structs.Evaluation) error
Process is used to implement the scheduler.Scheduler interface
type Eval ¶
type Eval struct {
// contains filtered or unexported fields
}
Eval endpoint is used for eval interactions
func (*Eval) Ack ¶
func (e *Eval) Ack(args *structs.EvalAckRequest, reply *structs.GenericResponse) error
Ack is used to acknowledge completion of a dequeued evaluation
func (*Eval) Allocations ¶
func (e *Eval) Allocations(args *structs.EvalSpecificRequest, reply *structs.EvalAllocationsResponse) error
Allocations is used to list the allocations for an evaluation
func (*Eval) Create ¶
func (e *Eval) Create(args *structs.EvalUpdateRequest, reply *structs.GenericResponse) error
Create is used to make a new evaluation
func (*Eval) Dequeue ¶
func (e *Eval) Dequeue(args *structs.EvalDequeueRequest, reply *structs.EvalDequeueResponse) error
Dequeue is used to dequeue a pending evaluation
func (*Eval) GetEval ¶
func (e *Eval) GetEval(args *structs.EvalSpecificRequest, reply *structs.SingleEvalResponse) error
GetEval is used to request information about a specific evaluation
func (*Eval) List ¶
func (e *Eval) List(args *structs.EvalListRequest, reply *structs.EvalListResponse) error
List is used to get a list of the evaluations in the system
func (*Eval) Nack ¶
func (e *Eval) Nack(args *structs.EvalAckRequest, reply *structs.GenericResponse) error
NAck is used to negative acknowledge completion of a dequeued evaluation
func (*Eval) Reap ¶
func (e *Eval) Reap(args *structs.EvalDeleteRequest, reply *structs.GenericResponse) error
Reap is used to cleanup dead evaluations and allocations
func (*Eval) Reblock ¶ added in v0.4.0
func (e *Eval) Reblock(args *structs.EvalUpdateRequest, reply *structs.GenericResponse) error
Reblock is used to reinsert an existing blocked evaluation into the blocked evaluation tracker.
func (*Eval) Update ¶
func (e *Eval) Update(args *structs.EvalUpdateRequest, reply *structs.GenericResponse) error
Update is used to perform an update of an Eval if it is outstanding.
type EvalBroker ¶
type EvalBroker struct {
// contains filtered or unexported fields
}
EvalBroker is used to manage brokering of evaluations. When an evaluation is created, due to a change in a job specification or a node, we put it into the broker. The broker sorts by evaluations by priority and scheduler type. This allows us to dequeue the highest priority work first, while also allowing sub-schedulers to only dequeue work they know how to handle. The broker is designed to be entirely in-memory and is managed by the leader node.
The broker must provide at-least-once delivery semantics. It relies on explicit Ack/Nack messages to handle this. If a delivery is not Ack'd in a sufficient time span, it will be assumed Nack'd.
func NewEvalBroker ¶
func NewEvalBroker(timeout time.Duration, deliveryLimit int) (*EvalBroker, error)
NewEvalBroker creates a new evaluation broker. This is parameterized with the timeout used for messages that are not acknowledged before we assume a Nack and attempt to redeliver as well as the deliveryLimit which prevents a failing eval from being endlessly delivered.
func (*EvalBroker) Ack ¶
func (b *EvalBroker) Ack(evalID, token string) error
Ack is used to positively acknowledge handling an evaluation
func (*EvalBroker) Dequeue ¶
func (b *EvalBroker) Dequeue(schedulers []string, timeout time.Duration) (*structs.Evaluation, string, error)
Dequeue is used to perform a blocking dequeue
func (*EvalBroker) EmitStats ¶
func (b *EvalBroker) EmitStats(period time.Duration, stopCh chan struct{})
EmitStats is used to export metrics about the broker while enabled
func (*EvalBroker) Enabled ¶
func (b *EvalBroker) Enabled() bool
Enabled is used to check if the broker is enabled.
func (*EvalBroker) Enqueue ¶
func (b *EvalBroker) Enqueue(eval *structs.Evaluation)
Enqueue is used to enqueue a new evaluation
func (*EvalBroker) EnqueueAll ¶ added in v0.3.0
func (b *EvalBroker) EnqueueAll(evals map[*structs.Evaluation]string)
EnqueueAll is used to enqueue many evaluations. The map allows evaluations that are being re-enqueued to include their token.
When requeueing an evaluation that potentially may be already enqueued. The evaluation is handled in one of the following ways: * Evaluation not outstanding: Process as a normal Enqueue * Evaluation outstanding: Do not allow the evaluation to be dequeued til:
- Ack received: Unblock the evaluation allowing it to be dequeued
- Nack received: Drop the evaluation as it was created as a result of a scheduler run that was Nack'd
func (*EvalBroker) Flush ¶
func (b *EvalBroker) Flush()
Flush is used to clear the state of the broker
func (*EvalBroker) Nack ¶
func (b *EvalBroker) Nack(evalID, token string) error
Nack is used to negatively acknowledge handling an evaluation
func (*EvalBroker) Outstanding ¶
func (b *EvalBroker) Outstanding(evalID string) (string, bool)
Outstanding checks if an EvalID has been delivered but not acknowledged and returns the associated token for the evaluation.
func (*EvalBroker) OutstandingReset ¶ added in v0.2.0
func (b *EvalBroker) OutstandingReset(evalID, token string) error
OutstandingReset resets the Nack timer for the EvalID if the token matches and the eval is outstanding
func (*EvalBroker) PauseNackTimeout ¶ added in v0.3.1
func (b *EvalBroker) PauseNackTimeout(evalID, token string) error
PauseNackTimeout is used to pause the Nack timeout for an eval that is making progress but is in a potentially unbounded operation such as the plan queue.
func (*EvalBroker) ResumeNackTimeout ¶ added in v0.3.1
func (b *EvalBroker) ResumeNackTimeout(evalID, token string) error
ResumeNackTimeout is used to resume the Nack timeout for an eval that was paused. It should be resumed after leaving an unbounded operation.
func (*EvalBroker) SetEnabled ¶
func (b *EvalBroker) SetEnabled(enabled bool)
SetEnabled is used to control if the broker is enabled. The broker should only be enabled on the active leader.
func (*EvalBroker) Stats ¶
func (b *EvalBroker) Stats() *BrokerStats
Stats is used to query the state of the broker
type EvaluatePool ¶ added in v0.3.0
type EvaluatePool struct {
// contains filtered or unexported fields
}
EvaluatePool is used to have a pool of workers that are evaluating if a plan is valid. It can be used to parallelize the evaluation of a plan.
func NewEvaluatePool ¶ added in v0.3.0
func NewEvaluatePool(workers, bufSize int) *EvaluatePool
NewEvaluatePool returns a pool of the given size.
func (*EvaluatePool) RequestCh ¶ added in v0.3.0
func (p *EvaluatePool) RequestCh() chan<- evaluateRequest
RequestCh is used to push requests
func (*EvaluatePool) ResultCh ¶ added in v0.3.0
func (p *EvaluatePool) ResultCh() <-chan evaluateResult
ResultCh is used to read the results as they are ready
func (*EvaluatePool) SetSize ¶ added in v0.3.0
func (p *EvaluatePool) SetSize(size int)
SetSize is used to resize the worker pool
func (*EvaluatePool) Shutdown ¶ added in v0.3.0
func (p *EvaluatePool) Shutdown()
Shutdown is used to shutdown the pool
func (*EvaluatePool) Size ¶ added in v0.3.0
func (p *EvaluatePool) Size() int
Size returns the current size
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job endpoint is used for job interactions
func (*Job) Allocations ¶
func (j *Job) Allocations(args *structs.JobSpecificRequest, reply *structs.JobAllocationsResponse) error
Allocations is used to list the allocations for a job
func (*Job) Deregister ¶
func (j *Job) Deregister(args *structs.JobDeregisterRequest, reply *structs.JobDeregisterResponse) error
Deregister is used to remove a job the cluster.
func (*Job) Dispatch ¶ added in v0.5.3
func (j *Job) Dispatch(args *structs.JobDispatchRequest, reply *structs.JobDispatchResponse) error
Dispatch a parameterized job.
func (*Job) Evaluate ¶
func (j *Job) Evaluate(args *structs.JobEvaluateRequest, reply *structs.JobRegisterResponse) error
Evaluate is used to force a job for re-evaluation
func (*Job) Evaluations ¶
func (j *Job) Evaluations(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error
Evaluations is used to list the evaluations for a job
func (*Job) GetJob ¶
func (j *Job) GetJob(args *structs.JobSpecificRequest, reply *structs.SingleJobResponse) error
GetJob is used to request information about a specific job
func (*Job) List ¶
func (j *Job) List(args *structs.JobListRequest, reply *structs.JobListResponse) error
List is used to list the jobs registered in the system
func (*Job) Plan ¶ added in v0.4.0
func (j *Job) Plan(args *structs.JobPlanRequest, reply *structs.JobPlanResponse) error
Plan is used to cause a dry-run evaluation of the Job and return the results with a potential diff containing annotations.
func (*Job) Register ¶
func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegisterResponse) error
Register is used to upsert a job for scheduling
func (*Job) Summary ¶ added in v0.4.1
func (j *Job) Summary(args *structs.JobSummaryRequest, reply *structs.JobSummaryResponse) error
Summary retreives the summary of a job
func (*Job) Validate ¶ added in v0.5.5
func (j *Job) Validate(args *structs.JobValidateRequest, reply *structs.JobValidateResponse) error
Validate validates a job
type JobEvalDispatcher ¶ added in v0.3.0
type JobEvalDispatcher interface { // DispatchJob takes a job a new, untracked job and creates an evaluation // for it and returns the eval. DispatchJob(job *structs.Job) (*structs.Evaluation, error) // RunningChildren returns whether the passed job has any running children. RunningChildren(job *structs.Job) (bool, error) }
JobEvalDispatcher is an interface to submit jobs and have evaluations created for them.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node endpoint is used for client interactions
func (*Node) Deregister ¶
func (n *Node) Deregister(args *structs.NodeDeregisterRequest, reply *structs.NodeUpdateResponse) error
Deregister is used to remove a client from the cluster. If a client should just be made unavailable for scheduling, a status update is preferred.
func (*Node) DeriveVaultToken ¶ added in v0.5.0
func (n *Node) DeriveVaultToken(args *structs.DeriveVaultTokenRequest, reply *structs.DeriveVaultTokenResponse) error
DeriveVaultToken is used by the clients to request wrapped Vault tokens for tasks
func (*Node) Evaluate ¶
func (n *Node) Evaluate(args *structs.NodeEvaluateRequest, reply *structs.NodeUpdateResponse) error
Evaluate is used to force a re-evaluation of the node
func (*Node) GetAllocs ¶
func (n *Node) GetAllocs(args *structs.NodeSpecificRequest, reply *structs.NodeAllocsResponse) error
GetAllocs is used to request allocations for a specific node
func (*Node) GetClientAllocs ¶ added in v0.3.0
func (n *Node) GetClientAllocs(args *structs.NodeSpecificRequest, reply *structs.NodeClientAllocsResponse) error
GetClientAllocs is used to request a lightweight list of alloc modify indexes per allocation.
func (*Node) GetNode ¶
func (n *Node) GetNode(args *structs.NodeSpecificRequest, reply *structs.SingleNodeResponse) error
GetNode is used to request information about a specific node
func (*Node) List ¶
func (n *Node) List(args *structs.NodeListRequest, reply *structs.NodeListResponse) error
List is used to list the available nodes
func (*Node) Register ¶
func (n *Node) Register(args *structs.NodeRegisterRequest, reply *structs.NodeUpdateResponse) error
Register is used to upsert a client that is available for scheduling
func (*Node) UpdateAlloc ¶
func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.GenericResponse) error
UpdateAlloc is used to update the client status of an allocation
func (*Node) UpdateDrain ¶
func (n *Node) UpdateDrain(args *structs.NodeUpdateDrainRequest, reply *structs.NodeDrainUpdateResponse) error
UpdateDrain is used to update the drain mode of a client node
func (*Node) UpdateStatus ¶
func (n *Node) UpdateStatus(args *structs.NodeUpdateStatusRequest, reply *structs.NodeUpdateResponse) error
UpdateStatus is used to update the status of a client node
type Operator ¶ added in v0.5.5
type Operator struct {
// contains filtered or unexported fields
}
Operator endpoint is used to perform low-level operator tasks for Nomad.
func (*Operator) RaftGetConfiguration ¶ added in v0.5.5
func (op *Operator) RaftGetConfiguration(args *structs.GenericRequest, reply *structs.RaftConfigurationResponse) error
RaftGetConfiguration is used to retrieve the current Raft configuration.
func (*Operator) RaftRemovePeerByAddress ¶ added in v0.5.5
func (op *Operator) RaftRemovePeerByAddress(args *structs.RaftPeerByAddressRequest, reply *struct{}) error
RaftRemovePeerByAddress is used to kick a stale peer (one that it in the Raft quorum but no longer known to Serf or the catalog) by address in the form of "IP:port". The reply argument is not used, but it required to fulfill the RPC interface.
type PendingEvaluations ¶
type PendingEvaluations []*structs.Evaluation
PendingEvaluations is a list of waiting evaluations. We implement the container/heap interface so that this is a priority queue
func (PendingEvaluations) Len ¶
func (p PendingEvaluations) Len() int
Len is for the sorting interface
func (PendingEvaluations) Less ¶
func (p PendingEvaluations) Less(i, j int) bool
Less is for the sorting interface. We flip the check so that the "min" in the min-heap is the element with the highest priority
func (PendingEvaluations) Peek ¶
func (p PendingEvaluations) Peek() *structs.Evaluation
Peek is used to peek at the next element that would be popped
func (*PendingEvaluations) Pop ¶
func (p *PendingEvaluations) Pop() interface{}
Pop is used to remove an evaluation from the slice
func (*PendingEvaluations) Push ¶
func (p *PendingEvaluations) Push(e interface{})
Push is used to add a new evalution to the slice
func (PendingEvaluations) Swap ¶
func (p PendingEvaluations) Swap(i, j int)
Swap is for the sorting interface
type PendingPlans ¶
type PendingPlans []*pendingPlan
PendingPlans is a list of waiting plans. We implement the container/heap interface so that this is a priority queue
func (PendingPlans) Less ¶
func (p PendingPlans) Less(i, j int) bool
Less is for the sorting interface. We flip the check so that the "min" in the min-heap is the element with the highest priority. For the same priority, we use the enqueue time of the evaluation to give a FIFO ordering.
func (PendingPlans) Peek ¶
func (p PendingPlans) Peek() *pendingPlan
Peek is used to peek at the next element that would be popped
func (*PendingPlans) Pop ¶
func (p *PendingPlans) Pop() interface{}
Pop is used to remove an evaluation from the slice
func (*PendingPlans) Push ¶
func (p *PendingPlans) Push(e interface{})
Push is used to add a new evalution to the slice
type Periodic ¶ added in v0.3.0
type Periodic struct {
// contains filtered or unexported fields
}
Periodic endpoint is used for periodic job interactions
func (*Periodic) Force ¶ added in v0.3.0
func (p *Periodic) Force(args *structs.PeriodicForceRequest, reply *structs.PeriodicForceResponse) error
Force is used to force a new instance of a periodic job
type PeriodicDispatch ¶ added in v0.3.0
type PeriodicDispatch struct {
// contains filtered or unexported fields
}
PeriodicDispatch is used to track and launch periodic jobs. It maintains the set of periodic jobs and creates derived jobs and evaluations per instantiation which is determined by the periodic spec.
func NewPeriodicDispatch ¶ added in v0.3.0
func NewPeriodicDispatch(logger *log.Logger, dispatcher JobEvalDispatcher) *PeriodicDispatch
NewPeriodicDispatch returns a periodic dispatcher that is used to track and launch periodic jobs.
func (*PeriodicDispatch) Add ¶ added in v0.3.0
func (p *PeriodicDispatch) Add(job *structs.Job) error
Add begins tracking of a periodic job. If it is already tracked, it acts as an update to the jobs periodic spec.
func (*PeriodicDispatch) Flush ¶ added in v0.3.0
func (p *PeriodicDispatch) Flush()
Flush clears the state of the PeriodicDispatcher
func (*PeriodicDispatch) ForceRun ¶ added in v0.3.0
func (p *PeriodicDispatch) ForceRun(jobID string) (*structs.Evaluation, error)
ForceRun causes the periodic job to be evaluated immediately and returns the subsequent eval.
func (*PeriodicDispatch) LaunchTime ¶ added in v0.3.0
func (p *PeriodicDispatch) LaunchTime(jobID string) (time.Time, error)
LaunchTime returns the launch time of the job. This is only valid for jobs created by PeriodicDispatch and will otherwise return an error.
func (*PeriodicDispatch) Remove ¶ added in v0.3.0
func (p *PeriodicDispatch) Remove(jobID string) error
Remove stops tracking the passed job. If the job is not tracked, it is a no-op.
func (*PeriodicDispatch) SetEnabled ¶ added in v0.3.0
func (p *PeriodicDispatch) SetEnabled(enabled bool)
SetEnabled is used to control if the periodic dispatcher is enabled. It should only be enabled on the active leader. Disabling an active dispatcher will stop any launched go routine and flush the dispatcher.
func (*PeriodicDispatch) Start ¶ added in v0.3.0
func (p *PeriodicDispatch) Start()
Start begins the goroutine that creates derived jobs and evals.
func (*PeriodicDispatch) Tracked ¶ added in v0.3.0
func (p *PeriodicDispatch) Tracked() []*structs.Job
Tracked returns the set of tracked job IDs.
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan endpoint is used for plan interactions
func (*Plan) Submit ¶
func (p *Plan) Submit(args *structs.PlanRequest, reply *structs.PlanResponse) error
Submit is used to submit a plan to the leader
type PlanFuture ¶
type PlanFuture interface {
Wait() (*structs.PlanResult, error)
}
PlanFuture is used to return a future for an enqueue
type PlanQueue ¶
type PlanQueue struct {
// contains filtered or unexported fields
}
PlanQueue is used to submit commit plans for task allocations to the current leader. The leader verifies that resources are not over-committed and commits to Raft. This allows sub-schedulers to be optimistically concurrent. In the case of an overcommit, the plan may be partially applied if allowed, or completely rejected (gang commit).
func NewPlanQueue ¶
NewPlanQueue is used to construct and return a new plan queue
func (*PlanQueue) Enqueue ¶
func (q *PlanQueue) Enqueue(plan *structs.Plan) (PlanFuture, error)
Enqueue is used to enqueue a plan
func (*PlanQueue) Flush ¶
func (q *PlanQueue) Flush()
Flush is used to reset the state of the plan queue
func (*PlanQueue) SetEnabled ¶
SetEnabled is used to control if the queue is enabled. The queue should only be enabled on the active leader.
func (*PlanQueue) Stats ¶
func (q *PlanQueue) Stats() *QueueStats
Stats is used to query the state of the queue
type PurgeVaultAccessorFn ¶ added in v0.5.0
type PurgeVaultAccessorFn func(accessors []*structs.VaultAccessor) error
PurgeVaultAccessor is called to remove VaultAccessors from the system. If the function returns an error, the token will still be tracked and revocation will retry till there is a success
type QueueStats ¶
type QueueStats struct {
Depth int
}
QueueStats returns all the stats about the plan queue
type RaftLayer ¶
type RaftLayer struct {
// contains filtered or unexported fields
}
RaftLayer implements the raft.StreamLayer interface, so that we can use a single RPC layer for Raft and Nomad
func NewRaftLayer ¶
NewRaftLayer is used to initialize a new RaftLayer which can be used as a StreamLayer for Raft. If a tlsConfig is provided, then the connection will use TLS.
func (*RaftLayer) Accept ¶
Accept is used to return connection which are dialed to be used with the Raft layer
type Region ¶ added in v0.2.1
type Region struct {
// contains filtered or unexported fields
}
Region is used to query and list the known regions
type SchedulerStats ¶
SchedulerStats returns the stats per scheduler
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is Nomad server which manages the job queues, schedulers, and notification bus for agents.
func NewServer ¶
NewServer is used to construct a new Nomad server from the configuration, potentially returning an error
func (*Server) Datacenter ¶ added in v0.5.0
Datacenter returns the data center of the server
func (*Server) DispatchJob ¶ added in v0.3.0
DispatchJob creates an evaluation for the passed job and commits both the evaluation and the job to the raft log. It returns the eval.
func (*Server) GetConfig ¶ added in v0.5.0
GetConfig returns the config of the server for testing purposes only
func (*Server) IsShutdown ¶
IsShutdown checks if the server is shutdown
func (*Server) Join ¶
Join is used to have Nomad join the gossip ring The target address should be another node listening on the Serf address
func (*Server) KeyManager ¶
func (s *Server) KeyManager() *serf.KeyManager
KeyManager returns the Serf keyring manager
func (*Server) LocalMember ¶
LocalMember is used to return the local node
func (*Server) Reload ¶ added in v0.5.5
Reload handles a config reload. Not all config fields can handle a reload.
func (*Server) RemoveFailedNode ¶
RemoveFailedNode is used to remove a failed node from the cluster
func (*Server) RunningChildren ¶ added in v0.3.0
RunningChildren checks whether the passed job has any running children.
func (*Server) State ¶
func (s *Server) State() *state.StateStore
State returns the underlying state store. This should *not* be used to modify state directly.
type SnapshotType ¶
type SnapshotType byte
SnapshotType is prefixed to a record in the FSM snapshot so that we can determine the type for restore
const ( NodeSnapshot SnapshotType = iota JobSnapshot IndexSnapshot EvalSnapshot AllocSnapshot TimeTableSnapshot PeriodicLaunchSnapshot JobSummarySnapshot VaultAccessorSnapshot )
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status endpoint is used to check on server status
func (*Status) Leader ¶
func (s *Status) Leader(args *structs.GenericRequest, reply *string) error
Leader is used to get the address of the leader
func (*Status) Members ¶ added in v0.5.0
func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error
Members return the list of servers in a cluster that a particular server is aware of
func (*Status) Peers ¶
func (s *Status) Peers(args *structs.GenericRequest, reply *[]string) error
Peers is used to get all the Raft peers
func (*Status) Version ¶
func (s *Status) Version(args *structs.GenericRequest, reply *structs.VersionResponse) error
Version is used to allow clients to determine the capabilities of the server
type StreamClient ¶
type StreamClient struct {
// contains filtered or unexported fields
}
streamClient is used to wrap a stream with an RPC client
func (*StreamClient) Close ¶
func (sc *StreamClient) Close()
type System ¶ added in v0.3.0
type System struct {
// contains filtered or unexported fields
}
System endpoint is used to call invoke system tasks.
func (*System) GarbageCollect ¶ added in v0.3.0
func (s *System) GarbageCollect(args *structs.GenericRequest, reply *structs.GenericResponse) error
GarbageCollect is used to trigger the system to immediately garbage collect nodes, evals and jobs.
func (*System) ReconcileJobSummaries ¶ added in v0.4.1
func (s *System) ReconcileJobSummaries(args *structs.GenericRequest, reply *structs.GenericResponse) error
ReconcileSummaries reconciles the summaries of all the jobs in the state store
type TestVaultClient ¶ added in v0.5.0
type TestVaultClient struct { // LookupTokenErrors maps a token to an error that will be returned by the // LookupToken call LookupTokenErrors map[string]error // LookupTokenSecret maps a token to the Vault secret that will be returned // by the LookupToken call LookupTokenSecret map[string]*vapi.Secret // CreateTokenErrors maps a token to an error that will be returned by the // CreateToken call CreateTokenErrors map[string]map[string]error // CreateTokenSecret maps a token to the Vault secret that will be returned // by the CreateToken call CreateTokenSecret map[string]map[string]*vapi.Secret RevokedTokens []*structs.VaultAccessor }
TestVaultClient is a Vault client appropriate for use during testing. Its behavior is programmable such that endpoints can be tested under various circumstances.
func (*TestVaultClient) CreateToken ¶ added in v0.5.0
func (v *TestVaultClient) CreateToken(ctx context.Context, a *structs.Allocation, task string) (*vapi.Secret, error)
func (*TestVaultClient) EmitStats ¶ added in v0.5.5
func (v *TestVaultClient) EmitStats(period time.Duration, stopCh chan struct{})
func (*TestVaultClient) LookupToken ¶ added in v0.5.0
func (*TestVaultClient) RevokeTokens ¶ added in v0.5.0
func (v *TestVaultClient) RevokeTokens(ctx context.Context, accessors []*structs.VaultAccessor, committed bool) error
func (*TestVaultClient) Running ¶ added in v0.5.5
func (v *TestVaultClient) Running() bool
func (*TestVaultClient) SetActive ¶ added in v0.5.0
func (v *TestVaultClient) SetActive(enabled bool)
func (*TestVaultClient) SetConfig ¶ added in v0.5.0
func (v *TestVaultClient) SetConfig(config *config.VaultConfig) error
func (*TestVaultClient) SetCreateTokenError ¶ added in v0.5.0
func (v *TestVaultClient) SetCreateTokenError(allocID, task string, err error)
SetCreateTokenError sets the error that will be returned by the token creation
func (*TestVaultClient) SetCreateTokenSecret ¶ added in v0.5.0
func (v *TestVaultClient) SetCreateTokenSecret(allocID, task string, secret *vapi.Secret)
SetCreateTokenSecret sets the secret that will be returned by the token creation
func (*TestVaultClient) SetLookupTokenAllowedPolicies ¶ added in v0.5.0
func (v *TestVaultClient) SetLookupTokenAllowedPolicies(token string, policies []string)
SetLookupTokenAllowedPolicies is a helper that adds a secret that allows the given policies
func (*TestVaultClient) SetLookupTokenError ¶ added in v0.5.0
func (v *TestVaultClient) SetLookupTokenError(token string, err error)
SetLookupTokenSecret sets the error that will be returned by the token lookup
func (*TestVaultClient) SetLookupTokenSecret ¶ added in v0.5.0
func (v *TestVaultClient) SetLookupTokenSecret(token string, secret *vapi.Secret)
SetLookupTokenSecret sets the secret that will be returned by the token lookup
func (*TestVaultClient) Stats ¶ added in v0.5.5
func (v *TestVaultClient) Stats() *VaultStats
func (*TestVaultClient) Stop ¶ added in v0.5.0
func (v *TestVaultClient) Stop()
type TimeTable ¶
type TimeTable struct {
// contains filtered or unexported fields
}
TimeTable is used to associate a Raft index with a timestamp. This is used so that we can quickly go from a timestamp to an index or visa versa.
func NewTimeTable ¶
NewTimeTable creates a new time table which stores entries at a given granularity for a maximum limit. The storage space required is (limit/granularity)
func (*TimeTable) Deserialize ¶
Deserialize is used to deserialize the time table and restore the state
func (*TimeTable) NearestIndex ¶
NearestIndex returns the nearest index older than the given time
func (*TimeTable) NearestTime ¶
NearestTime returns the nearest time older than the given index
type TimeTableEntry ¶
TimeTableEntry is used to track a time and index
type VaultClient ¶ added in v0.5.0
type VaultClient interface { // SetActive activates or de-activates the Vault client. When active, token // creation/lookup/revocation operation are allowed. SetActive(active bool) // SetConfig updates the config used by the Vault client SetConfig(config *config.VaultConfig) error // CreateToken takes an allocation and task and returns an appropriate Vault // Secret CreateToken(ctx context.Context, a *structs.Allocation, task string) (*vapi.Secret, error) // LookupToken takes a token string and returns its capabilities. LookupToken(ctx context.Context, token string) (*vapi.Secret, error) // RevokeTokens takes a set of tokens accessor and revokes the tokens RevokeTokens(ctx context.Context, accessors []*structs.VaultAccessor, committed bool) error // Stop is used to stop token renewal Stop() // Running returns whether the Vault client is running Running() bool // Stats returns the Vault clients statistics Stats() *VaultStats // EmitStats emits that clients statistics at the given period until stopCh // is called. EmitStats(period time.Duration, stopCh chan struct{}) }
VaultClient is the Servers interface for interfacing with Vault
type VaultStats ¶ added in v0.5.5
type VaultStats struct { // TrackedForRevoke is the count of tokens that are being tracked to be // revoked since they could not be immediately revoked. TrackedForRevoke int }
VaultStats returns all the stats about Vault tokens created and managed by Nomad.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is a single threaded scheduling worker. There may be multiple running per server (leader or follower). They are responsible for dequeuing pending evaluations, invoking schedulers, plan submission and the lifecycle around making task allocations. They bridge the business logic of the scheduler with the plumbing required to make it all work.
func (*Worker) CreateEval ¶
func (w *Worker) CreateEval(eval *structs.Evaluation) error
CreateEval is used to create a new evaluation. This allows the worker to act as the planner for the scheduler.
func (*Worker) ReblockEval ¶ added in v0.4.0
func (w *Worker) ReblockEval(eval *structs.Evaluation) error
ReblockEval is used to reinsert a blocked evaluation into the blocked eval tracker. This allows the worker to act as the planner for the scheduler.
func (*Worker) SubmitPlan ¶
SubmitPlan is used to submit a plan for consideration. This allows the worker to act as the planner for the scheduler.
func (*Worker) UpdateEval ¶
func (w *Worker) UpdateEval(eval *structs.Evaluation) error
UpdateEval is used to submit an updated evaluation. This allows the worker to act as the planner for the scheduler.
Source Files ¶
- alloc_endpoint.go
- blocked_evals.go
- config.go
- core_sched.go
- eval_broker.go
- eval_endpoint.go
- fsm.go
- heartbeat.go
- job_endpoint.go
- leader.go
- merge.go
- node_endpoint.go
- operator_endpoint.go
- periodic.go
- periodic_endpoint.go
- plan_apply.go
- plan_apply_pool.go
- plan_endpoint.go
- plan_queue.go
- pool.go
- raft_rpc.go
- regions_endpoint.go
- rpc.go
- serf.go
- server.go
- status_endpoint.go
- system_endpoint.go
- timetable.go
- util.go
- vault.go
- vault_testing.go
- worker.go