id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
132,900
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
Migrate
func (p *remotePrevAlloc) Migrate(ctx context.Context, dest *allocdir.AllocDir) error { if !p.migrate { // Volume wasn't configured to be migrated, return early return nil } p.waitingLock.Lock() p.migrating = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.migrating = false p.waitingL...
go
func (p *remotePrevAlloc) Migrate(ctx context.Context, dest *allocdir.AllocDir) error { if !p.migrate { // Volume wasn't configured to be migrated, return early return nil } p.waitingLock.Lock() p.migrating = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.migrating = false p.waitingL...
[ "func", "(", "p", "*", "remotePrevAlloc", ")", "Migrate", "(", "ctx", "context", ".", "Context", ",", "dest", "*", "allocdir", ".", "AllocDir", ")", "error", "{", "if", "!", "p", ".", "migrate", "{", "// Volume wasn't configured to be migrated, return early", ...
// Migrate alloc data from a remote node if the new alloc has migration enabled // and the old alloc hasn't been GC'd.
[ "Migrate", "alloc", "data", "from", "a", "remote", "node", "if", "the", "new", "alloc", "has", "migration", "enabled", "and", "the", "old", "alloc", "hasn", "t", "been", "GC", "d", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L424-L468
132,901
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
getNodeAddr
func (p *remotePrevAlloc) getNodeAddr(ctx context.Context, nodeID string) (string, error) { req := structs.NodeSpecificRequest{ NodeID: nodeID, QueryOptions: structs.QueryOptions{ Region: p.config.Region, AllowStale: true, AuthToken: p.config.Node.SecretID, }, } resp := structs.SingleNodeRespons...
go
func (p *remotePrevAlloc) getNodeAddr(ctx context.Context, nodeID string) (string, error) { req := structs.NodeSpecificRequest{ NodeID: nodeID, QueryOptions: structs.QueryOptions{ Region: p.config.Region, AllowStale: true, AuthToken: p.config.Node.SecretID, }, } resp := structs.SingleNodeRespons...
[ "func", "(", "p", "*", "remotePrevAlloc", ")", "getNodeAddr", "(", "ctx", "context", ".", "Context", ",", "nodeID", "string", ")", "(", "string", ",", "error", ")", "{", "req", ":=", "structs", ".", "NodeSpecificRequest", "{", "NodeID", ":", "nodeID", ",...
// getNodeAddr gets the node from the server with the given Node ID
[ "getNodeAddr", "gets", "the", "node", "from", "the", "server", "with", "the", "given", "Node", "ID" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L471-L506
132,902
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
migrateAllocDir
func (p *remotePrevAlloc) migrateAllocDir(ctx context.Context, nodeAddr string) (*allocdir.AllocDir, error) { // Create the previous alloc dir prevAllocDir := allocdir.NewAllocDir(p.logger, filepath.Join(p.config.AllocDir, p.prevAllocID)) if err := prevAllocDir.Build(); err != nil { return nil, fmt.Errorf("error b...
go
func (p *remotePrevAlloc) migrateAllocDir(ctx context.Context, nodeAddr string) (*allocdir.AllocDir, error) { // Create the previous alloc dir prevAllocDir := allocdir.NewAllocDir(p.logger, filepath.Join(p.config.AllocDir, p.prevAllocID)) if err := prevAllocDir.Build(); err != nil { return nil, fmt.Errorf("error b...
[ "func", "(", "p", "*", "remotePrevAlloc", ")", "migrateAllocDir", "(", "ctx", "context", ".", "Context", ",", "nodeAddr", "string", ")", "(", "*", "allocdir", ".", "AllocDir", ",", "error", ")", "{", "// Create the previous alloc dir", "prevAllocDir", ":=", "a...
// migrate a remote alloc dir to local node. Caller is responsible for calling // Destroy on the returned allocdir if no error occurs.
[ "migrate", "a", "remote", "alloc", "dir", "to", "local", "node", ".", "Caller", "is", "responsible", "for", "calling", "Destroy", "on", "the", "returned", "allocdir", "if", "no", "error", "occurs", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L510-L545
132,903
hashicorp/nomad
nomad/plan_queue.go
NewPlanQueue
func NewPlanQueue() (*PlanQueue, error) { q := &PlanQueue{ enabled: false, stats: new(QueueStats), ready: make([]*pendingPlan, 0, 16), waitCh: make(chan struct{}, 1), } return q, nil }
go
func NewPlanQueue() (*PlanQueue, error) { q := &PlanQueue{ enabled: false, stats: new(QueueStats), ready: make([]*pendingPlan, 0, 16), waitCh: make(chan struct{}, 1), } return q, nil }
[ "func", "NewPlanQueue", "(", ")", "(", "*", "PlanQueue", ",", "error", ")", "{", "q", ":=", "&", "PlanQueue", "{", "enabled", ":", "false", ",", "stats", ":", "new", "(", "QueueStats", ")", ",", "ready", ":", "make", "(", "[", "]", "*", "pendingPla...
// NewPlanQueue is used to construct and return a new plan queue
[ "NewPlanQueue", "is", "used", "to", "construct", "and", "return", "a", "new", "plan", "queue" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L40-L48
132,904
hashicorp/nomad
nomad/plan_queue.go
Wait
func (p *pendingPlan) Wait() (*structs.PlanResult, error) { err := <-p.errCh return p.result, err }
go
func (p *pendingPlan) Wait() (*structs.PlanResult, error) { err := <-p.errCh return p.result, err }
[ "func", "(", "p", "*", "pendingPlan", ")", "Wait", "(", ")", "(", "*", "structs", ".", "PlanResult", ",", "error", ")", "{", "err", ":=", "<-", "p", ".", "errCh", "\n", "return", "p", ".", "result", ",", "err", "\n", "}" ]
// Wait is used to block for the plan result or potential error
[ "Wait", "is", "used", "to", "block", "for", "the", "plan", "result", "or", "potential", "error" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L60-L63
132,905
hashicorp/nomad
nomad/plan_queue.go
Enabled
func (q *PlanQueue) Enabled() bool { q.l.RLock() defer q.l.RUnlock() return q.enabled }
go
func (q *PlanQueue) Enabled() bool { q.l.RLock() defer q.l.RUnlock() return q.enabled }
[ "func", "(", "q", "*", "PlanQueue", ")", "Enabled", "(", ")", "bool", "{", "q", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "q", ".", "l", ".", "RUnlock", "(", ")", "\n", "return", "q", ".", "enabled", "\n", "}" ]
// Enabled is used to check if the queue is enabled.
[ "Enabled", "is", "used", "to", "check", "if", "the", "queue", "is", "enabled", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L77-L81
132,906
hashicorp/nomad
nomad/plan_queue.go
SetEnabled
func (q *PlanQueue) SetEnabled(enabled bool) { q.l.Lock() q.enabled = enabled q.l.Unlock() if !enabled { q.Flush() } }
go
func (q *PlanQueue) SetEnabled(enabled bool) { q.l.Lock() q.enabled = enabled q.l.Unlock() if !enabled { q.Flush() } }
[ "func", "(", "q", "*", "PlanQueue", ")", "SetEnabled", "(", "enabled", "bool", ")", "{", "q", ".", "l", ".", "Lock", "(", ")", "\n", "q", ".", "enabled", "=", "enabled", "\n", "q", ".", "l", ".", "Unlock", "(", ")", "\n", "if", "!", "enabled", ...
// SetEnabled is used to control if the queue is enabled. The queue // should only be enabled on the active leader.
[ "SetEnabled", "is", "used", "to", "control", "if", "the", "queue", "is", "enabled", ".", "The", "queue", "should", "only", "be", "enabled", "on", "the", "active", "leader", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L85-L92
132,907
hashicorp/nomad
nomad/plan_queue.go
Enqueue
func (q *PlanQueue) Enqueue(plan *structs.Plan) (PlanFuture, error) { q.l.Lock() defer q.l.Unlock() // Do nothing if not enabled if !q.enabled { return nil, fmt.Errorf("plan queue is disabled") } // Wrap the pending plan pending := &pendingPlan{ plan: plan, enqueueTime: time.Now(), errCh: ...
go
func (q *PlanQueue) Enqueue(plan *structs.Plan) (PlanFuture, error) { q.l.Lock() defer q.l.Unlock() // Do nothing if not enabled if !q.enabled { return nil, fmt.Errorf("plan queue is disabled") } // Wrap the pending plan pending := &pendingPlan{ plan: plan, enqueueTime: time.Now(), errCh: ...
[ "func", "(", "q", "*", "PlanQueue", ")", "Enqueue", "(", "plan", "*", "structs", ".", "Plan", ")", "(", "PlanFuture", ",", "error", ")", "{", "q", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "q", ".", "l", ".", "Unlock", "(", ")", "\n\n", ...
// Enqueue is used to enqueue a plan
[ "Enqueue", "is", "used", "to", "enqueue", "a", "plan" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L95-L123
132,908
hashicorp/nomad
nomad/plan_queue.go
Flush
func (q *PlanQueue) Flush() { q.l.Lock() defer q.l.Unlock() // Error out all the futures for _, pending := range q.ready { pending.respond(nil, planQueueFlushed) } // Reset the broker q.stats.Depth = 0 q.ready = make([]*pendingPlan, 0, 16) // Unblock any waiters select { case q.waitCh <- struct{}{}: de...
go
func (q *PlanQueue) Flush() { q.l.Lock() defer q.l.Unlock() // Error out all the futures for _, pending := range q.ready { pending.respond(nil, planQueueFlushed) } // Reset the broker q.stats.Depth = 0 q.ready = make([]*pendingPlan, 0, 16) // Unblock any waiters select { case q.waitCh <- struct{}{}: de...
[ "func", "(", "q", "*", "PlanQueue", ")", "Flush", "(", ")", "{", "q", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "q", ".", "l", ".", "Unlock", "(", ")", "\n\n", "// Error out all the futures", "for", "_", ",", "pending", ":=", "range", "q", ...
// Flush is used to reset the state of the plan queue
[ "Flush", "is", "used", "to", "reset", "the", "state", "of", "the", "plan", "queue" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L164-L182
132,909
hashicorp/nomad
nomad/plan_queue.go
Stats
func (q *PlanQueue) Stats() *QueueStats { // Allocate a new stats struct stats := new(QueueStats) q.l.RLock() defer q.l.RUnlock() // Copy all the stats *stats = *q.stats return stats }
go
func (q *PlanQueue) Stats() *QueueStats { // Allocate a new stats struct stats := new(QueueStats) q.l.RLock() defer q.l.RUnlock() // Copy all the stats *stats = *q.stats return stats }
[ "func", "(", "q", "*", "PlanQueue", ")", "Stats", "(", ")", "*", "QueueStats", "{", "// Allocate a new stats struct", "stats", ":=", "new", "(", "QueueStats", ")", "\n\n", "q", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "q", ".", "l", ".", "RUn...
// Stats is used to query the state of the queue
[ "Stats", "is", "used", "to", "query", "the", "state", "of", "the", "queue" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L185-L195
132,910
hashicorp/nomad
nomad/plan_queue.go
Less
func (p PendingPlans) Less(i, j int) bool { if p[i].plan.Priority != p[j].plan.Priority { return !(p[i].plan.Priority < p[j].plan.Priority) } return p[i].enqueueTime.Before(p[j].enqueueTime) }
go
func (p PendingPlans) Less(i, j int) bool { if p[i].plan.Priority != p[j].plan.Priority { return !(p[i].plan.Priority < p[j].plan.Priority) } return p[i].enqueueTime.Before(p[j].enqueueTime) }
[ "func", "(", "p", "PendingPlans", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "if", "p", "[", "i", "]", ".", "plan", ".", "Priority", "!=", "p", "[", "j", "]", ".", "plan", ".", "Priority", "{", "return", "!", "(", "p", "[", "...
// 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.
[ "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...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_queue.go#L225-L230
132,911
hashicorp/nomad
nomad/job_endpoint.go
setImplicitConstraints
func setImplicitConstraints(j *structs.Job) { // Get the required Vault Policies policies := j.VaultPolicies() // Get the required signals signals := j.RequiredSignals() // Hot path if len(signals) == 0 && len(policies) == 0 { return } // Add Vault constraints for _, tg := range j.TaskGroups { _, ok := ...
go
func setImplicitConstraints(j *structs.Job) { // Get the required Vault Policies policies := j.VaultPolicies() // Get the required signals signals := j.RequiredSignals() // Hot path if len(signals) == 0 && len(policies) == 0 { return } // Add Vault constraints for _, tg := range j.TaskGroups { _, ok := ...
[ "func", "setImplicitConstraints", "(", "j", "*", "structs", ".", "Job", ")", "{", "// Get the required Vault Policies", "policies", ":=", "j", ".", "VaultPolicies", "(", ")", "\n\n", "// Get the required signals", "signals", ":=", "j", ".", "RequiredSignals", "(", ...
// setImplicitConstraints adds implicit constraints to the job based on the // features it is requesting.
[ "setImplicitConstraints", "adds", "implicit", "constraints", "to", "the", "job", "based", "on", "the", "features", "it", "is", "requesting", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L244-L301
132,912
hashicorp/nomad
nomad/job_endpoint.go
getSignalConstraint
func getSignalConstraint(signals []string) *structs.Constraint { sort.Strings(signals) return &structs.Constraint{ Operand: structs.ConstraintSetContains, LTarget: "${attr.os.signals}", RTarget: strings.Join(signals, ","), } }
go
func getSignalConstraint(signals []string) *structs.Constraint { sort.Strings(signals) return &structs.Constraint{ Operand: structs.ConstraintSetContains, LTarget: "${attr.os.signals}", RTarget: strings.Join(signals, ","), } }
[ "func", "getSignalConstraint", "(", "signals", "[", "]", "string", ")", "*", "structs", ".", "Constraint", "{", "sort", ".", "Strings", "(", "signals", ")", "\n", "return", "&", "structs", ".", "Constraint", "{", "Operand", ":", "structs", ".", "Constraint...
// getSignalConstraint builds a suitable constraint based on the required // signals
[ "getSignalConstraint", "builds", "a", "suitable", "constraint", "based", "on", "the", "required", "signals" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L305-L312
132,913
hashicorp/nomad
nomad/job_endpoint.go
Validate
func (j *Job) Validate(args *structs.JobValidateRequest, reply *structs.JobValidateResponse) error { defer metrics.MeasureSince([]string{"nomad", "job", "validate"}, time.Now()) // Check for read-job permissions if aclObj, err := j.srv.ResolveToken(args.AuthToken); err != nil { return err } else if aclObj != nil...
go
func (j *Job) Validate(args *structs.JobValidateRequest, reply *structs.JobValidateResponse) error { defer metrics.MeasureSince([]string{"nomad", "job", "validate"}, time.Now()) // Check for read-job permissions if aclObj, err := j.srv.ResolveToken(args.AuthToken); err != nil { return err } else if aclObj != nil...
[ "func", "(", "j", "*", "Job", ")", "Validate", "(", "args", "*", "structs", ".", "JobValidateRequest", ",", "reply", "*", "structs", ".", "JobValidateResponse", ")", "error", "{", "defer", "metrics", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"...
// Validate validates a job
[ "Validate", "validates", "a", "job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L362-L396
132,914
hashicorp/nomad
nomad/job_endpoint.go
Revert
func (j *Job) Revert(args *structs.JobRevertRequest, reply *structs.JobRegisterResponse) error { if done, err := j.srv.forward("Job.Revert", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "revert"}, time.Now()) // Check for submit-job permissions if aclObj, err := j....
go
func (j *Job) Revert(args *structs.JobRevertRequest, reply *structs.JobRegisterResponse) error { if done, err := j.srv.forward("Job.Revert", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "revert"}, time.Now()) // Check for submit-job permissions if aclObj, err := j....
[ "func", "(", "j", "*", "Job", ")", "Revert", "(", "args", "*", "structs", ".", "JobRevertRequest", ",", "reply", "*", "structs", ".", "JobRegisterResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "(", "\""...
// Revert is used to revert the job to a prior version
[ "Revert", "is", "used", "to", "revert", "the", "job", "to", "a", "prior", "version" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L399-L464
132,915
hashicorp/nomad
nomad/job_endpoint.go
Stable
func (j *Job) Stable(args *structs.JobStabilityRequest, reply *structs.JobStabilityResponse) error { if done, err := j.srv.forward("Job.Stable", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "stable"}, time.Now()) // Check for read-job permissions if aclObj, err := ...
go
func (j *Job) Stable(args *structs.JobStabilityRequest, reply *structs.JobStabilityResponse) error { if done, err := j.srv.forward("Job.Stable", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "stable"}, time.Now()) // Check for read-job permissions if aclObj, err := ...
[ "func", "(", "j", "*", "Job", ")", "Stable", "(", "args", "*", "structs", ".", "JobStabilityRequest", ",", "reply", "*", "structs", ".", "JobStabilityResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "(", ...
// Stable is used to mark the job version as stable
[ "Stable", "is", "used", "to", "mark", "the", "job", "version", "as", "stable" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L467-L510
132,916
hashicorp/nomad
nomad/job_endpoint.go
Deregister
func (j *Job) Deregister(args *structs.JobDeregisterRequest, reply *structs.JobDeregisterResponse) error { if done, err := j.srv.forward("Job.Deregister", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "deregister"}, time.Now()) // Check for submit-job permissions if...
go
func (j *Job) Deregister(args *structs.JobDeregisterRequest, reply *structs.JobDeregisterResponse) error { if done, err := j.srv.forward("Job.Deregister", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "deregister"}, time.Now()) // Check for submit-job permissions if...
[ "func", "(", "j", "*", "Job", ")", "Deregister", "(", "args", "*", "structs", ".", "JobDeregisterRequest", ",", "reply", "*", "structs", ".", "JobDeregisterResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "...
// Deregister is used to remove a job the cluster.
[ "Deregister", "is", "used", "to", "remove", "a", "job", "the", "cluster", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L606-L680
132,917
hashicorp/nomad
nomad/job_endpoint.go
BatchDeregister
func (j *Job) BatchDeregister(args *structs.JobBatchDeregisterRequest, reply *structs.JobBatchDeregisterResponse) error { if done, err := j.srv.forward("Job.BatchDeregister", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "batch_deregister"}, time.Now()) // Resolve th...
go
func (j *Job) BatchDeregister(args *structs.JobBatchDeregisterRequest, reply *structs.JobBatchDeregisterResponse) error { if done, err := j.srv.forward("Job.BatchDeregister", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "batch_deregister"}, time.Now()) // Resolve th...
[ "func", "(", "j", "*", "Job", ")", "BatchDeregister", "(", "args", "*", "structs", ".", "JobBatchDeregisterRequest", ",", "reply", "*", "structs", ".", "JobBatchDeregisterResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", ...
// BatchDeregister is used to remove a set of jobs from the cluster.
[ "BatchDeregister", "is", "used", "to", "remove", "a", "set", "of", "jobs", "from", "the", "cluster", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L683-L762
132,918
hashicorp/nomad
nomad/job_endpoint.go
GetJobVersions
func (j *Job) GetJobVersions(args *structs.JobVersionsRequest, reply *structs.JobVersionsResponse) error { if done, err := j.srv.forward("Job.GetJobVersions", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "get_job_versions"}, time.Now()) // Check for read-job permis...
go
func (j *Job) GetJobVersions(args *structs.JobVersionsRequest, reply *structs.JobVersionsResponse) error { if done, err := j.srv.forward("Job.GetJobVersions", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "get_job_versions"}, time.Now()) // Check for read-job permis...
[ "func", "(", "j", "*", "Job", ")", "GetJobVersions", "(", "args", "*", "structs", ".", "JobVersionsRequest", ",", "reply", "*", "structs", ".", "JobVersionsResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "...
// GetJobVersions is used to retrieve all tracked versions of a job.
[ "GetJobVersions", "is", "used", "to", "retrieve", "all", "tracked", "versions", "of", "a", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L811-L866
132,919
hashicorp/nomad
nomad/job_endpoint.go
List
func (j *Job) List(args *structs.JobListRequest, reply *structs.JobListResponse) error { if done, err := j.srv.forward("Job.List", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "list"}, time.Now()) // Check for list-job permissions if aclObj, err := j.srv.ResolveTo...
go
func (j *Job) List(args *structs.JobListRequest, reply *structs.JobListResponse) error { if done, err := j.srv.forward("Job.List", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "list"}, time.Now()) // Check for list-job permissions if aclObj, err := j.srv.ResolveTo...
[ "func", "(", "j", "*", "Job", ")", "List", "(", "args", "*", "structs", ".", "JobListRequest", ",", "reply", "*", "structs", ".", "JobListResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "(", "\"", "\""...
// List is used to list the jobs registered in the system
[ "List", "is", "used", "to", "list", "the", "jobs", "registered", "in", "the", "system" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L869-L931
132,920
hashicorp/nomad
nomad/job_endpoint.go
Allocations
func (j *Job) Allocations(args *structs.JobSpecificRequest, reply *structs.JobAllocationsResponse) error { if done, err := j.srv.forward("Job.Allocations", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "allocations"}, time.Now()) // Check for read-job permissions i...
go
func (j *Job) Allocations(args *structs.JobSpecificRequest, reply *structs.JobAllocationsResponse) error { if done, err := j.srv.forward("Job.Allocations", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "allocations"}, time.Now()) // Check for read-job permissions i...
[ "func", "(", "j", "*", "Job", ")", "Allocations", "(", "args", "*", "structs", ".", "JobSpecificRequest", ",", "reply", "*", "structs", ".", "JobAllocationsResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "...
// Allocations is used to list the allocations for a job
[ "Allocations", "is", "used", "to", "list", "the", "allocations", "for", "a", "job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L934-L980
132,921
hashicorp/nomad
nomad/job_endpoint.go
Evaluations
func (j *Job) Evaluations(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error { if done, err := j.srv.forward("Job.Evaluations", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "evaluations"}, time.Now()) // Check for read-job permissions i...
go
func (j *Job) Evaluations(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error { if done, err := j.srv.forward("Job.Evaluations", args, args, reply); done { return err } defer metrics.MeasureSince([]string{"nomad", "job", "evaluations"}, time.Now()) // Check for read-job permissions i...
[ "func", "(", "j", "*", "Job", ")", "Evaluations", "(", "args", "*", "structs", ".", "JobSpecificRequest", ",", "reply", "*", "structs", ".", "JobEvaluationsResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "j", ".", "srv", ".", "forward", "...
// Evaluations is used to list the evaluations for a job
[ "Evaluations", "is", "used", "to", "list", "the", "evaluations", "for", "a", "job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L983-L1022
132,922
hashicorp/nomad
nomad/job_endpoint.go
validateJob
func validateJob(job *structs.Job) (invalid, warnings error) { validationErrors := new(multierror.Error) if err := job.Validate(); err != nil { multierror.Append(validationErrors, err) } // Get any warnings warnings = job.Warnings() // TODO: Validate the driver configurations. These had to be removed in 0.9 ...
go
func validateJob(job *structs.Job) (invalid, warnings error) { validationErrors := new(multierror.Error) if err := job.Validate(); err != nil { multierror.Append(validationErrors, err) } // Get any warnings warnings = job.Warnings() // TODO: Validate the driver configurations. These had to be removed in 0.9 ...
[ "func", "validateJob", "(", "job", "*", "structs", ".", "Job", ")", "(", "invalid", ",", "warnings", "error", ")", "{", "validationErrors", ":=", "new", "(", "multierror", ".", "Error", ")", "\n", "if", "err", ":=", "job", ".", "Validate", "(", ")", ...
// validateJob validates a Job and task drivers and returns an error if there is // a validation problem or if the Job is of a type a user is not allowed to // submit.
[ "validateJob", "validates", "a", "Job", "and", "task", "drivers", "and", "returns", "an", "error", "if", "there", "is", "a", "validation", "problem", "or", "if", "the", "Job", "is", "of", "a", "type", "a", "user", "is", "not", "allowed", "to", "submit", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L1270-L1291
132,923
hashicorp/nomad
nomad/job_endpoint.go
validateJobUpdate
func validateJobUpdate(old, new *structs.Job) error { // Validate Dispatch not set on new Jobs if old == nil { if new.Dispatched { return fmt.Errorf("job can't be submitted with 'Dispatched' set") } return nil } // Type transitions are disallowed if old.Type != new.Type { return fmt.Errorf("cannot upda...
go
func validateJobUpdate(old, new *structs.Job) error { // Validate Dispatch not set on new Jobs if old == nil { if new.Dispatched { return fmt.Errorf("job can't be submitted with 'Dispatched' set") } return nil } // Type transitions are disallowed if old.Type != new.Type { return fmt.Errorf("cannot upda...
[ "func", "validateJobUpdate", "(", "old", ",", "new", "*", "structs", ".", "Job", ")", "error", "{", "// Validate Dispatch not set on new Jobs", "if", "old", "==", "nil", "{", "if", "new", ".", "Dispatched", "{", "return", "fmt", ".", "Errorf", "(", "\"", "...
// validateJobUpdate ensures updates to a job are valid.
[ "validateJobUpdate", "ensures", "updates", "to", "a", "job", "are", "valid", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L1294-L1329
132,924
hashicorp/nomad
nomad/job_endpoint.go
validateDispatchRequest
func validateDispatchRequest(req *structs.JobDispatchRequest, job *structs.Job) error { // Check the payload constraint is met hasInputData := len(req.Payload) != 0 if job.ParameterizedJob.Payload == structs.DispatchPayloadRequired && !hasInputData { return fmt.Errorf("Payload is not provided but required by param...
go
func validateDispatchRequest(req *structs.JobDispatchRequest, job *structs.Job) error { // Check the payload constraint is met hasInputData := len(req.Payload) != 0 if job.ParameterizedJob.Payload == structs.DispatchPayloadRequired && !hasInputData { return fmt.Errorf("Payload is not provided but required by param...
[ "func", "validateDispatchRequest", "(", "req", "*", "structs", ".", "JobDispatchRequest", ",", "job", "*", "structs", ".", "Job", ")", "error", "{", "// Check the payload constraint is met", "hasInputData", ":=", "len", "(", "req", ".", "Payload", ")", "!=", "0"...
// validateDispatchRequest returns whether the request is valid given the // parameterized job.
[ "validateDispatchRequest", "returns", "whether", "the", "request", "is", "valid", "given", "the", "parameterized", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/job_endpoint.go#L1451-L1513
132,925
hashicorp/nomad
command/agent/agent_endpoint.go
AgentServersRequest
func (s *HTTPServer) AgentServersRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) { switch req.Method { case "PUT", "POST": return s.updateServers(resp, req) case "GET": return s.listServers(resp, req) default: return nil, CodedError(405, ErrInvalidMethod) } }
go
func (s *HTTPServer) AgentServersRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) { switch req.Method { case "PUT", "POST": return s.updateServers(resp, req) case "GET": return s.listServers(resp, req) default: return nil, CodedError(405, ErrInvalidMethod) } }
[ "func", "(", "s", "*", "HTTPServer", ")", "AgentServersRequest", "(", "resp", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "switch", "req", ".", "Method", "{", "case", ...
// AgentServersRequest is used to query the list of servers used by the Nomad // Client for RPCs. This endpoint can also be used to update the list of // servers for a given agent.
[ "AgentServersRequest", "is", "used", "to", "query", "the", "list", "of", "servers", "used", "by", "the", "Nomad", "Client", "for", "RPCs", ".", "This", "endpoint", "can", "also", "be", "used", "to", "update", "the", "list", "of", "servers", "for", "a", "...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent_endpoint.go#L169-L178
132,926
hashicorp/nomad
command/agent/agent_endpoint.go
ok
func (h healthResponse) ok() bool { if h.Client != nil && !h.Client.Ok { return false } if h.Server != nil && !h.Server.Ok { return false } return true }
go
func (h healthResponse) ok() bool { if h.Client != nil && !h.Client.Ok { return false } if h.Server != nil && !h.Server.Ok { return false } return true }
[ "func", "(", "h", "healthResponse", ")", "ok", "(", ")", "bool", "{", "if", "h", ".", "Client", "!=", "nil", "&&", "!", "h", ".", "Client", ".", "Ok", "{", "return", "false", "\n", "}", "\n", "if", "h", ".", "Server", "!=", "nil", "&&", "!", ...
// ok returns true as long as neither Client nor Server have Ok=false.
[ "ok", "returns", "true", "as", "long", "as", "neither", "Client", "nor", "Server", "have", "Ok", "=", "false", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent_endpoint.go#L389-L397
132,927
hashicorp/nomad
nomad/drainer/drainer_util.go
partitionIds
func partitionIds(maxIds int, ids []string) [][]string { index := 0 total := len(ids) var partitions [][]string for remaining := total - index; remaining > 0; remaining = total - index { if remaining < maxIds { partitions = append(partitions, ids[index:]) break } else { partitions = append(partitions, ...
go
func partitionIds(maxIds int, ids []string) [][]string { index := 0 total := len(ids) var partitions [][]string for remaining := total - index; remaining > 0; remaining = total - index { if remaining < maxIds { partitions = append(partitions, ids[index:]) break } else { partitions = append(partitions, ...
[ "func", "partitionIds", "(", "maxIds", "int", ",", "ids", "[", "]", "string", ")", "[", "]", "[", "]", "string", "{", "index", ":=", "0", "\n", "total", ":=", "len", "(", "ids", ")", "\n", "var", "partitions", "[", "]", "[", "]", "string", "\n", ...
// partitionIds takes a set of IDs and returns a partitioned view of them such // that no batch would result in an overly large raft transaction.
[ "partitionIds", "takes", "a", "set", "of", "IDs", "and", "returns", "a", "partitioned", "view", "of", "them", "such", "that", "no", "batch", "would", "result", "in", "an", "overly", "large", "raft", "transaction", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/drainer_util.go#L16-L31
132,928
hashicorp/nomad
nomad/drainer/drainer_util.go
partitionAllocDrain
func partitionAllocDrain(maxIds int, transitions map[string]*structs.DesiredTransition, evals []*structs.Evaluation) []*transitionTuple { // Determine a stable ordering of the transitioning allocs allocs := make([]string, 0, len(transitions)) for id := range transitions { allocs = append(allocs, id) } var req...
go
func partitionAllocDrain(maxIds int, transitions map[string]*structs.DesiredTransition, evals []*structs.Evaluation) []*transitionTuple { // Determine a stable ordering of the transitioning allocs allocs := make([]string, 0, len(transitions)) for id := range transitions { allocs = append(allocs, id) } var req...
[ "func", "partitionAllocDrain", "(", "maxIds", "int", ",", "transitions", "map", "[", "string", "]", "*", "structs", ".", "DesiredTransition", ",", "evals", "[", "]", "*", "structs", ".", "Evaluation", ")", "[", "]", "*", "transitionTuple", "{", "// Determine...
// partitionAllocDrain returns a list of alloc transitions and evals to apply // in a single raft transaction.This is necessary to ensure that the Raft // transaction does not become too large.
[ "partitionAllocDrain", "returns", "a", "list", "of", "alloc", "transitions", "and", "evals", "to", "apply", "in", "a", "single", "raft", "transaction", ".", "This", "is", "necessary", "to", "ensure", "that", "the", "Raft", "transaction", "does", "not", "become...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/drainer_util.go#L42-L93
132,929
hashicorp/nomad
api/search.go
PrefixSearch
func (s *Search) PrefixSearch(prefix string, context contexts.Context, q *QueryOptions) (*SearchResponse, *QueryMeta, error) { var resp SearchResponse req := &SearchRequest{Prefix: prefix, Context: context} qm, err := s.client.putQuery("/v1/search", req, &resp, q) if err != nil { return nil, nil, err } return...
go
func (s *Search) PrefixSearch(prefix string, context contexts.Context, q *QueryOptions) (*SearchResponse, *QueryMeta, error) { var resp SearchResponse req := &SearchRequest{Prefix: prefix, Context: context} qm, err := s.client.putQuery("/v1/search", req, &resp, q) if err != nil { return nil, nil, err } return...
[ "func", "(", "s", "*", "Search", ")", "PrefixSearch", "(", "prefix", "string", ",", "context", "contexts", ".", "Context", ",", "q", "*", "QueryOptions", ")", "(", "*", "SearchResponse", ",", "*", "QueryMeta", ",", "error", ")", "{", "var", "resp", "Se...
// PrefixSearch returns a list of matches for a particular context and prefix.
[ "PrefixSearch", "returns", "a", "list", "of", "matches", "for", "a", "particular", "context", "and", "prefix", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/search.go#L17-L27
132,930
hashicorp/nomad
nomad/server.go
startRPCListener
func (s *Server) startRPCListener() { ctx, cancel := context.WithCancel(context.Background()) s.rpcCancel = cancel go s.listen(ctx) }
go
func (s *Server) startRPCListener() { ctx, cancel := context.WithCancel(context.Background()) s.rpcCancel = cancel go s.listen(ctx) }
[ "func", "(", "s", "*", "Server", ")", "startRPCListener", "(", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "s", ".", "rpcCancel", "=", "cancel", "\n", "go", "s", ".", "...
// startRPCListener starts the server's the RPC listener
[ "startRPCListener", "starts", "the", "server", "s", "the", "RPC", "listener" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L416-L420
132,931
hashicorp/nomad
nomad/server.go
createRPCListener
func (s *Server) createRPCListener() (*net.TCPListener, error) { s.listenerCh = make(chan struct{}) listener, err := net.ListenTCP("tcp", s.config.RPCAddr) if err != nil { s.logger.Error("failed to initialize TLS listener", "error", err) return listener, err } s.rpcListener = listener return listener, nil }
go
func (s *Server) createRPCListener() (*net.TCPListener, error) { s.listenerCh = make(chan struct{}) listener, err := net.ListenTCP("tcp", s.config.RPCAddr) if err != nil { s.logger.Error("failed to initialize TLS listener", "error", err) return listener, err } s.rpcListener = listener return listener, nil }
[ "func", "(", "s", "*", "Server", ")", "createRPCListener", "(", ")", "(", "*", "net", ".", "TCPListener", ",", "error", ")", "{", "s", ".", "listenerCh", "=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "listener", ",", "err", ":=", "net", ...
// createRPCListener creates the server's RPC listener
[ "createRPCListener", "creates", "the", "server", "s", "RPC", "listener" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L423-L433
132,932
hashicorp/nomad
nomad/server.go
getTLSConf
func getTLSConf(enableRPC bool, tlsConf *tlsutil.Config) (*tls.Config, tlsutil.RegionWrapper, error) { var tlsWrap tlsutil.RegionWrapper var incomingTLS *tls.Config if enableRPC { tw, err := tlsConf.OutgoingTLSWrapper() if err != nil { return nil, nil, err } tlsWrap = tw itls, err := tlsConf.IncomingTL...
go
func getTLSConf(enableRPC bool, tlsConf *tlsutil.Config) (*tls.Config, tlsutil.RegionWrapper, error) { var tlsWrap tlsutil.RegionWrapper var incomingTLS *tls.Config if enableRPC { tw, err := tlsConf.OutgoingTLSWrapper() if err != nil { return nil, nil, err } tlsWrap = tw itls, err := tlsConf.IncomingTL...
[ "func", "getTLSConf", "(", "enableRPC", "bool", ",", "tlsConf", "*", "tlsutil", ".", "Config", ")", "(", "*", "tls", ".", "Config", ",", "tlsutil", ".", "RegionWrapper", ",", "error", ")", "{", "var", "tlsWrap", "tlsutil", ".", "RegionWrapper", "\n", "va...
// getTLSConf gets the server's TLS configuration based on the config supplied // by the operator
[ "getTLSConf", "gets", "the", "server", "s", "TLS", "configuration", "based", "on", "the", "config", "supplied", "by", "the", "operator" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L437-L454
132,933
hashicorp/nomad
nomad/server.go
reloadTLSConnections
func (s *Server) reloadTLSConnections(newTLSConfig *config.TLSConfig) error { s.logger.Info("reloading server connections due to configuration changes") // Check if we can reload the RPC listener if s.rpcListener == nil || s.rpcCancel == nil { s.logger.Warn("unable to reload configuration due to uninitialized rpc...
go
func (s *Server) reloadTLSConnections(newTLSConfig *config.TLSConfig) error { s.logger.Info("reloading server connections due to configuration changes") // Check if we can reload the RPC listener if s.rpcListener == nil || s.rpcCancel == nil { s.logger.Warn("unable to reload configuration due to uninitialized rpc...
[ "func", "(", "s", "*", "Server", ")", "reloadTLSConnections", "(", "newTLSConfig", "*", "config", ".", "TLSConfig", ")", "error", "{", "s", ".", "logger", ".", "Info", "(", "\"", "\"", ")", "\n\n", "// Check if we can reload the RPC listener", "if", "s", "."...
// reloadTLSConnections updates a server's TLS configuration and reloads RPC // connections.
[ "reloadTLSConnections", "updates", "a", "server", "s", "TLS", "configuration", "and", "reloads", "RPC", "connections", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L458-L520
132,934
hashicorp/nomad
nomad/server.go
Reload
func (s *Server) Reload(newConfig *Config) error { if newConfig == nil { return fmt.Errorf("Reload given a nil config") } var mErr multierror.Error // Handle the Vault reload. Vault should never be nil but just guard. if s.vault != nil { if err := s.vault.SetConfig(newConfig.VaultConfig); err != nil { mul...
go
func (s *Server) Reload(newConfig *Config) error { if newConfig == nil { return fmt.Errorf("Reload given a nil config") } var mErr multierror.Error // Handle the Vault reload. Vault should never be nil but just guard. if s.vault != nil { if err := s.vault.SetConfig(newConfig.VaultConfig); err != nil { mul...
[ "func", "(", "s", "*", "Server", ")", "Reload", "(", "newConfig", "*", "Config", ")", "error", "{", "if", "newConfig", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "mErr", "multierror", ".", "Err...
// Reload handles a config reload specific to server-only configuration. Not // all config fields can handle a reload.
[ "Reload", "handles", "a", "config", "reload", "specific", "to", "server", "-", "only", "configuration", ".", "Not", "all", "config", "fields", "can", "handle", "a", "reload", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L678-L705
132,935
hashicorp/nomad
nomad/server.go
setupConsulSyncer
func (s *Server) setupConsulSyncer() error { if s.config.ConsulConfig.ServerAutoJoin != nil && *s.config.ConsulConfig.ServerAutoJoin { if err := s.setupBootstrapHandler(); err != nil { return err } } return nil }
go
func (s *Server) setupConsulSyncer() error { if s.config.ConsulConfig.ServerAutoJoin != nil && *s.config.ConsulConfig.ServerAutoJoin { if err := s.setupBootstrapHandler(); err != nil { return err } } return nil }
[ "func", "(", "s", "*", "Server", ")", "setupConsulSyncer", "(", ")", "error", "{", "if", "s", ".", "config", ".", "ConsulConfig", ".", "ServerAutoJoin", "!=", "nil", "&&", "*", "s", ".", "config", ".", "ConsulConfig", ".", "ServerAutoJoin", "{", "if", ...
// setupConsulSyncer creates Server-mode consul.Syncer which periodically // executes callbacks on a fixed interval.
[ "setupConsulSyncer", "creates", "Server", "-", "mode", "consul", ".", "Syncer", "which", "periodically", "executes", "callbacks", "on", "a", "fixed", "interval", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L889-L897
132,936
hashicorp/nomad
nomad/server.go
setupDeploymentWatcher
func (s *Server) setupDeploymentWatcher() error { // Create the raft shim type to restrict the set of raft methods that can be // made raftShim := &deploymentWatcherRaftShim{ apply: s.raftApply, } // Create the deployment watcher s.deploymentWatcher = deploymentwatcher.NewDeploymentsWatcher( s.logger, raftS...
go
func (s *Server) setupDeploymentWatcher() error { // Create the raft shim type to restrict the set of raft methods that can be // made raftShim := &deploymentWatcherRaftShim{ apply: s.raftApply, } // Create the deployment watcher s.deploymentWatcher = deploymentwatcher.NewDeploymentsWatcher( s.logger, raftS...
[ "func", "(", "s", "*", "Server", ")", "setupDeploymentWatcher", "(", ")", "error", "{", "// Create the raft shim type to restrict the set of raft methods that can be", "// made", "raftShim", ":=", "&", "deploymentWatcherRaftShim", "{", "apply", ":", "s", ".", "raftApply",...
// setupDeploymentWatcher creates a deployment watcher that consumes the RPC // endpoints for state information and makes transitions via Raft through a // shim that provides the appropriate methods.
[ "setupDeploymentWatcher", "creates", "a", "deployment", "watcher", "that", "consumes", "the", "RPC", "endpoints", "for", "state", "information", "and", "makes", "transitions", "via", "Raft", "through", "a", "shim", "that", "provides", "the", "appropriate", "methods"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L902-L917
132,937
hashicorp/nomad
nomad/server.go
setupNodeDrainer
func (s *Server) setupNodeDrainer() { // Create a shim around Raft requests shim := drainerShim{s} c := &drainer.NodeDrainerConfig{ Logger: s.logger, Raft: shim, JobFactory: drainer.GetDrainingJobWatcher, NodeFactory: drainer.GetNodeWatcherFactory(), Dra...
go
func (s *Server) setupNodeDrainer() { // Create a shim around Raft requests shim := drainerShim{s} c := &drainer.NodeDrainerConfig{ Logger: s.logger, Raft: shim, JobFactory: drainer.GetDrainingJobWatcher, NodeFactory: drainer.GetNodeWatcherFactory(), Dra...
[ "func", "(", "s", "*", "Server", ")", "setupNodeDrainer", "(", ")", "{", "// Create a shim around Raft requests", "shim", ":=", "drainerShim", "{", "s", "}", "\n", "c", ":=", "&", "drainer", ".", "NodeDrainerConfig", "{", "Logger", ":", "s", ".", "logger", ...
// setupNodeDrainer creates a node drainer which will be enabled when a server // becomes a leader.
[ "setupNodeDrainer", "creates", "a", "node", "drainer", "which", "will", "be", "enabled", "when", "a", "server", "becomes", "a", "leader", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L921-L934
132,938
hashicorp/nomad
nomad/server.go
setupVaultClient
func (s *Server) setupVaultClient() error { v, err := NewVaultClient(s.config.VaultConfig, s.logger, s.purgeVaultAccessors) if err != nil { return err } s.vault = v return nil }
go
func (s *Server) setupVaultClient() error { v, err := NewVaultClient(s.config.VaultConfig, s.logger, s.purgeVaultAccessors) if err != nil { return err } s.vault = v return nil }
[ "func", "(", "s", "*", "Server", ")", "setupVaultClient", "(", ")", "error", "{", "v", ",", "err", ":=", "NewVaultClient", "(", "s", ".", "config", ".", "VaultConfig", ",", "s", ".", "logger", ",", "s", ".", "purgeVaultAccessors", ")", "\n", "if", "e...
// setupVaultClient is used to set up the Vault API client.
[ "setupVaultClient", "is", "used", "to", "set", "up", "the", "Vault", "API", "client", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L937-L944
132,939
hashicorp/nomad
nomad/server.go
setupWorkers
func (s *Server) setupWorkers() error { // Check if all the schedulers are disabled if len(s.config.EnabledSchedulers) == 0 || s.config.NumSchedulers == 0 { s.logger.Warn("no enabled schedulers") return nil } // Check if the core scheduler is not enabled foundCore := false for _, sched := range s.config.Enab...
go
func (s *Server) setupWorkers() error { // Check if all the schedulers are disabled if len(s.config.EnabledSchedulers) == 0 || s.config.NumSchedulers == 0 { s.logger.Warn("no enabled schedulers") return nil } // Check if the core scheduler is not enabled foundCore := false for _, sched := range s.config.Enab...
[ "func", "(", "s", "*", "Server", ")", "setupWorkers", "(", ")", "error", "{", "// Check if all the schedulers are disabled", "if", "len", "(", "s", ".", "config", ".", "EnabledSchedulers", ")", "==", "0", "||", "s", ".", "config", ".", "NumSchedulers", "==",...
// setupWorkers is used to start the scheduling workers
[ "setupWorkers", "is", "used", "to", "start", "the", "scheduling", "workers" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1285-L1318
132,940
hashicorp/nomad
nomad/server.go
numPeers
func (s *Server) numPeers() (int, error) { future := s.raft.GetConfiguration() if err := future.Error(); err != nil { return 0, err } configuration := future.Configuration() return len(configuration.Servers), nil }
go
func (s *Server) numPeers() (int, error) { future := s.raft.GetConfiguration() if err := future.Error(); err != nil { return 0, err } configuration := future.Configuration() return len(configuration.Servers), nil }
[ "func", "(", "s", "*", "Server", ")", "numPeers", "(", ")", "(", "int", ",", "error", ")", "{", "future", ":=", "s", ".", "raft", ".", "GetConfiguration", "(", ")", "\n", "if", "err", ":=", "future", ".", "Error", "(", ")", ";", "err", "!=", "n...
// numPeers is used to check on the number of known peers, including the local // node.
[ "numPeers", "is", "used", "to", "check", "on", "the", "number", "of", "known", "peers", "including", "the", "local", "node", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1322-L1329
132,941
hashicorp/nomad
nomad/server.go
Join
func (s *Server) Join(addrs []string) (int, error) { return s.serf.Join(addrs, true) }
go
func (s *Server) Join(addrs []string) (int, error) { return s.serf.Join(addrs, true) }
[ "func", "(", "s", "*", "Server", ")", "Join", "(", "addrs", "[", "]", "string", ")", "(", "int", ",", "error", ")", "{", "return", "s", ".", "serf", ".", "Join", "(", "addrs", ",", "true", ")", "\n", "}" ]
// Join is used to have Nomad join the gossip ring // The target address should be another node listening on the // Serf address
[ "Join", "is", "used", "to", "have", "Nomad", "join", "the", "gossip", "ring", "The", "target", "address", "should", "be", "another", "node", "listening", "on", "the", "Serf", "address" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1339-L1341
132,942
hashicorp/nomad
nomad/server.go
setLeaderAcl
func (s *Server) setLeaderAcl(token string) { s.leaderAclLock.Lock() s.leaderAcl = token s.leaderAclLock.Unlock() }
go
func (s *Server) setLeaderAcl(token string) { s.leaderAclLock.Lock() s.leaderAcl = token s.leaderAclLock.Unlock() }
[ "func", "(", "s", "*", "Server", ")", "setLeaderAcl", "(", "token", "string", ")", "{", "s", ".", "leaderAclLock", ".", "Lock", "(", ")", "\n", "s", ".", "leaderAcl", "=", "token", "\n", "s", ".", "leaderAclLock", ".", "Unlock", "(", ")", "\n", "}"...
// setLeaderAcl stores the given ACL token as the current leader's ACL token.
[ "setLeaderAcl", "stores", "the", "given", "ACL", "token", "as", "the", "current", "leader", "s", "ACL", "token", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1375-L1379
132,943
hashicorp/nomad
nomad/server.go
getLeaderAcl
func (s *Server) getLeaderAcl() string { s.leaderAclLock.Lock() defer s.leaderAclLock.Unlock() return s.leaderAcl }
go
func (s *Server) getLeaderAcl() string { s.leaderAclLock.Lock() defer s.leaderAclLock.Unlock() return s.leaderAcl }
[ "func", "(", "s", "*", "Server", ")", "getLeaderAcl", "(", ")", "string", "{", "s", ".", "leaderAclLock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "leaderAclLock", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "leaderAcl", "\n", "}" ]
// getLeaderAcl retrieves the leader's ACL token
[ "getLeaderAcl", "retrieves", "the", "leader", "s", "ACL", "token" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1382-L1386
132,944
hashicorp/nomad
nomad/server.go
Regions
func (s *Server) Regions() []string { s.peerLock.RLock() defer s.peerLock.RUnlock() regions := make([]string, 0, len(s.peers)) for region := range s.peers { regions = append(regions, region) } sort.Strings(regions) return regions }
go
func (s *Server) Regions() []string { s.peerLock.RLock() defer s.peerLock.RUnlock() regions := make([]string, 0, len(s.peers)) for region := range s.peers { regions = append(regions, region) } sort.Strings(regions) return regions }
[ "func", "(", "s", "*", "Server", ")", "Regions", "(", ")", "[", "]", "string", "{", "s", ".", "peerLock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "peerLock", ".", "RUnlock", "(", ")", "\n\n", "regions", ":=", "make", "(", "[", "]", "st...
// Regions returns the known regions in the cluster.
[ "Regions", "returns", "the", "known", "regions", "in", "the", "cluster", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1389-L1399
132,945
hashicorp/nomad
nomad/server.go
StreamingRpcHandler
func (s *Server) StreamingRpcHandler(method string) (structs.StreamingRpcHandler, error) { return s.streamingRpcs.GetHandler(method) }
go
func (s *Server) StreamingRpcHandler(method string) (structs.StreamingRpcHandler, error) { return s.streamingRpcs.GetHandler(method) }
[ "func", "(", "s", "*", "Server", ")", "StreamingRpcHandler", "(", "method", "string", ")", "(", "structs", ".", "StreamingRpcHandler", ",", "error", ")", "{", "return", "s", ".", "streamingRpcs", ".", "GetHandler", "(", "method", ")", "\n", "}" ]
// StreamingRpcHandler is used to make a streaming RPC call.
[ "StreamingRpcHandler", "is", "used", "to", "make", "a", "streaming", "RPC", "call", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/server.go#L1415-L1417
132,946
hashicorp/nomad
nomad/drainer/draining_node.go
DeadlineTime
func (n *drainingNode) DeadlineTime() (bool, time.Time) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return false, time.Time{} } return n.node.DrainStrategy.DeadlineTime() }
go
func (n *drainingNode) DeadlineTime() (bool, time.Time) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return false, time.Time{} } return n.node.DrainStrategy.DeadlineTime() }
[ "func", "(", "n", "*", "drainingNode", ")", "DeadlineTime", "(", ")", "(", "bool", ",", "time", ".", "Time", ")", "{", "n", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "n", ".", "l", ".", "RUnlock", "(", ")", "\n\n", "// Should never happen", ...
// DeadlineTime returns if the node has a deadline and if so what it is
[ "DeadlineTime", "returns", "if", "the", "node", "has", "a", "deadline", "and", "if", "so", "what", "it", "is" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/draining_node.go#L38-L48
132,947
hashicorp/nomad
nomad/drainer/draining_node.go
IsDone
func (n *drainingNode) IsDone() (bool, error) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return false, fmt.Errorf("node doesn't have a drain strategy set") } // Retrieve the allocs on the node allocs, err := n.state.AllocsByNode(nil, n.node.ID) ...
go
func (n *drainingNode) IsDone() (bool, error) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return false, fmt.Errorf("node doesn't have a drain strategy set") } // Retrieve the allocs on the node allocs, err := n.state.AllocsByNode(nil, n.node.ID) ...
[ "func", "(", "n", "*", "drainingNode", ")", "IsDone", "(", ")", "(", "bool", ",", "error", ")", "{", "n", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "n", ".", "l", ".", "RUnlock", "(", ")", "\n\n", "// Should never happen", "if", "n", ".", ...
// IsDone returns if the node is done draining batch and service allocs. System // allocs must be stopped before marking drain complete unless they're being // ignored.
[ "IsDone", "returns", "if", "the", "node", "is", "done", "draining", "batch", "and", "service", "allocs", ".", "System", "allocs", "must", "be", "stopped", "before", "marking", "drain", "complete", "unless", "they", "re", "being", "ignored", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/draining_node.go#L53-L82
132,948
hashicorp/nomad
nomad/drainer/draining_node.go
RemainingAllocs
func (n *drainingNode) RemainingAllocs() ([]*structs.Allocation, error) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return nil, fmt.Errorf("node doesn't have a drain strategy set") } // Grab the relevant drain info ignoreSystem := n.node.DrainStr...
go
func (n *drainingNode) RemainingAllocs() ([]*structs.Allocation, error) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return nil, fmt.Errorf("node doesn't have a drain strategy set") } // Grab the relevant drain info ignoreSystem := n.node.DrainStr...
[ "func", "(", "n", "*", "drainingNode", ")", "RemainingAllocs", "(", ")", "(", "[", "]", "*", "structs", ".", "Allocation", ",", "error", ")", "{", "n", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "n", ".", "l", ".", "RUnlock", "(", ")", "\...
// RemainingAllocs returns the set of allocations remaining on a node that // still need to be drained.
[ "RemainingAllocs", "returns", "the", "set", "of", "allocations", "remaining", "on", "a", "node", "that", "still", "need", "to", "be", "drained", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/draining_node.go#L86-L120
132,949
hashicorp/nomad
nomad/drainer/draining_node.go
DrainingJobs
func (n *drainingNode) DrainingJobs() ([]structs.NamespacedID, error) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return nil, fmt.Errorf("node doesn't have a drain strategy set") } // Retrieve the allocs on the node allocs, err := n.state.AllocsB...
go
func (n *drainingNode) DrainingJobs() ([]structs.NamespacedID, error) { n.l.RLock() defer n.l.RUnlock() // Should never happen if n.node == nil || n.node.DrainStrategy == nil { return nil, fmt.Errorf("node doesn't have a drain strategy set") } // Retrieve the allocs on the node allocs, err := n.state.AllocsB...
[ "func", "(", "n", "*", "drainingNode", ")", "DrainingJobs", "(", ")", "(", "[", "]", "structs", ".", "NamespacedID", ",", "error", ")", "{", "n", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "n", ".", "l", ".", "RUnlock", "(", ")", "\n\n", ...
// DrainingJobs returns the set of jobs on the node that can block a drain. // These include batch and service jobs.
[ "DrainingJobs", "returns", "the", "set", "of", "jobs", "on", "the", "node", "that", "can", "block", "a", "drain", ".", "These", "include", "batch", "and", "service", "jobs", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/draining_node.go#L124-L155
132,950
hashicorp/nomad
client/logmon/logging/syslog_server.go
NewSyslogServer
func NewSyslogServer(l net.Listener, messages chan *SyslogMessage, logger hclog.Logger) *SyslogServer { logger = logger.Named("logcollector.server") parser := NewDockerLogParser(logger) return &SyslogServer{ listener: l, messages: messages, parser: parser, logger: logger, doneCh: make(chan interface{...
go
func NewSyslogServer(l net.Listener, messages chan *SyslogMessage, logger hclog.Logger) *SyslogServer { logger = logger.Named("logcollector.server") parser := NewDockerLogParser(logger) return &SyslogServer{ listener: l, messages: messages, parser: parser, logger: logger, doneCh: make(chan interface{...
[ "func", "NewSyslogServer", "(", "l", "net", ".", "Listener", ",", "messages", "chan", "*", "SyslogMessage", ",", "logger", "hclog", ".", "Logger", ")", "*", "SyslogServer", "{", "logger", "=", "logger", ".", "Named", "(", "\"", "\"", ")", "\n", "parser",...
// NewSyslogServer creates a new syslog server
[ "NewSyslogServer", "creates", "a", "new", "syslog", "server" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_server.go#L25-L35
132,951
hashicorp/nomad
client/logmon/logging/syslog_server.go
Start
func (s *SyslogServer) Start() { for { select { case <-s.doneCh: return default: connection, err := s.listener.Accept() if err != nil { s.doneLock.Lock() done := s.done s.doneLock.Unlock() if done { return } s.logger.Error("error in accepting connection", "err", err) co...
go
func (s *SyslogServer) Start() { for { select { case <-s.doneCh: return default: connection, err := s.listener.Accept() if err != nil { s.doneLock.Lock() done := s.done s.doneLock.Unlock() if done { return } s.logger.Error("error in accepting connection", "err", err) co...
[ "func", "(", "s", "*", "SyslogServer", ")", "Start", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "s", ".", "doneCh", ":", "return", "\n", "default", ":", "connection", ",", "err", ":=", "s", ".", "listener", ".", "Accept", "(", ")", "...
// Start starts accepting syslog connections
[ "Start", "starts", "accepting", "syslog", "connections" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_server.go#L38-L59
132,952
hashicorp/nomad
client/logmon/logging/syslog_server.go
read
func (s *SyslogServer) read(connection net.Conn) { defer connection.Close() scanner := bufio.NewScanner(bufio.NewReader(connection)) for { select { case <-s.doneCh: return default: } if scanner.Scan() { b := scanner.Bytes() msg := s.parser.Parse(b) s.messages <- msg } else { return } }...
go
func (s *SyslogServer) read(connection net.Conn) { defer connection.Close() scanner := bufio.NewScanner(bufio.NewReader(connection)) for { select { case <-s.doneCh: return default: } if scanner.Scan() { b := scanner.Bytes() msg := s.parser.Parse(b) s.messages <- msg } else { return } }...
[ "func", "(", "s", "*", "SyslogServer", ")", "read", "(", "connection", "net", ".", "Conn", ")", "{", "defer", "connection", ".", "Close", "(", ")", "\n", "scanner", ":=", "bufio", ".", "NewScanner", "(", "bufio", ".", "NewReader", "(", "connection", ")...
// read reads the bytes from a connection
[ "read", "reads", "the", "bytes", "from", "a", "connection" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_server.go#L62-L80
132,953
hashicorp/nomad
client/logmon/logging/syslog_server.go
Shutdown
func (s *SyslogServer) Shutdown() { s.doneLock.Lock() defer s.doneLock.Unlock() if !s.done { close(s.doneCh) close(s.messages) s.done = true s.listener.Close() } }
go
func (s *SyslogServer) Shutdown() { s.doneLock.Lock() defer s.doneLock.Unlock() if !s.done { close(s.doneCh) close(s.messages) s.done = true s.listener.Close() } }
[ "func", "(", "s", "*", "SyslogServer", ")", "Shutdown", "(", ")", "{", "s", ".", "doneLock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "doneLock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "s", ".", "done", "{", "close", "(", "s", ".", ...
// Shutdown the syslog server
[ "Shutdown", "the", "syslog", "server" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/syslog_server.go#L83-L93
132,954
hashicorp/nomad
client/logmon/logging/rotator.go
NewFileRotator
func NewFileRotator(path string, baseFile string, maxFiles int, fileSize int64, logger hclog.Logger) (*FileRotator, error) { logger = logger.Named("rotator") rotator := &FileRotator{ MaxFiles: maxFiles, FileSize: fileSize, path: path, baseFileName: baseFile, flushTicker: time.NewTicker(bufferFlus...
go
func NewFileRotator(path string, baseFile string, maxFiles int, fileSize int64, logger hclog.Logger) (*FileRotator, error) { logger = logger.Named("rotator") rotator := &FileRotator{ MaxFiles: maxFiles, FileSize: fileSize, path: path, baseFileName: baseFile, flushTicker: time.NewTicker(bufferFlus...
[ "func", "NewFileRotator", "(", "path", "string", ",", "baseFile", "string", ",", "maxFiles", "int", ",", "fileSize", "int64", ",", "logger", "hclog", ".", "Logger", ")", "(", "*", "FileRotator", ",", "error", ")", "{", "logger", "=", "logger", ".", "Name...
// NewFileRotator returns a new file rotator
[ "NewFileRotator", "returns", "a", "new", "file", "rotator" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L61-L83
132,955
hashicorp/nomad
client/logmon/logging/rotator.go
Write
func (f *FileRotator) Write(p []byte) (n int, err error) { n = 0 var forceRotate bool for n < len(p) { // Check if we still have space in the current file, otherwise close and // open the next file if forceRotate || f.currentWr >= f.FileSize { forceRotate = false f.flushBuffer() f.currentFile.Close()...
go
func (f *FileRotator) Write(p []byte) (n int, err error) { n = 0 var forceRotate bool for n < len(p) { // Check if we still have space in the current file, otherwise close and // open the next file if forceRotate || f.currentWr >= f.FileSize { forceRotate = false f.flushBuffer() f.currentFile.Close()...
[ "func", "(", "f", "*", "FileRotator", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", "=", "0", "\n", "var", "forceRotate", "bool", "\n\n", "for", "n", "<", "len", "(", "p", ")", "{", "// Ch...
// Write writes a byte array to a file and rotates the file if it's size becomes // equal to the maximum size the user has defined.
[ "Write", "writes", "a", "byte", "array", "to", "a", "file", "and", "rotates", "the", "file", "if", "it", "s", "size", "becomes", "equal", "to", "the", "maximum", "size", "the", "user", "has", "defined", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L87-L158
132,956
hashicorp/nomad
client/logmon/logging/rotator.go
nextFile
func (f *FileRotator) nextFile() error { nextFileIdx := f.logFileIdx for { nextFileIdx += 1 logFileName := filepath.Join(f.path, fmt.Sprintf("%s.%d", f.baseFileName, nextFileIdx)) if fi, err := os.Stat(logFileName); err == nil { if fi.IsDir() || fi.Size() >= f.FileSize { continue } } f.logFileIdx ...
go
func (f *FileRotator) nextFile() error { nextFileIdx := f.logFileIdx for { nextFileIdx += 1 logFileName := filepath.Join(f.path, fmt.Sprintf("%s.%d", f.baseFileName, nextFileIdx)) if fi, err := os.Stat(logFileName); err == nil { if fi.IsDir() || fi.Size() >= f.FileSize { continue } } f.logFileIdx ...
[ "func", "(", "f", "*", "FileRotator", ")", "nextFile", "(", ")", "error", "{", "nextFileIdx", ":=", "f", ".", "logFileIdx", "\n", "for", "{", "nextFileIdx", "+=", "1", "\n", "logFileName", ":=", "filepath", ".", "Join", "(", "f", ".", "path", ",", "f...
// nextFile opens the next file and purges older files if the number of rotated // files is larger than the maximum files configured by the user
[ "nextFile", "opens", "the", "next", "file", "and", "purges", "older", "files", "if", "the", "number", "of", "rotated", "files", "is", "larger", "than", "the", "maximum", "files", "configured", "by", "the", "user" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L162-L188
132,957
hashicorp/nomad
client/logmon/logging/rotator.go
lastFile
func (f *FileRotator) lastFile() error { finfos, err := ioutil.ReadDir(f.path) if err != nil { return err } prefix := fmt.Sprintf("%s.", f.baseFileName) for _, fi := range finfos { if fi.IsDir() { continue } if strings.HasPrefix(fi.Name(), prefix) { fileIdx := strings.TrimPrefix(fi.Name(), prefix) ...
go
func (f *FileRotator) lastFile() error { finfos, err := ioutil.ReadDir(f.path) if err != nil { return err } prefix := fmt.Sprintf("%s.", f.baseFileName) for _, fi := range finfos { if fi.IsDir() { continue } if strings.HasPrefix(fi.Name(), prefix) { fileIdx := strings.TrimPrefix(fi.Name(), prefix) ...
[ "func", "(", "f", "*", "FileRotator", ")", "lastFile", "(", ")", "error", "{", "finfos", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "f", ".", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "prefix", ":...
// lastFile finds out the rotated file with the largest index in a path.
[ "lastFile", "finds", "out", "the", "rotated", "file", "with", "the", "largest", "index", "in", "a", "path", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L191-L217
132,958
hashicorp/nomad
client/logmon/logging/rotator.go
createFile
func (f *FileRotator) createFile() error { logFileName := filepath.Join(f.path, fmt.Sprintf("%s.%d", f.baseFileName, f.logFileIdx)) cFile, err := os.OpenFile(logFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) if err != nil { return err } f.currentFile = cFile fi, err := f.currentFile.Stat() if err != nil {...
go
func (f *FileRotator) createFile() error { logFileName := filepath.Join(f.path, fmt.Sprintf("%s.%d", f.baseFileName, f.logFileIdx)) cFile, err := os.OpenFile(logFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) if err != nil { return err } f.currentFile = cFile fi, err := f.currentFile.Stat() if err != nil {...
[ "func", "(", "f", "*", "FileRotator", ")", "createFile", "(", ")", "error", "{", "logFileName", ":=", "filepath", ".", "Join", "(", "f", ".", "path", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "f", ".", "baseFileName", ",", "f", ".", "logFil...
// createFile opens a new or existing file for writing
[ "createFile", "opens", "a", "new", "or", "existing", "file", "for", "writing" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L220-L235
132,959
hashicorp/nomad
client/logmon/logging/rotator.go
purgeOldFiles
func (f *FileRotator) purgeOldFiles() { for { select { case <-f.purgeCh: var fIndexes []int files, err := ioutil.ReadDir(f.path) if err != nil { f.logger.Error("error getting directory listing", "err", err) return } // Inserting all the rotated files in a slice for _, fi := range files { ...
go
func (f *FileRotator) purgeOldFiles() { for { select { case <-f.purgeCh: var fIndexes []int files, err := ioutil.ReadDir(f.path) if err != nil { f.logger.Error("error getting directory listing", "err", err) return } // Inserting all the rotated files in a slice for _, fi := range files { ...
[ "func", "(", "f", "*", "FileRotator", ")", "purgeOldFiles", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "f", ".", "purgeCh", ":", "var", "fIndexes", "[", "]", "int", "\n", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "f", ...
// purgeOldFiles removes older files and keeps only the last N files rotated for // a file
[ "purgeOldFiles", "removes", "older", "files", "and", "keeps", "only", "the", "last", "N", "files", "rotated", "for", "a", "file" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L263-L308
132,960
hashicorp/nomad
client/logmon/logging/rotator.go
flushBuffer
func (f *FileRotator) flushBuffer() error { f.bufLock.Lock() defer f.bufLock.Unlock() if f.bufw != nil { return f.bufw.Flush() } return nil }
go
func (f *FileRotator) flushBuffer() error { f.bufLock.Lock() defer f.bufLock.Unlock() if f.bufw != nil { return f.bufw.Flush() } return nil }
[ "func", "(", "f", "*", "FileRotator", ")", "flushBuffer", "(", ")", "error", "{", "f", ".", "bufLock", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "bufLock", ".", "Unlock", "(", ")", "\n", "if", "f", ".", "bufw", "!=", "nil", "{", "return", ...
// flushBuffer flushes the buffer
[ "flushBuffer", "flushes", "the", "buffer" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L311-L318
132,961
hashicorp/nomad
client/logmon/logging/rotator.go
writeToBuffer
func (f *FileRotator) writeToBuffer(p []byte) (int, error) { f.bufLock.Lock() defer f.bufLock.Unlock() return f.bufw.Write(p) }
go
func (f *FileRotator) writeToBuffer(p []byte) (int, error) { f.bufLock.Lock() defer f.bufLock.Unlock() return f.bufw.Write(p) }
[ "func", "(", "f", "*", "FileRotator", ")", "writeToBuffer", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "f", ".", "bufLock", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "bufLock", ".", "Unlock", "(", ")", "\n", "ret...
// writeToBuffer writes the byte array to buffer
[ "writeToBuffer", "writes", "the", "byte", "array", "to", "buffer" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L321-L325
132,962
hashicorp/nomad
client/logmon/logging/rotator.go
createOrResetBuffer
func (f *FileRotator) createOrResetBuffer() { f.bufLock.Lock() defer f.bufLock.Unlock() if f.bufw == nil { f.bufw = bufio.NewWriterSize(f.currentFile, logBufferSize) } else { f.bufw.Reset(f.currentFile) } }
go
func (f *FileRotator) createOrResetBuffer() { f.bufLock.Lock() defer f.bufLock.Unlock() if f.bufw == nil { f.bufw = bufio.NewWriterSize(f.currentFile, logBufferSize) } else { f.bufw.Reset(f.currentFile) } }
[ "func", "(", "f", "*", "FileRotator", ")", "createOrResetBuffer", "(", ")", "{", "f", ".", "bufLock", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "bufLock", ".", "Unlock", "(", ")", "\n", "if", "f", ".", "bufw", "==", "nil", "{", "f", ".", ...
// createOrResetBuffer creates a new buffer if we don't have one otherwise // resets the buffer
[ "createOrResetBuffer", "creates", "a", "new", "buffer", "if", "we", "don", "t", "have", "one", "otherwise", "resets", "the", "buffer" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/rotator.go#L329-L337
132,963
hashicorp/nomad
drivers/docker/coordinator.go
newDockerCoordinator
func newDockerCoordinator(config *dockerCoordinatorConfig) *dockerCoordinator { if config.client == nil { return nil } return &dockerCoordinator{ dockerCoordinatorConfig: config, pullFutures: make(map[string]*pullFuture), pullLoggers: make(map[string][]LogEventFn), imageRefCount: ...
go
func newDockerCoordinator(config *dockerCoordinatorConfig) *dockerCoordinator { if config.client == nil { return nil } return &dockerCoordinator{ dockerCoordinatorConfig: config, pullFutures: make(map[string]*pullFuture), pullLoggers: make(map[string][]LogEventFn), imageRefCount: ...
[ "func", "newDockerCoordinator", "(", "config", "*", "dockerCoordinatorConfig", ")", "*", "dockerCoordinator", "{", "if", "config", ".", "client", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "dockerCoordinator", "{", "dockerCoordinatorConfi...
// newDockerCoordinator returns a new Docker coordinator
[ "newDockerCoordinator", "returns", "a", "new", "Docker", "coordinator" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L113-L125
132,964
hashicorp/nomad
drivers/docker/coordinator.go
PullImage
func (d *dockerCoordinator) PullImage(image string, authOptions *docker.AuthConfiguration, callerID string, emitFn LogEventFn) (imageID string, err error) { // Get the future d.imageLock.Lock() future, ok := d.pullFutures[image] d.registerPullLogger(image, emitFn) if !ok { // Make the future future = newPullFu...
go
func (d *dockerCoordinator) PullImage(image string, authOptions *docker.AuthConfiguration, callerID string, emitFn LogEventFn) (imageID string, err error) { // Get the future d.imageLock.Lock() future, ok := d.pullFutures[image] d.registerPullLogger(image, emitFn) if !ok { // Make the future future = newPullFu...
[ "func", "(", "d", "*", "dockerCoordinator", ")", "PullImage", "(", "image", "string", ",", "authOptions", "*", "docker", ".", "AuthConfiguration", ",", "callerID", "string", ",", "emitFn", "LogEventFn", ")", "(", "imageID", "string", ",", "err", "error", ")"...
// PullImage is used to pull an image. It returns the pulled imaged ID or an // error that occurred during the pull
[ "PullImage", "is", "used", "to", "pull", "an", "image", ".", "It", "returns", "the", "pulled", "imaged", "ID", "or", "an", "error", "that", "occurred", "during", "the", "pull" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L129-L161
132,965
hashicorp/nomad
drivers/docker/coordinator.go
pullImageImpl
func (d *dockerCoordinator) pullImageImpl(image string, authOptions *docker.AuthConfiguration, future *pullFuture) { defer d.clearPullLogger(image) // Parse the repo and tag repo, tag := parseDockerImage(image) ctx, cancel := context.WithCancel(context.Background()) defer cancel() pm := newImageProgressManager(i...
go
func (d *dockerCoordinator) pullImageImpl(image string, authOptions *docker.AuthConfiguration, future *pullFuture) { defer d.clearPullLogger(image) // Parse the repo and tag repo, tag := parseDockerImage(image) ctx, cancel := context.WithCancel(context.Background()) defer cancel() pm := newImageProgressManager(i...
[ "func", "(", "d", "*", "dockerCoordinator", ")", "pullImageImpl", "(", "image", "string", ",", "authOptions", "*", "docker", ".", "AuthConfiguration", ",", "future", "*", "pullFuture", ")", "{", "defer", "d", ".", "clearPullLogger", "(", "image", ")", "\n", ...
// pullImageImpl is the implementation of pulling an image. The results are // returned via the passed future
[ "pullImageImpl", "is", "the", "implementation", "of", "pulling", "an", "image", ".", "The", "results", "are", "returned", "via", "the", "passed", "future" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L165-L216
132,966
hashicorp/nomad
drivers/docker/coordinator.go
IncrementImageReference
func (d *dockerCoordinator) IncrementImageReference(imageID, imageName, callerID string) { d.imageLock.Lock() defer d.imageLock.Unlock() if d.cleanup { d.incrementImageReferenceImpl(imageID, imageName, callerID) } }
go
func (d *dockerCoordinator) IncrementImageReference(imageID, imageName, callerID string) { d.imageLock.Lock() defer d.imageLock.Unlock() if d.cleanup { d.incrementImageReferenceImpl(imageID, imageName, callerID) } }
[ "func", "(", "d", "*", "dockerCoordinator", ")", "IncrementImageReference", "(", "imageID", ",", "imageName", ",", "callerID", "string", ")", "{", "d", ".", "imageLock", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "imageLock", ".", "Unlock", "(", ")"...
// IncrementImageReference is used to increment an image reference count
[ "IncrementImageReference", "is", "used", "to", "increment", "an", "image", "reference", "count" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L219-L225
132,967
hashicorp/nomad
drivers/docker/coordinator.go
incrementImageReferenceImpl
func (d *dockerCoordinator) incrementImageReferenceImpl(imageID, imageName, callerID string) { // Cancel any pending delete if cancel, ok := d.deleteFuture[imageID]; ok { d.logger.Debug("cancelling removal of container image", "image_name", imageName) cancel() delete(d.deleteFuture, imageID) } // Increment t...
go
func (d *dockerCoordinator) incrementImageReferenceImpl(imageID, imageName, callerID string) { // Cancel any pending delete if cancel, ok := d.deleteFuture[imageID]; ok { d.logger.Debug("cancelling removal of container image", "image_name", imageName) cancel() delete(d.deleteFuture, imageID) } // Increment t...
[ "func", "(", "d", "*", "dockerCoordinator", ")", "incrementImageReferenceImpl", "(", "imageID", ",", "imageName", ",", "callerID", "string", ")", "{", "// Cancel any pending delete", "if", "cancel", ",", "ok", ":=", "d", ".", "deleteFuture", "[", "imageID", "]",...
// incrementImageReferenceImpl assumes the lock is held
[ "incrementImageReferenceImpl", "assumes", "the", "lock", "is", "held" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L228-L247
132,968
hashicorp/nomad
drivers/docker/coordinator.go
RemoveImage
func (d *dockerCoordinator) RemoveImage(imageID, callerID string) { d.imageLock.Lock() defer d.imageLock.Unlock() if !d.cleanup { return } references, ok := d.imageRefCount[imageID] if !ok { d.logger.Warn("RemoveImage on non-referenced counted image id", "image_id", imageID) return } // Decrement the r...
go
func (d *dockerCoordinator) RemoveImage(imageID, callerID string) { d.imageLock.Lock() defer d.imageLock.Unlock() if !d.cleanup { return } references, ok := d.imageRefCount[imageID] if !ok { d.logger.Warn("RemoveImage on non-referenced counted image id", "image_id", imageID) return } // Decrement the r...
[ "func", "(", "d", "*", "dockerCoordinator", ")", "RemoveImage", "(", "imageID", ",", "callerID", "string", ")", "{", "d", ".", "imageLock", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "imageLock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "d", ...
// RemoveImage removes the given image. If there are any errors removing the // image, the remove is retried internally.
[ "RemoveImage", "removes", "the", "given", "image", ".", "If", "there", "are", "any", "errors", "removing", "the", "image", "the", "remove", "is", "retried", "internally", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L251-L289
132,969
hashicorp/nomad
drivers/docker/coordinator.go
removeImageImpl
func (d *dockerCoordinator) removeImageImpl(id string, ctx context.Context) { // Wait for the delay or a cancellation event select { case <-ctx.Done(): // We have been cancelled return case <-time.After(d.removeDelay): } // Ensure we are suppose to delete. Do a short check while holding the lock // so there...
go
func (d *dockerCoordinator) removeImageImpl(id string, ctx context.Context) { // Wait for the delay or a cancellation event select { case <-ctx.Done(): // We have been cancelled return case <-time.After(d.removeDelay): } // Ensure we are suppose to delete. Do a short check while holding the lock // so there...
[ "func", "(", "d", "*", "dockerCoordinator", ")", "removeImageImpl", "(", "id", "string", ",", "ctx", "context", ".", "Context", ")", "{", "// Wait for the delay or a cancellation event", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "// We ha...
// removeImageImpl is used to remove an image. It wil wait the specified remove // delay to remove the image. If the context is cancelled before that the image // removal will be cancelled.
[ "removeImageImpl", "is", "used", "to", "remove", "an", "image", ".", "It", "wil", "wait", "the", "specified", "remove", "delay", "to", "remove", "the", "image", ".", "If", "the", "context", "is", "cancelled", "before", "that", "the", "image", "removal", "w...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L294-L352
132,970
hashicorp/nomad
drivers/docker/coordinator.go
recoverablePullError
func recoverablePullError(err error, image string) error { recoverable := true if imageNotFoundMatcher.MatchString(err.Error()) { recoverable = false } return structs.NewRecoverableError(fmt.Errorf("Failed to pull `%s`: %s", image, err), recoverable) }
go
func recoverablePullError(err error, image string) error { recoverable := true if imageNotFoundMatcher.MatchString(err.Error()) { recoverable = false } return structs.NewRecoverableError(fmt.Errorf("Failed to pull `%s`: %s", image, err), recoverable) }
[ "func", "recoverablePullError", "(", "err", "error", ",", "image", "string", ")", "error", "{", "recoverable", ":=", "true", "\n", "if", "imageNotFoundMatcher", ".", "MatchString", "(", "err", ".", "Error", "(", ")", ")", "{", "recoverable", "=", "false", ...
// recoverablePullError wraps the error gotten when trying to pull and image if // the error is recoverable.
[ "recoverablePullError", "wraps", "the", "error", "gotten", "when", "trying", "to", "pull", "and", "image", "if", "the", "error", "is", "recoverable", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/coordinator.go#L394-L400
132,971
hashicorp/nomad
plugins/shared/structs/util.go
CopyMapStringAttribute
func CopyMapStringAttribute(in map[string]*Attribute) map[string]*Attribute { if in == nil { return nil } out := make(map[string]*Attribute, len(in)) for k, v := range in { out[k] = v.Copy() } return out }
go
func CopyMapStringAttribute(in map[string]*Attribute) map[string]*Attribute { if in == nil { return nil } out := make(map[string]*Attribute, len(in)) for k, v := range in { out[k] = v.Copy() } return out }
[ "func", "CopyMapStringAttribute", "(", "in", "map", "[", "string", "]", "*", "Attribute", ")", "map", "[", "string", "]", "*", "Attribute", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "map", "[", ...
// CopyMapStringAttribute copies a map of string to Attribute
[ "CopyMapStringAttribute", "copies", "a", "map", "of", "string", "to", "Attribute" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/util.go#L94-L104
132,972
hashicorp/nomad
plugins/shared/structs/util.go
ConvertProtoStatObject
func ConvertProtoStatObject(in *proto.StatObject) *StatObject { if in == nil { return nil } out := &StatObject{ Nested: make(map[string]*StatObject, len(in.Nested)), Attributes: make(map[string]*StatValue, len(in.Attributes)), } for k, v := range in.Nested { out.Nested[k] = ConvertProtoStatObject(v) ...
go
func ConvertProtoStatObject(in *proto.StatObject) *StatObject { if in == nil { return nil } out := &StatObject{ Nested: make(map[string]*StatObject, len(in.Nested)), Attributes: make(map[string]*StatValue, len(in.Attributes)), } for k, v := range in.Nested { out.Nested[k] = ConvertProtoStatObject(v) ...
[ "func", "ConvertProtoStatObject", "(", "in", "*", "proto", ".", "StatObject", ")", "*", "StatObject", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "&", "StatObject", "{", "Nested", ":", "make", "(", "map", "[", ...
// ConvertProtoStatObject converts between a proto and struct StatObject
[ "ConvertProtoStatObject", "converts", "between", "a", "proto", "and", "struct", "StatObject" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/util.go#L107-L126
132,973
hashicorp/nomad
plugins/shared/structs/util.go
ConvertProtoStatValue
func ConvertProtoStatValue(in *proto.StatValue) *StatValue { if in == nil { return nil } return &StatValue{ FloatNumeratorVal: unwrapDouble(in.FloatNumeratorVal), FloatDenominatorVal: unwrapDouble(in.FloatDenominatorVal), IntNumeratorVal: unwrapInt64(in.IntNumeratorVal), IntDenominatorVal: unwrapI...
go
func ConvertProtoStatValue(in *proto.StatValue) *StatValue { if in == nil { return nil } return &StatValue{ FloatNumeratorVal: unwrapDouble(in.FloatNumeratorVal), FloatDenominatorVal: unwrapDouble(in.FloatDenominatorVal), IntNumeratorVal: unwrapInt64(in.IntNumeratorVal), IntDenominatorVal: unwrapI...
[ "func", "ConvertProtoStatValue", "(", "in", "*", "proto", ".", "StatValue", ")", "*", "StatValue", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "StatValue", "{", "FloatNumeratorVal", ":", "unwrapDouble", "(", "in", ...
// ConvertProtoStatValue converts between a proto and struct StatValue
[ "ConvertProtoStatValue", "converts", "between", "a", "proto", "and", "struct", "StatValue" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/util.go#L129-L144
132,974
hashicorp/nomad
plugins/shared/structs/util.go
ConvertStructStatObject
func ConvertStructStatObject(in *StatObject) *proto.StatObject { if in == nil { return nil } out := &proto.StatObject{ Nested: make(map[string]*proto.StatObject, len(in.Nested)), Attributes: make(map[string]*proto.StatValue, len(in.Attributes)), } for k, v := range in.Nested { out.Nested[k] = Convert...
go
func ConvertStructStatObject(in *StatObject) *proto.StatObject { if in == nil { return nil } out := &proto.StatObject{ Nested: make(map[string]*proto.StatObject, len(in.Nested)), Attributes: make(map[string]*proto.StatValue, len(in.Attributes)), } for k, v := range in.Nested { out.Nested[k] = Convert...
[ "func", "ConvertStructStatObject", "(", "in", "*", "StatObject", ")", "*", "proto", ".", "StatObject", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "&", "proto", ".", "StatObject", "{", "Nested", ":", "make", "(",...
// ConvertStructStatObject converts between a struct and proto StatObject
[ "ConvertStructStatObject", "converts", "between", "a", "struct", "and", "proto", "StatObject" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/util.go#L147-L166
132,975
hashicorp/nomad
plugins/shared/structs/util.go
ConvertStructStatValue
func ConvertStructStatValue(in *StatValue) *proto.StatValue { if in == nil { return nil } return &proto.StatValue{ FloatNumeratorVal: wrapDouble(in.FloatNumeratorVal), FloatDenominatorVal: wrapDouble(in.FloatDenominatorVal), IntNumeratorVal: wrapInt64(in.IntNumeratorVal), IntDenominatorVal: wrapIn...
go
func ConvertStructStatValue(in *StatValue) *proto.StatValue { if in == nil { return nil } return &proto.StatValue{ FloatNumeratorVal: wrapDouble(in.FloatNumeratorVal), FloatDenominatorVal: wrapDouble(in.FloatDenominatorVal), IntNumeratorVal: wrapInt64(in.IntNumeratorVal), IntDenominatorVal: wrapIn...
[ "func", "ConvertStructStatValue", "(", "in", "*", "StatValue", ")", "*", "proto", ".", "StatValue", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "proto", ".", "StatValue", "{", "FloatNumeratorVal", ":", "wrapDouble"...
// ConvertStructStatValue converts between a struct and proto StatValue
[ "ConvertStructStatValue", "converts", "between", "a", "struct", "and", "proto", "StatValue" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/util.go#L169-L184
132,976
hashicorp/nomad
plugins/shared/structs/util.go
unwrapDouble
func unwrapDouble(w *wrappers.DoubleValue) *float64 { if w == nil { return nil } v := w.Value return &v }
go
func unwrapDouble(w *wrappers.DoubleValue) *float64 { if w == nil { return nil } v := w.Value return &v }
[ "func", "unwrapDouble", "(", "w", "*", "wrappers", ".", "DoubleValue", ")", "*", "float64", "{", "if", "w", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "v", ":=", "w", ".", "Value", "\n", "return", "&", "v", "\n", "}" ]
// Helper functions for proto wrapping
[ "Helper", "functions", "for", "proto", "wrapping" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/util.go#L188-L195
132,977
hashicorp/nomad
drivers/shared/executor/pid_collector.go
collectPids
func (c *pidCollector) collectPids(stopCh chan interface{}, pidGetter allPidGetter) { // Fire the timer right away when the executor starts from there on the pids // are collected every scan interval timer := time.NewTimer(0) defer timer.Stop() for { select { case <-timer.C: pids, err := pidGetter() if e...
go
func (c *pidCollector) collectPids(stopCh chan interface{}, pidGetter allPidGetter) { // Fire the timer right away when the executor starts from there on the pids // are collected every scan interval timer := time.NewTimer(0) defer timer.Stop() for { select { case <-timer.C: pids, err := pidGetter() if e...
[ "func", "(", "c", "*", "pidCollector", ")", "collectPids", "(", "stopCh", "chan", "interface", "{", "}", ",", "pidGetter", "allPidGetter", ")", "{", "// Fire the timer right away when the executor starts from there on the pids", "// are collected every scan interval", "timer"...
// collectPids collects the pids of the child processes that the executor is // running every 5 seconds
[ "collectPids", "collects", "the", "pids", "of", "the", "child", "processes", "that", "the", "executor", "is", "running", "every", "5", "seconds" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/pid_collector.go#L52-L84
132,978
hashicorp/nomad
drivers/shared/executor/pid_collector.go
scanPids
func scanPids(parentPid int, allPids []ps.Process) (map[int]*nomadPid, error) { processFamily := make(map[int]struct{}) processFamily[parentPid] = struct{}{} // A mapping of pids to their parent pids. It is used to build the process // tree of the executing task pidsRemaining := make(map[int]int, len(allPids)) f...
go
func scanPids(parentPid int, allPids []ps.Process) (map[int]*nomadPid, error) { processFamily := make(map[int]struct{}) processFamily[parentPid] = struct{}{} // A mapping of pids to their parent pids. It is used to build the process // tree of the executing task pidsRemaining := make(map[int]int, len(allPids)) f...
[ "func", "scanPids", "(", "parentPid", "int", ",", "allPids", "[", "]", "ps", ".", "Process", ")", "(", "map", "[", "int", "]", "*", "nomadPid", ",", "error", ")", "{", "processFamily", ":=", "make", "(", "map", "[", "int", "]", "struct", "{", "}", ...
// scanPids scans all the pids on the machine running the current executor and // returns the child processes of the executor.
[ "scanPids", "scans", "all", "the", "pids", "on", "the", "machine", "running", "the", "current", "executor", "and", "returns", "the", "child", "processes", "of", "the", "executor", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/pid_collector.go#L88-L131
132,979
hashicorp/nomad
drivers/shared/executor/pid_collector.go
pidStats
func (c *pidCollector) pidStats() (map[string]*drivers.ResourceUsage, error) { stats := make(map[string]*drivers.ResourceUsage) c.pidLock.RLock() pids := make(map[int]*nomadPid, len(c.pids)) for k, v := range c.pids { pids[k] = v } c.pidLock.RUnlock() for pid, np := range pids { p, err := process.NewProcess(...
go
func (c *pidCollector) pidStats() (map[string]*drivers.ResourceUsage, error) { stats := make(map[string]*drivers.ResourceUsage) c.pidLock.RLock() pids := make(map[int]*nomadPid, len(c.pids)) for k, v := range c.pids { pids[k] = v } c.pidLock.RUnlock() for pid, np := range pids { p, err := process.NewProcess(...
[ "func", "(", "c", "*", "pidCollector", ")", "pidStats", "(", ")", "(", "map", "[", "string", "]", "*", "drivers", ".", "ResourceUsage", ",", "error", ")", "{", "stats", ":=", "make", "(", "map", "[", "string", "]", "*", "drivers", ".", "ResourceUsage...
// pidStats returns the resource usage stats per pid
[ "pidStats", "returns", "the", "resource", "usage", "stats", "per", "pid" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/pid_collector.go#L134-L168
132,980
hashicorp/nomad
drivers/shared/executor/pid_collector.go
aggregatedResourceUsage
func aggregatedResourceUsage(systemCpuStats *stats.CpuStats, pidStats map[string]*drivers.ResourceUsage) *drivers.TaskResourceUsage { ts := time.Now().UTC().UnixNano() var ( systemModeCPU, userModeCPU, percent float64 totalRSS, totalSwap uint64 ) for _, pidStat := range pidStats { systemModeC...
go
func aggregatedResourceUsage(systemCpuStats *stats.CpuStats, pidStats map[string]*drivers.ResourceUsage) *drivers.TaskResourceUsage { ts := time.Now().UTC().UnixNano() var ( systemModeCPU, userModeCPU, percent float64 totalRSS, totalSwap uint64 ) for _, pidStat := range pidStats { systemModeC...
[ "func", "aggregatedResourceUsage", "(", "systemCpuStats", "*", "stats", ".", "CpuStats", ",", "pidStats", "map", "[", "string", "]", "*", "drivers", ".", "ResourceUsage", ")", "*", "drivers", ".", "TaskResourceUsage", "{", "ts", ":=", "time", ".", "Now", "("...
// aggregatedResourceUsage aggregates the resource usage of all the pids and // returns a TaskResourceUsage data point
[ "aggregatedResourceUsage", "aggregates", "the", "resource", "usage", "of", "all", "the", "pids", "and", "returns", "a", "TaskResourceUsage", "data", "point" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/pid_collector.go#L172-L211
132,981
hashicorp/nomad
nomad/state/state_store.go
NewStateStore
func NewStateStore(config *StateStoreConfig) (*StateStore, error) { // Create the MemDB db, err := memdb.NewMemDB(stateStoreSchema()) if err != nil { return nil, fmt.Errorf("state store setup failed: %v", err) } // Create the state store s := &StateStore{ logger: config.Logger.Named("state_store"), db: ...
go
func NewStateStore(config *StateStoreConfig) (*StateStore, error) { // Create the MemDB db, err := memdb.NewMemDB(stateStoreSchema()) if err != nil { return nil, fmt.Errorf("state store setup failed: %v", err) } // Create the state store s := &StateStore{ logger: config.Logger.Named("state_store"), db: ...
[ "func", "NewStateStore", "(", "config", "*", "StateStoreConfig", ")", "(", "*", "StateStore", ",", "error", ")", "{", "// Create the MemDB", "db", ",", "err", ":=", "memdb", ".", "NewMemDB", "(", "stateStoreSchema", "(", ")", ")", "\n", "if", "err", "!=", ...
// NewStateStore is used to create a new state store
[ "NewStateStore", "is", "used", "to", "create", "a", "new", "state", "store" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L68-L83
132,982
hashicorp/nomad
nomad/state/state_store.go
Snapshot
func (s *StateStore) Snapshot() (*StateSnapshot, error) { snap := &StateSnapshot{ StateStore: StateStore{ logger: s.logger, config: s.config, db: s.db.Snapshot(), }, } return snap, nil }
go
func (s *StateStore) Snapshot() (*StateSnapshot, error) { snap := &StateSnapshot{ StateStore: StateStore{ logger: s.logger, config: s.config, db: s.db.Snapshot(), }, } return snap, nil }
[ "func", "(", "s", "*", "StateStore", ")", "Snapshot", "(", ")", "(", "*", "StateSnapshot", ",", "error", ")", "{", "snap", ":=", "&", "StateSnapshot", "{", "StateStore", ":", "StateStore", "{", "logger", ":", "s", ".", "logger", ",", "config", ":", "...
// 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.
[ "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", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L93-L102
132,983
hashicorp/nomad
nomad/state/state_store.go
Restore
func (s *StateStore) Restore() (*StateRestore, error) { txn := s.db.Txn(true) r := &StateRestore{ txn: txn, } return r, nil }
go
func (s *StateStore) Restore() (*StateRestore, error) { txn := s.db.Txn(true) r := &StateRestore{ txn: txn, } return r, nil }
[ "func", "(", "s", "*", "StateStore", ")", "Restore", "(", ")", "(", "*", "StateRestore", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "r", ":=", "&", "StateRestore", "{", "txn", ":", "txn", ",", "}", ...
// Restore is used to optimize the efficiency of rebuilding // state by minimizing the number of transactions and checking // overhead.
[ "Restore", "is", "used", "to", "optimize", "the", "efficiency", "of", "rebuilding", "state", "by", "minimizing", "the", "number", "of", "transactions", "and", "checking", "overhead", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L107-L113
132,984
hashicorp/nomad
nomad/state/state_store.go
BlockingQuery
func (s *StateStore) BlockingQuery(query QueryFn, minIndex uint64, ctx context.Context) ( resp interface{}, index uint64, err error) { RUN_QUERY: // We capture the state store and its abandon channel but pass a snapshot to // the blocking query function. We operate on the snapshot to allow separate // calls to the...
go
func (s *StateStore) BlockingQuery(query QueryFn, minIndex uint64, ctx context.Context) ( resp interface{}, index uint64, err error) { RUN_QUERY: // We capture the state store and its abandon channel but pass a snapshot to // the blocking query function. We operate on the snapshot to allow separate // calls to the...
[ "func", "(", "s", "*", "StateStore", ")", "BlockingQuery", "(", "query", "QueryFn", ",", "minIndex", "uint64", ",", "ctx", "context", ".", "Context", ")", "(", "resp", "interface", "{", "}", ",", "index", "uint64", ",", "err", "error", ")", "{", "RUN_Q...
// BlockingQuery takes a query function and runs the function until the minimum // query index is met or until the passed context is cancelled.
[ "BlockingQuery", "takes", "a", "query", "function", "and", "runs", "the", "function", "until", "the", "minimum", "query", "index", "is", "met", "or", "until", "the", "passed", "context", "is", "cancelled", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L133-L169
132,985
hashicorp/nomad
nomad/state/state_store.go
UpsertPlanResults
func (s *StateStore) UpsertPlanResults(index uint64, results *structs.ApplyPlanResultsRequest) error { snapshot, err := s.Snapshot() if err != nil { return err } allocsStopped, err := snapshot.DenormalizeAllocationDiffSlice(results.AllocsStopped, results.Job) if err != nil { return err } allocsPreempted, e...
go
func (s *StateStore) UpsertPlanResults(index uint64, results *structs.ApplyPlanResultsRequest) error { snapshot, err := s.Snapshot() if err != nil { return err } allocsStopped, err := snapshot.DenormalizeAllocationDiffSlice(results.AllocsStopped, results.Job) if err != nil { return err } allocsPreempted, e...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertPlanResults", "(", "index", "uint64", ",", "results", "*", "structs", ".", "ApplyPlanResultsRequest", ")", "error", "{", "snapshot", ",", "err", ":=", "s", ".", "Snapshot", "(", ")", "\n", "if", "err", "!=...
// UpsertPlanResults is used to upsert the results of a plan.
[ "UpsertPlanResults", "is", "used", "to", "upsert", "the", "results", "of", "a", "plan", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L172-L258
132,986
hashicorp/nomad
nomad/state/state_store.go
upsertDeploymentUpdates
func (s *StateStore) upsertDeploymentUpdates(index uint64, updates []*structs.DeploymentStatusUpdate, txn *memdb.Txn) error { for _, u := range updates { if err := s.updateDeploymentStatusImpl(index, u, txn); err != nil { return err } } return nil }
go
func (s *StateStore) upsertDeploymentUpdates(index uint64, updates []*structs.DeploymentStatusUpdate, txn *memdb.Txn) error { for _, u := range updates { if err := s.updateDeploymentStatusImpl(index, u, txn); err != nil { return err } } return nil }
[ "func", "(", "s", "*", "StateStore", ")", "upsertDeploymentUpdates", "(", "index", "uint64", ",", "updates", "[", "]", "*", "structs", ".", "DeploymentStatusUpdate", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "for", "_", ",", "u", ":=", "...
// upsertDeploymentUpdates updates the deployments given the passed status // updates.
[ "upsertDeploymentUpdates", "updates", "the", "deployments", "given", "the", "passed", "status", "updates", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L286-L294
132,987
hashicorp/nomad
nomad/state/state_store.go
UpsertJobSummary
func (s *StateStore) UpsertJobSummary(index uint64, jobSummary *structs.JobSummary) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if jobSummary.Namespace == "" { jobSummary.Namespace = structs.DefaultNamespace } // Check if the job summary alrea...
go
func (s *StateStore) UpsertJobSummary(index uint64, jobSummary *structs.JobSummary) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if jobSummary.Namespace == "" { jobSummary.Namespace = structs.DefaultNamespace } // Check if the job summary alrea...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertJobSummary", "(", "index", "uint64", ",", "jobSummary", "*", "structs", ".", "JobSummary", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abor...
// UpsertJobSummary upserts a job summary into the state store.
[ "UpsertJobSummary", "upserts", "a", "job", "summary", "into", "the", "state", "store", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L297-L333
132,988
hashicorp/nomad
nomad/state/state_store.go
DeleteJobSummary
func (s *StateStore) DeleteJobSummary(index uint64, namespace, id string) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Delete the job summary if _, err := txn.DeleteAll("job_summar...
go
func (s *StateStore) DeleteJobSummary(index uint64, namespace, id string) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Delete the job summary if _, err := txn.DeleteAll("job_summar...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteJobSummary", "(", "index", "uint64", ",", "namespace", ",", "id", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", ")",...
// DeleteJobSummary deletes the job summary with the given ID. This is for // testing purposes only.
[ "DeleteJobSummary", "deletes", "the", "job", "summary", "with", "the", "given", "ID", ".", "This", "is", "for", "testing", "purposes", "only", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L337-L355
132,989
hashicorp/nomad
nomad/state/state_store.go
UpsertDeployment
func (s *StateStore) UpsertDeployment(index uint64, deployment *structs.Deployment) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.upsertDeploymentImpl(index, deployment, txn); err != nil { return err } txn.Commit() return nil }
go
func (s *StateStore) UpsertDeployment(index uint64, deployment *structs.Deployment) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.upsertDeploymentImpl(index, deployment, txn); err != nil { return err } txn.Commit() return nil }
[ "func", "(", "s", "*", "StateStore", ")", "UpsertDeployment", "(", "index", "uint64", ",", "deployment", "*", "structs", ".", "Deployment", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abor...
// UpsertDeployment is used to insert a new deployment. If cancelPrior is set to // true, all prior deployments for the same job will be cancelled.
[ "UpsertDeployment", "is", "used", "to", "insert", "a", "new", "deployment", ".", "If", "cancelPrior", "is", "set", "to", "true", "all", "prior", "deployments", "for", "the", "same", "job", "will", "be", "cancelled", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L359-L367
132,990
hashicorp/nomad
nomad/state/state_store.go
deploymentNamespaceFilter
func deploymentNamespaceFilter(namespace string) func(interface{}) bool { return func(raw interface{}) bool { d, ok := raw.(*structs.Deployment) if !ok { return true } return d.Namespace != namespace } }
go
func deploymentNamespaceFilter(namespace string) func(interface{}) bool { return func(raw interface{}) bool { d, ok := raw.(*structs.Deployment) if !ok { return true } return d.Namespace != namespace } }
[ "func", "deploymentNamespaceFilter", "(", "namespace", "string", ")", "func", "(", "interface", "{", "}", ")", "bool", "{", "return", "func", "(", "raw", "interface", "{", "}", ")", "bool", "{", "d", ",", "ok", ":=", "raw", ".", "(", "*", "structs", ...
// deploymentNamespaceFilter returns a filter function that filters all // deployment not in the given namespace.
[ "deploymentNamespaceFilter", "returns", "a", "filter", "function", "that", "filters", "all", "deployment", "not", "in", "the", "given", "namespace", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L454-L463
132,991
hashicorp/nomad
nomad/state/state_store.go
DeleteDeployment
func (s *StateStore) DeleteDeployment(index uint64, deploymentIDs []string) error { txn := s.db.Txn(true) defer txn.Abort() if len(deploymentIDs) == 0 { return nil } for _, deploymentID := range deploymentIDs { // Lookup the deployment existing, err := txn.First("deployment", "id", deploymentID) if err !...
go
func (s *StateStore) DeleteDeployment(index uint64, deploymentIDs []string) error { txn := s.db.Txn(true) defer txn.Abort() if len(deploymentIDs) == 0 { return nil } for _, deploymentID := range deploymentIDs { // Lookup the deployment existing, err := txn.First("deployment", "id", deploymentID) if err !...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteDeployment", "(", "index", "uint64", ",", "deploymentIDs", "[", "]", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", "...
// DeleteDeployment is used to delete a set of deployments by ID
[ "DeleteDeployment", "is", "used", "to", "delete", "a", "set", "of", "deployments", "by", "ID" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L549-L579
132,992
hashicorp/nomad
nomad/state/state_store.go
DeleteNode
func (s *StateStore) DeleteNode(index uint64, nodeID string) error { txn := s.db.Txn(true) defer txn.Abort() // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if existing == nil { return fmt.Errorf("node not found") } /...
go
func (s *StateStore) DeleteNode(index uint64, nodeID string) error { txn := s.db.Txn(true) defer txn.Abort() // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if existing == nil { return fmt.Errorf("node not found") } /...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteNode", "(", "index", "uint64", ",", "nodeID", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", ")", "\n\n", "// Lookup ...
// DeleteNode is used to deregister a node
[ "DeleteNode", "is", "used", "to", "deregister", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L638-L661
132,993
hashicorp/nomad
nomad/state/state_store.go
UpdateNodeStatus
func (s *StateStore) UpdateNodeStatus(index uint64, nodeID, status string, event *structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if existing == nil { re...
go
func (s *StateStore) UpdateNodeStatus(index uint64, nodeID, status string, event *structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if existing == nil { re...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateNodeStatus", "(", "index", "uint64", ",", "nodeID", ",", "status", "string", ",", "event", "*", "structs", ".", "NodeEvent", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")"...
// UpdateNodeStatus is used to update the status of a node
[ "UpdateNodeStatus", "is", "used", "to", "update", "the", "status", "of", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L664-L700
132,994
hashicorp/nomad
nomad/state/state_store.go
BatchUpdateNodeDrain
func (s *StateStore) BatchUpdateNodeDrain(index uint64, updates map[string]*structs.DrainUpdate, events map[string]*structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() for node, update := range updates { if err := s.updateNodeDrainImpl(txn, index, node, update.DrainStrategy, update.MarkEligible, eve...
go
func (s *StateStore) BatchUpdateNodeDrain(index uint64, updates map[string]*structs.DrainUpdate, events map[string]*structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() for node, update := range updates { if err := s.updateNodeDrainImpl(txn, index, node, update.DrainStrategy, update.MarkEligible, eve...
[ "func", "(", "s", "*", "StateStore", ")", "BatchUpdateNodeDrain", "(", "index", "uint64", ",", "updates", "map", "[", "string", "]", "*", "structs", ".", "DrainUpdate", ",", "events", "map", "[", "string", "]", "*", "structs", ".", "NodeEvent", ")", "err...
// BatchUpdateNodeDrain is used to update the drain of a node set of nodes
[ "BatchUpdateNodeDrain", "is", "used", "to", "update", "the", "drain", "of", "a", "node", "set", "of", "nodes" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L703-L713
132,995
hashicorp/nomad
nomad/state/state_store.go
UpdateNodeDrain
func (s *StateStore) UpdateNodeDrain(index uint64, nodeID string, drain *structs.DrainStrategy, markEligible bool, event *structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.updateNodeDrainImpl(txn, index, nodeID, drain, markEligible, event); err != nil { return err } txn.Commit() r...
go
func (s *StateStore) UpdateNodeDrain(index uint64, nodeID string, drain *structs.DrainStrategy, markEligible bool, event *structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.updateNodeDrainImpl(txn, index, nodeID, drain, markEligible, event); err != nil { return err } txn.Commit() r...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateNodeDrain", "(", "index", "uint64", ",", "nodeID", "string", ",", "drain", "*", "structs", ".", "DrainStrategy", ",", "markEligible", "bool", ",", "event", "*", "structs", ".", "NodeEvent", ")", "error", "{"...
// UpdateNodeDrain is used to update the drain of a node
[ "UpdateNodeDrain", "is", "used", "to", "update", "the", "drain", "of", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L716-L726
132,996
hashicorp/nomad
nomad/state/state_store.go
UpdateNodeEligibility
func (s *StateStore) UpdateNodeEligibility(index uint64, nodeID string, eligibility string, event *structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if exis...
go
func (s *StateStore) UpdateNodeEligibility(index uint64, nodeID string, eligibility string, event *structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if exis...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateNodeEligibility", "(", "index", "uint64", ",", "nodeID", "string", ",", "eligibility", "string", ",", "event", "*", "structs", ".", "NodeEvent", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", ...
// UpdateNodeEligibility is used to update the scheduling eligibility of a node
[ "UpdateNodeEligibility", "is", "used", "to", "update", "the", "scheduling", "eligibility", "of", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L772-L814
132,997
hashicorp/nomad
nomad/state/state_store.go
UpsertNodeEvents
func (s *StateStore) UpsertNodeEvents(index uint64, nodeEvents map[string][]*structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() for nodeID, events := range nodeEvents { if err := s.upsertNodeEvents(index, nodeID, events, txn); err != nil { return err } } txn.Commit() return nil }
go
func (s *StateStore) UpsertNodeEvents(index uint64, nodeEvents map[string][]*structs.NodeEvent) error { txn := s.db.Txn(true) defer txn.Abort() for nodeID, events := range nodeEvents { if err := s.upsertNodeEvents(index, nodeID, events, txn); err != nil { return err } } txn.Commit() return nil }
[ "func", "(", "s", "*", "StateStore", ")", "UpsertNodeEvents", "(", "index", "uint64", ",", "nodeEvents", "map", "[", "string", "]", "[", "]", "*", "structs", ".", "NodeEvent", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ...
// UpsertNodeEvents adds the node events to the nodes, rotating events as // necessary.
[ "UpsertNodeEvents", "adds", "the", "node", "events", "to", "the", "nodes", "rotating", "events", "as", "necessary", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L818-L830
132,998
hashicorp/nomad
nomad/state/state_store.go
upsertNodeEvents
func (s *StateStore) upsertNodeEvents(index uint64, nodeID string, events []*structs.NodeEvent, txn *memdb.Txn) error { // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if existing == nil { return fmt.Errorf("node not found"...
go
func (s *StateStore) upsertNodeEvents(index uint64, nodeID string, events []*structs.NodeEvent, txn *memdb.Txn) error { // Lookup the node existing, err := txn.First("nodes", "id", nodeID) if err != nil { return fmt.Errorf("node lookup failed: %v", err) } if existing == nil { return fmt.Errorf("node not found"...
[ "func", "(", "s", "*", "StateStore", ")", "upsertNodeEvents", "(", "index", "uint64", ",", "nodeID", "string", ",", "events", "[", "]", "*", "structs", ".", "NodeEvent", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// Lookup the node", "exis...
// upsertNodeEvent upserts a node event for a respective node. It also maintains // that a fixed number of node events are ever stored simultaneously, deleting // older events once this bound has been reached.
[ "upsertNodeEvent", "upserts", "a", "node", "event", "for", "a", "respective", "node", ".", "It", "also", "maintains", "that", "a", "fixed", "number", "of", "node", "events", "are", "ever", "stored", "simultaneously", "deleting", "older", "events", "once", "thi...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L835-L859
132,999
hashicorp/nomad
nomad/state/state_store.go
appendNodeEvents
func appendNodeEvents(index uint64, node *structs.Node, events []*structs.NodeEvent) { // Add the events, updating the indexes for _, e := range events { e.CreateIndex = index node.Events = append(node.Events, e) } // Keep node events pruned to not exceed the max allowed if l := len(node.Events); l > structs....
go
func appendNodeEvents(index uint64, node *structs.Node, events []*structs.NodeEvent) { // Add the events, updating the indexes for _, e := range events { e.CreateIndex = index node.Events = append(node.Events, e) } // Keep node events pruned to not exceed the max allowed if l := len(node.Events); l > structs....
[ "func", "appendNodeEvents", "(", "index", "uint64", ",", "node", "*", "structs", ".", "Node", ",", "events", "[", "]", "*", "structs", ".", "NodeEvent", ")", "{", "// Add the events, updating the indexes", "for", "_", ",", "e", ":=", "range", "events", "{", ...
// appendNodeEvents is a helper that takes a node and new events and appends // them, pruning older events as needed.
[ "appendNodeEvents", "is", "a", "helper", "that", "takes", "a", "node", "and", "new", "events", "and", "appends", "them", "pruning", "older", "events", "as", "needed", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L863-L875