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,400 | hashicorp/nomad | nomad/structs/structs.go | SetHash | func (a *ACLToken) SetHash() []byte {
// Initialize a 256bit Blake2 hash (32 bytes)
hash, err := blake2b.New256(nil)
if err != nil {
panic(err)
}
// Write all the user set fields
hash.Write([]byte(a.Name))
hash.Write([]byte(a.Type))
for _, policyName := range a.Policies {
hash.Write([]byte(policyName))
}
... | go | func (a *ACLToken) SetHash() []byte {
// Initialize a 256bit Blake2 hash (32 bytes)
hash, err := blake2b.New256(nil)
if err != nil {
panic(err)
}
// Write all the user set fields
hash.Write([]byte(a.Name))
hash.Write([]byte(a.Type))
for _, policyName := range a.Policies {
hash.Write([]byte(policyName))
}
... | [
"func",
"(",
"a",
"*",
"ACLToken",
")",
"SetHash",
"(",
")",
"[",
"]",
"byte",
"{",
"// Initialize a 256bit Blake2 hash (32 bytes)",
"hash",
",",
"err",
":=",
"blake2b",
".",
"New256",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
... | // SetHash is used to compute and set the hash of the ACL token | [
"SetHash",
"is",
"used",
"to",
"compute",
"and",
"set",
"the",
"hash",
"of",
"the",
"ACL",
"token"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L9053-L9078 |
132,401 | hashicorp/nomad | nomad/structs/structs.go | Validate | func (a *ACLToken) Validate() error {
var mErr multierror.Error
if len(a.Name) > maxTokenNameLength {
mErr.Errors = append(mErr.Errors, fmt.Errorf("token name too long"))
}
switch a.Type {
case ACLClientToken:
if len(a.Policies) == 0 {
mErr.Errors = append(mErr.Errors, fmt.Errorf("client token missing polic... | go | func (a *ACLToken) Validate() error {
var mErr multierror.Error
if len(a.Name) > maxTokenNameLength {
mErr.Errors = append(mErr.Errors, fmt.Errorf("token name too long"))
}
switch a.Type {
case ACLClientToken:
if len(a.Policies) == 0 {
mErr.Errors = append(mErr.Errors, fmt.Errorf("client token missing polic... | [
"func",
"(",
"a",
"*",
"ACLToken",
")",
"Validate",
"(",
")",
"error",
"{",
"var",
"mErr",
"multierror",
".",
"Error",
"\n",
"if",
"len",
"(",
"a",
".",
"Name",
")",
">",
"maxTokenNameLength",
"{",
"mErr",
".",
"Errors",
"=",
"append",
"(",
"mErr",
... | // Validate is used to sanity check a token | [
"Validate",
"is",
"used",
"to",
"sanity",
"check",
"a",
"token"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L9095-L9113 |
132,402 | hashicorp/nomad | nomad/structs/structs.go | PolicySubset | func (a *ACLToken) PolicySubset(policies []string) bool {
// Hot-path the management tokens, superset of all policies.
if a.Type == ACLManagementToken {
return true
}
associatedPolicies := make(map[string]struct{}, len(a.Policies))
for _, policy := range a.Policies {
associatedPolicies[policy] = struct{}{}
}
... | go | func (a *ACLToken) PolicySubset(policies []string) bool {
// Hot-path the management tokens, superset of all policies.
if a.Type == ACLManagementToken {
return true
}
associatedPolicies := make(map[string]struct{}, len(a.Policies))
for _, policy := range a.Policies {
associatedPolicies[policy] = struct{}{}
}
... | [
"func",
"(",
"a",
"*",
"ACLToken",
")",
"PolicySubset",
"(",
"policies",
"[",
"]",
"string",
")",
"bool",
"{",
"// Hot-path the management tokens, superset of all policies.",
"if",
"a",
".",
"Type",
"==",
"ACLManagementToken",
"{",
"return",
"true",
"\n",
"}",
"... | // PolicySubset checks if a given set of policies is a subset of the token | [
"PolicySubset",
"checks",
"if",
"a",
"given",
"set",
"of",
"policies",
"is",
"a",
"subset",
"of",
"the",
"token"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L9116-L9131 |
132,403 | hashicorp/nomad | nomad/periodic_endpoint.go | Force | func (p *Periodic) Force(args *structs.PeriodicForceRequest, reply *structs.PeriodicForceResponse) error {
if done, err := p.srv.forward("Periodic.Force", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "periodic", "force"}, time.Now())
// Check for write-job permissions
if ... | go | func (p *Periodic) Force(args *structs.PeriodicForceRequest, reply *structs.PeriodicForceResponse) error {
if done, err := p.srv.forward("Periodic.Force", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "periodic", "force"}, time.Now())
// Check for write-job permissions
if ... | [
"func",
"(",
"p",
"*",
"Periodic",
")",
"Force",
"(",
"args",
"*",
"structs",
".",
"PeriodicForceRequest",
",",
"reply",
"*",
"structs",
".",
"PeriodicForceResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"p",
".",
"srv",
".",
"forward",
"... | // Force is used to force a new instance of a periodic job | [
"Force",
"is",
"used",
"to",
"force",
"a",
"new",
"instance",
"of",
"a",
"periodic",
"job"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/periodic_endpoint.go#L22-L69 |
132,404 | hashicorp/nomad | drivers/shared/executor/executor.go | SetWriters | func (c *ExecCommand) SetWriters(out io.WriteCloser, err io.WriteCloser) {
c.stdout = out
c.stderr = err
} | go | func (c *ExecCommand) SetWriters(out io.WriteCloser, err io.WriteCloser) {
c.stdout = out
c.stderr = err
} | [
"func",
"(",
"c",
"*",
"ExecCommand",
")",
"SetWriters",
"(",
"out",
"io",
".",
"WriteCloser",
",",
"err",
"io",
".",
"WriteCloser",
")",
"{",
"c",
".",
"stdout",
"=",
"out",
"\n",
"c",
".",
"stderr",
"=",
"err",
"\n",
"}"
] | // SetWriters sets the writer for the process stdout and stderr. This should
// not be used if writing to a file path such as a fifo file. SetStdoutWriter
// is mainly used for unit testing purposes. | [
"SetWriters",
"sets",
"the",
"writer",
"for",
"the",
"process",
"stdout",
"and",
"stderr",
".",
"This",
"should",
"not",
"be",
"used",
"if",
"writing",
"to",
"a",
"file",
"path",
"such",
"as",
"a",
"fifo",
"file",
".",
"SetStdoutWriter",
"is",
"mainly",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L130-L133 |
132,405 | hashicorp/nomad | drivers/shared/executor/executor.go | GetWriters | func (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) {
return c.stdout, c.stderr
} | go | func (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) {
return c.stdout, c.stderr
} | [
"func",
"(",
"c",
"*",
"ExecCommand",
")",
"GetWriters",
"(",
")",
"(",
"stdout",
"io",
".",
"WriteCloser",
",",
"stderr",
"io",
".",
"WriteCloser",
")",
"{",
"return",
"c",
".",
"stdout",
",",
"c",
".",
"stderr",
"\n",
"}"
] | // GetWriters returns the unexported io.WriteCloser for the stdout and stderr
// handles. This is mainly used for unit testing purposes. | [
"GetWriters",
"returns",
"the",
"unexported",
"io",
".",
"WriteCloser",
"for",
"the",
"stdout",
"and",
"stderr",
"handles",
".",
"This",
"is",
"mainly",
"used",
"for",
"unit",
"testing",
"purposes",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L137-L139 |
132,406 | hashicorp/nomad | drivers/shared/executor/executor.go | Stdout | func (c *ExecCommand) Stdout() (io.WriteCloser, error) {
if c.stdout == nil {
if c.StdoutPath != "" {
f, err := fifo.OpenWriter(c.StdoutPath)
if err != nil {
return nil, fmt.Errorf("failed to create stdout: %v", err)
}
c.stdout = f
} else {
c.stdout = nopCloser{ioutil.Discard}
}
}
return c.s... | go | func (c *ExecCommand) Stdout() (io.WriteCloser, error) {
if c.stdout == nil {
if c.StdoutPath != "" {
f, err := fifo.OpenWriter(c.StdoutPath)
if err != nil {
return nil, fmt.Errorf("failed to create stdout: %v", err)
}
c.stdout = f
} else {
c.stdout = nopCloser{ioutil.Discard}
}
}
return c.s... | [
"func",
"(",
"c",
"*",
"ExecCommand",
")",
"Stdout",
"(",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"if",
"c",
".",
"stdout",
"==",
"nil",
"{",
"if",
"c",
".",
"StdoutPath",
"!=",
"\"",
"\"",
"{",
"f",
",",
"err",
":=",
"fifo"... | // Stdout returns a writer for the configured file descriptor | [
"Stdout",
"returns",
"a",
"writer",
"for",
"the",
"configured",
"file",
"descriptor"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L148-L161 |
132,407 | hashicorp/nomad | drivers/shared/executor/executor.go | Stderr | func (c *ExecCommand) Stderr() (io.WriteCloser, error) {
if c.stderr == nil {
if c.StderrPath != "" {
f, err := fifo.OpenWriter(c.StderrPath)
if err != nil {
return nil, fmt.Errorf("failed to create stderr: %v", err)
}
c.stderr = f
} else {
c.stderr = nopCloser{ioutil.Discard}
}
}
return c.s... | go | func (c *ExecCommand) Stderr() (io.WriteCloser, error) {
if c.stderr == nil {
if c.StderrPath != "" {
f, err := fifo.OpenWriter(c.StderrPath)
if err != nil {
return nil, fmt.Errorf("failed to create stderr: %v", err)
}
c.stderr = f
} else {
c.stderr = nopCloser{ioutil.Discard}
}
}
return c.s... | [
"func",
"(",
"c",
"*",
"ExecCommand",
")",
"Stderr",
"(",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"if",
"c",
".",
"stderr",
"==",
"nil",
"{",
"if",
"c",
".",
"StderrPath",
"!=",
"\"",
"\"",
"{",
"f",
",",
"err",
":=",
"fifo"... | // Stderr returns a writer for the configured file descriptor | [
"Stderr",
"returns",
"a",
"writer",
"for",
"the",
"configured",
"file",
"descriptor"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L164-L177 |
132,408 | hashicorp/nomad | drivers/shared/executor/executor.go | NewExecutor | func NewExecutor(logger hclog.Logger) Executor {
logger = logger.Named("executor")
if err := shelpers.Init(); err != nil {
logger.Error("unable to initialize stats", "error", err)
}
return &UniversalExecutor{
logger: logger,
processExited: make(chan interface{}),
totalCpuStats: stats.NewCpuStats()... | go | func NewExecutor(logger hclog.Logger) Executor {
logger = logger.Named("executor")
if err := shelpers.Init(); err != nil {
logger.Error("unable to initialize stats", "error", err)
}
return &UniversalExecutor{
logger: logger,
processExited: make(chan interface{}),
totalCpuStats: stats.NewCpuStats()... | [
"func",
"NewExecutor",
"(",
"logger",
"hclog",
".",
"Logger",
")",
"Executor",
"{",
"logger",
"=",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"shelpers",
".",
"Init",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
"."... | // NewExecutor returns an Executor | [
"NewExecutor",
"returns",
"an",
"Executor"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L228-L241 |
132,409 | hashicorp/nomad | drivers/shared/executor/executor.go | Launch | func (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error) {
e.logger.Debug("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " "))
e.commandCfg = command
// setting the user of the process
if command.User != "" {
e.logger.Debug("running command as user", "user... | go | func (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error) {
e.logger.Debug("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " "))
e.commandCfg = command
// setting the user of the process
if command.User != "" {
e.logger.Debug("running command as user", "user... | [
"func",
"(",
"e",
"*",
"UniversalExecutor",
")",
"Launch",
"(",
"command",
"*",
"ExecCommand",
")",
"(",
"*",
"ProcessState",
",",
"error",
")",
"{",
"e",
".",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"command",
".",
"Cmd",
",... | // Launch launches the main process and returns its state. It also
// configures an applies isolation on certain platforms. | [
"Launch",
"launches",
"the",
"main",
"process",
"and",
"returns",
"its",
"state",
".",
"It",
"also",
"configures",
"an",
"applies",
"isolation",
"on",
"certain",
"platforms",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L250-L313 |
132,410 | hashicorp/nomad | drivers/shared/executor/executor.go | Exec | func (e *UniversalExecutor) Exec(deadline time.Time, name string, args []string) ([]byte, int, error) {
ctx, cancel := context.WithDeadline(context.Background(), deadline)
defer cancel()
return ExecScript(ctx, e.childCmd.Dir, e.commandCfg.Env, e.childCmd.SysProcAttr, name, args)
} | go | func (e *UniversalExecutor) Exec(deadline time.Time, name string, args []string) ([]byte, int, error) {
ctx, cancel := context.WithDeadline(context.Background(), deadline)
defer cancel()
return ExecScript(ctx, e.childCmd.Dir, e.commandCfg.Env, e.childCmd.SysProcAttr, name, args)
} | [
"func",
"(",
"e",
"*",
"UniversalExecutor",
")",
"Exec",
"(",
"deadline",
"time",
".",
"Time",
",",
"name",
"string",
",",
"args",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"int",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"co... | // Exec a command inside a container for exec and java drivers. | [
"Exec",
"a",
"command",
"inside",
"a",
"container",
"for",
"exec",
"and",
"java",
"drivers",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L316-L320 |
132,411 | hashicorp/nomad | drivers/shared/executor/executor.go | Shutdown | func (e *UniversalExecutor) Shutdown(signal string, grace time.Duration) error {
e.logger.Debug("shutdown requested", "signal", signal, "grace_period_ms", grace.Round(time.Millisecond))
var merr multierror.Error
// If the executor did not launch a process, return.
if e.commandCfg == nil {
return nil
}
// If t... | go | func (e *UniversalExecutor) Shutdown(signal string, grace time.Duration) error {
e.logger.Debug("shutdown requested", "signal", signal, "grace_period_ms", grace.Round(time.Millisecond))
var merr multierror.Error
// If the executor did not launch a process, return.
if e.commandCfg == nil {
return nil
}
// If t... | [
"func",
"(",
"e",
"*",
"UniversalExecutor",
")",
"Shutdown",
"(",
"signal",
"string",
",",
"grace",
"time",
".",
"Duration",
")",
"error",
"{",
"e",
".",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"signal",
",",
"\"",
"\"",
",",... | // Exit cleans up the alloc directory, destroys resource container and kills the
// user process | [
"Exit",
"cleans",
"up",
"the",
"alloc",
"directory",
"destroys",
"resource",
"container",
"and",
"kills",
"the",
"user",
"process"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L420-L498 |
132,412 | hashicorp/nomad | drivers/shared/executor/executor.go | Signal | func (e *UniversalExecutor) Signal(s os.Signal) error {
if e.childCmd.Process == nil {
return fmt.Errorf("Task not yet run")
}
e.logger.Debug("sending signal to PID", "signal", s, "pid", e.childCmd.Process.Pid)
err := e.childCmd.Process.Signal(s)
if err != nil {
e.logger.Error("sending signal failed", "signal... | go | func (e *UniversalExecutor) Signal(s os.Signal) error {
if e.childCmd.Process == nil {
return fmt.Errorf("Task not yet run")
}
e.logger.Debug("sending signal to PID", "signal", s, "pid", e.childCmd.Process.Pid)
err := e.childCmd.Process.Signal(s)
if err != nil {
e.logger.Error("sending signal failed", "signal... | [
"func",
"(",
"e",
"*",
"UniversalExecutor",
")",
"Signal",
"(",
"s",
"os",
".",
"Signal",
")",
"error",
"{",
"if",
"e",
".",
"childCmd",
".",
"Process",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"e... | // Signal sends the passed signal to the task | [
"Signal",
"sends",
"the",
"passed",
"signal",
"to",
"the",
"task"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L501-L514 |
132,413 | hashicorp/nomad | drivers/shared/executor/executor.go | makeExecutable | func makeExecutable(binPath string) error {
if runtime.GOOS == "windows" {
return nil
}
fi, err := os.Stat(binPath)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("binary %q does not exist", binPath)
}
return fmt.Errorf("specified binary is invalid: %v", err)
}
// If it is not executable, ... | go | func makeExecutable(binPath string) error {
if runtime.GOOS == "windows" {
return nil
}
fi, err := os.Stat(binPath)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("binary %q does not exist", binPath)
}
return fmt.Errorf("specified binary is invalid: %v", err)
}
// If it is not executable, ... | [
"func",
"makeExecutable",
"(",
"binPath",
"string",
")",
"error",
"{",
"if",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"binPath",
")",
"\n",
"if",
"err",
"!=",... | // makeExecutable makes the given file executable for root,group,others. | [
"makeExecutable",
"makes",
"the",
"given",
"file",
"executable",
"for",
"root",
"group",
"others",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor.go#L581-L603 |
132,414 | hashicorp/nomad | nomad/mock/mock.go | NvidiaNode | func NvidiaNode() *structs.Node {
n := Node()
n.NodeResources.Devices = []*structs.NodeDeviceResource{
{
Type: "gpu",
Vendor: "nvidia",
Name: "1080ti",
Attributes: map[string]*psstructs.Attribute{
"memory": psstructs.NewIntAttribute(11, psstructs.UnitGiB),
"cuda_cores": psstr... | go | func NvidiaNode() *structs.Node {
n := Node()
n.NodeResources.Devices = []*structs.NodeDeviceResource{
{
Type: "gpu",
Vendor: "nvidia",
Name: "1080ti",
Attributes: map[string]*psstructs.Attribute{
"memory": psstructs.NewIntAttribute(11, psstructs.UnitGiB),
"cuda_cores": psstr... | [
"func",
"NvidiaNode",
"(",
")",
"*",
"structs",
".",
"Node",
"{",
"n",
":=",
"Node",
"(",
")",
"\n",
"n",
".",
"NodeResources",
".",
"Devices",
"=",
"[",
"]",
"*",
"structs",
".",
"NodeDeviceResource",
"{",
"{",
"Type",
":",
"\"",
"\"",
",",
"Vendo... | // NvidiaNode returns a node with two instances of an Nvidia GPU | [
"NvidiaNode",
"returns",
"a",
"node",
"with",
"two",
"instances",
"of",
"an",
"Nvidia",
"GPU"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/mock/mock.go#L95-L122 |
132,415 | hashicorp/nomad | client/allocrunner/health_hook.go | watchHealth | func (h *allocHealthWatcherHook) watchHealth(ctx context.Context, deadline time.Time, tracker *allochealth.Tracker, done chan<- struct{}) {
defer close(done)
// Default to unhealthy for the deadline reached case
healthy := false
select {
case <-ctx.Done():
// Graceful shutdown
return
case <-tracker.AllocSt... | go | func (h *allocHealthWatcherHook) watchHealth(ctx context.Context, deadline time.Time, tracker *allochealth.Tracker, done chan<- struct{}) {
defer close(done)
// Default to unhealthy for the deadline reached case
healthy := false
select {
case <-ctx.Done():
// Graceful shutdown
return
case <-tracker.AllocSt... | [
"func",
"(",
"h",
"*",
"allocHealthWatcherHook",
")",
"watchHealth",
"(",
"ctx",
"context",
".",
"Context",
",",
"deadline",
"time",
".",
"Time",
",",
"tracker",
"*",
"allochealth",
".",
"Tracker",
",",
"done",
"chan",
"<-",
"struct",
"{",
"}",
")",
"{",... | // watchHealth watches alloc health until it is set, the alloc is stopped, the
// deadline is reached, or the context is canceled. watchHealth will be
// canceled and restarted on Updates so calls are serialized with a lock. | [
"watchHealth",
"watches",
"alloc",
"health",
"until",
"it",
"is",
"set",
"the",
"alloc",
"is",
"stopped",
"the",
"deadline",
"is",
"reached",
"or",
"the",
"context",
"is",
"canceled",
".",
"watchHealth",
"will",
"be",
"canceled",
"and",
"restarted",
"on",
"U... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/health_hook.go#L203-L235 |
132,416 | hashicorp/nomad | client/allocrunner/health_hook.go | getHealthParams | func getHealthParams(now time.Time, tg *structs.TaskGroup, isDeploy bool) (deadline time.Time, useChecks bool, minHealthyTime time.Duration) {
if isDeploy {
deadline = now.Add(tg.Update.HealthyDeadline)
minHealthyTime = tg.Update.MinHealthyTime
useChecks = tg.Update.HealthCheck == structs.UpdateStrategyHealthChe... | go | func getHealthParams(now time.Time, tg *structs.TaskGroup, isDeploy bool) (deadline time.Time, useChecks bool, minHealthyTime time.Duration) {
if isDeploy {
deadline = now.Add(tg.Update.HealthyDeadline)
minHealthyTime = tg.Update.MinHealthyTime
useChecks = tg.Update.HealthCheck == structs.UpdateStrategyHealthChe... | [
"func",
"getHealthParams",
"(",
"now",
"time",
".",
"Time",
",",
"tg",
"*",
"structs",
".",
"TaskGroup",
",",
"isDeploy",
"bool",
")",
"(",
"deadline",
"time",
".",
"Time",
",",
"useChecks",
"bool",
",",
"minHealthyTime",
"time",
".",
"Duration",
")",
"{... | // getHealthParams returns the health watcher parameters which vary based on
// whether this allocation is in a deployment or migration. | [
"getHealthParams",
"returns",
"the",
"health",
"watcher",
"parameters",
"which",
"vary",
"based",
"on",
"whether",
"this",
"allocation",
"is",
"in",
"a",
"deployment",
"or",
"migration",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/health_hook.go#L239-L257 |
132,417 | hashicorp/nomad | nomad/state/notify.go | Empty | func (n *NotifyGroup) Empty() bool {
n.l.Lock()
defer n.l.Unlock()
return len(n.notify) == 0
} | go | func (n *NotifyGroup) Empty() bool {
n.l.Lock()
defer n.l.Unlock()
return len(n.notify) == 0
} | [
"func",
"(",
"n",
"*",
"NotifyGroup",
")",
"Empty",
"(",
")",
"bool",
"{",
"n",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"return",
"len",
"(",
"n",
".",
"notify",
")",
"==",
"0",
"\n",
"}... | // Empty checks if there are no channels to notify | [
"Empty",
"checks",
"if",
"there",
"are",
"no",
"channels",
"to",
"notify"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/notify.go#L58-L62 |
132,418 | hashicorp/nomad | nomad/stats_fetcher.go | Fetch | func (f *StatsFetcher) Fetch(ctx context.Context, members []serf.Member) map[string]*autopilot.ServerStats {
type workItem struct {
server *serverParts
replyCh chan *autopilot.ServerStats
}
var servers []*serverParts
for _, s := range members {
if ok, parts := isNomadServer(s); ok {
servers = append(serve... | go | func (f *StatsFetcher) Fetch(ctx context.Context, members []serf.Member) map[string]*autopilot.ServerStats {
type workItem struct {
server *serverParts
replyCh chan *autopilot.ServerStats
}
var servers []*serverParts
for _, s := range members {
if ok, parts := isNomadServer(s); ok {
servers = append(serve... | [
"func",
"(",
"f",
"*",
"StatsFetcher",
")",
"Fetch",
"(",
"ctx",
"context",
".",
"Context",
",",
"members",
"[",
"]",
"serf",
".",
"Member",
")",
"map",
"[",
"string",
"]",
"*",
"autopilot",
".",
"ServerStats",
"{",
"type",
"workItem",
"struct",
"{",
... | // Fetch will attempt to query all the servers in parallel. | [
"Fetch",
"will",
"attempt",
"to",
"query",
"all",
"the",
"servers",
"in",
"parallel",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/stats_fetcher.go#L59-L102 |
132,419 | hashicorp/nomad | api/deployments.go | List | func (d *Deployments) List(q *QueryOptions) ([]*Deployment, *QueryMeta, error) {
var resp []*Deployment
qm, err := d.client.query("/v1/deployments", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(DeploymentIndexSort(resp))
return resp, qm, nil
} | go | func (d *Deployments) List(q *QueryOptions) ([]*Deployment, *QueryMeta, error) {
var resp []*Deployment
qm, err := d.client.query("/v1/deployments", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(DeploymentIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"List",
"(",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Deployment",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Deployment",
"\n",
"qm",
",",
"err",
":=",
"d",... | // List is used to dump all of the deployments. | [
"List",
"is",
"used",
"to",
"dump",
"all",
"of",
"the",
"deployments",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L19-L27 |
132,420 | hashicorp/nomad | api/deployments.go | Info | func (d *Deployments) Info(deploymentID string, q *QueryOptions) (*Deployment, *QueryMeta, error) {
var resp Deployment
qm, err := d.client.query("/v1/deployment/"+deploymentID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (d *Deployments) Info(deploymentID string, q *QueryOptions) (*Deployment, *QueryMeta, error) {
var resp Deployment
qm, err := d.client.query("/v1/deployment/"+deploymentID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"Info",
"(",
"deploymentID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Deployment",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"Deployment",
"\n",
"qm",
",",
"err",
":=",
"d... | // Info is used to query a single deployment by its ID. | [
"Info",
"is",
"used",
"to",
"query",
"a",
"single",
"deployment",
"by",
"its",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L34-L41 |
132,421 | hashicorp/nomad | api/deployments.go | Allocations | func (d *Deployments) Allocations(deploymentID string, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
qm, err := d.client.query("/v1/deployment/allocations/"+deploymentID, &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocIndexSort(resp))
return resp, ... | go | func (d *Deployments) Allocations(deploymentID string, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
qm, err := d.client.query("/v1/deployment/allocations/"+deploymentID, &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocIndexSort(resp))
return resp, ... | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"Allocations",
"(",
"deploymentID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"AllocationListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Allocat... | // Allocations is used to retrieve a set of allocations that are part of the
// deployment | [
"Allocations",
"is",
"used",
"to",
"retrieve",
"a",
"set",
"of",
"allocations",
"that",
"are",
"part",
"of",
"the",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L45-L53 |
132,422 | hashicorp/nomad | api/deployments.go | Fail | func (d *Deployments) Fail(deploymentID string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentFailRequest{
DeploymentID: deploymentID,
}
wm, err := d.client.write("/v1/deployment/fail/"+deploymentID, req, &resp, q)
if err != nil {
return n... | go | func (d *Deployments) Fail(deploymentID string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentFailRequest{
DeploymentID: deploymentID,
}
wm, err := d.client.write("/v1/deployment/fail/"+deploymentID, req, &resp, q)
if err != nil {
return n... | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"Fail",
"(",
"deploymentID",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"DeploymentUpdateResponse",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"DeploymentUpdateResponse",
"\n",
"req",... | // Fail is used to fail the given deployment. | [
"Fail",
"is",
"used",
"to",
"fail",
"the",
"given",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L56-L66 |
132,423 | hashicorp/nomad | api/deployments.go | Pause | func (d *Deployments) Pause(deploymentID string, pause bool, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentPauseRequest{
DeploymentID: deploymentID,
Pause: pause,
}
wm, err := d.client.write("/v1/deployment/pause/"+deploymentID, req,... | go | func (d *Deployments) Pause(deploymentID string, pause bool, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentPauseRequest{
DeploymentID: deploymentID,
Pause: pause,
}
wm, err := d.client.write("/v1/deployment/pause/"+deploymentID, req,... | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"Pause",
"(",
"deploymentID",
"string",
",",
"pause",
"bool",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"DeploymentUpdateResponse",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"DeploymentUpda... | // Pause is used to pause or unpause the given deployment. | [
"Pause",
"is",
"used",
"to",
"pause",
"or",
"unpause",
"the",
"given",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L69-L80 |
132,424 | hashicorp/nomad | api/deployments.go | PromoteAll | func (d *Deployments) PromoteAll(deploymentID string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentPromoteRequest{
DeploymentID: deploymentID,
All: true,
}
wm, err := d.client.write("/v1/deployment/promote/"+deploymentID, req, &re... | go | func (d *Deployments) PromoteAll(deploymentID string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentPromoteRequest{
DeploymentID: deploymentID,
All: true,
}
wm, err := d.client.write("/v1/deployment/promote/"+deploymentID, req, &re... | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"PromoteAll",
"(",
"deploymentID",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"DeploymentUpdateResponse",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"DeploymentUpdateResponse",
"\n",
... | // PromoteAll is used to promote all canaries in the given deployment | [
"PromoteAll",
"is",
"used",
"to",
"promote",
"all",
"canaries",
"in",
"the",
"given",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L83-L94 |
132,425 | hashicorp/nomad | api/deployments.go | PromoteGroups | func (d *Deployments) PromoteGroups(deploymentID string, groups []string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentPromoteRequest{
DeploymentID: deploymentID,
Groups: groups,
}
wm, err := d.client.write("/v1/deployment/promote/"+... | go | func (d *Deployments) PromoteGroups(deploymentID string, groups []string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentPromoteRequest{
DeploymentID: deploymentID,
Groups: groups,
}
wm, err := d.client.write("/v1/deployment/promote/"+... | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"PromoteGroups",
"(",
"deploymentID",
"string",
",",
"groups",
"[",
"]",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"DeploymentUpdateResponse",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
... | // PromoteGroups is used to promote canaries in the passed groups in the given deployment | [
"PromoteGroups",
"is",
"used",
"to",
"promote",
"canaries",
"in",
"the",
"passed",
"groups",
"in",
"the",
"given",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L97-L108 |
132,426 | hashicorp/nomad | api/deployments.go | SetAllocHealth | func (d *Deployments) SetAllocHealth(deploymentID string, healthy, unhealthy []string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentAllocHealthRequest{
DeploymentID: deploymentID,
HealthyAllocationIDs: healthy,
UnhealthyAllocat... | go | func (d *Deployments) SetAllocHealth(deploymentID string, healthy, unhealthy []string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error) {
var resp DeploymentUpdateResponse
req := &DeploymentAllocHealthRequest{
DeploymentID: deploymentID,
HealthyAllocationIDs: healthy,
UnhealthyAllocat... | [
"func",
"(",
"d",
"*",
"Deployments",
")",
"SetAllocHealth",
"(",
"deploymentID",
"string",
",",
"healthy",
",",
"unhealthy",
"[",
"]",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"DeploymentUpdateResponse",
",",
"*",
"WriteMeta",
",",
"error",
... | // SetAllocHealth is used to set allocation health for allocs that are part of
// the given deployment | [
"SetAllocHealth",
"is",
"used",
"to",
"set",
"allocation",
"health",
"for",
"allocs",
"that",
"are",
"part",
"of",
"the",
"given",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/deployments.go#L112-L124 |
132,427 | hashicorp/nomad | client/structs/structs.go | joinStringSet | func joinStringSet(s1, s2 []string) []string {
lookup := make(map[string]struct{}, len(s1))
j := make([]string, 0, len(s1))
for _, s := range s1 {
j = append(j, s)
lookup[s] = struct{}{}
}
for _, s := range s2 {
if _, ok := lookup[s]; !ok {
j = append(j, s)
}
}
return j
} | go | func joinStringSet(s1, s2 []string) []string {
lookup := make(map[string]struct{}, len(s1))
j := make([]string, 0, len(s1))
for _, s := range s1 {
j = append(j, s)
lookup[s] = struct{}{}
}
for _, s := range s2 {
if _, ok := lookup[s]; !ok {
j = append(j, s)
}
}
return j
} | [
"func",
"joinStringSet",
"(",
"s1",
",",
"s2",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"lookup",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"s1",
")",
")",
"\n",
"j",
":=",
"make",
"(",
"[",
"... | // joinStringSet takes two slices of strings and joins them | [
"joinStringSet",
"takes",
"two",
"slices",
"of",
"strings",
"and",
"joins",
"them"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/structs/structs.go#L257-L272 |
132,428 | hashicorp/nomad | client/structs/structs.go | AddDriverInfo | func (h *HealthCheckResponse) AddDriverInfo(name string, driverInfo *structs.DriverInfo) {
// initialize Drivers if it has not been already
if h.Drivers == nil {
h.Drivers = make(map[string]*structs.DriverInfo, 0)
}
h.Drivers[name] = driverInfo
} | go | func (h *HealthCheckResponse) AddDriverInfo(name string, driverInfo *structs.DriverInfo) {
// initialize Drivers if it has not been already
if h.Drivers == nil {
h.Drivers = make(map[string]*structs.DriverInfo, 0)
}
h.Drivers[name] = driverInfo
} | [
"func",
"(",
"h",
"*",
"HealthCheckResponse",
")",
"AddDriverInfo",
"(",
"name",
"string",
",",
"driverInfo",
"*",
"structs",
".",
"DriverInfo",
")",
"{",
"// initialize Drivers if it has not been already",
"if",
"h",
".",
"Drivers",
"==",
"nil",
"{",
"h",
".",
... | // AddDriverInfo adds information about a driver to the fingerprint response.
// If the Drivers field has not yet been initialized, it does so here. | [
"AddDriverInfo",
"adds",
"information",
"about",
"a",
"driver",
"to",
"the",
"fingerprint",
"response",
".",
"If",
"the",
"Drivers",
"field",
"has",
"not",
"yet",
"been",
"initialized",
"it",
"does",
"so",
"here",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/structs/structs.go#L293-L300 |
132,429 | hashicorp/nomad | client/fingerprint/host.go | NewHostFingerprint | func NewHostFingerprint(logger log.Logger) Fingerprint {
f := &HostFingerprint{logger: logger.Named("host")}
return f
} | go | func NewHostFingerprint(logger log.Logger) Fingerprint {
f := &HostFingerprint{logger: logger.Named("host")}
return f
} | [
"func",
"NewHostFingerprint",
"(",
"logger",
"log",
".",
"Logger",
")",
"Fingerprint",
"{",
"f",
":=",
"&",
"HostFingerprint",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
"}",
"\n",
"return",
"f",
"\n",
"}"
] | // NewHostFingerprint is used to create a Host fingerprint | [
"NewHostFingerprint",
"is",
"used",
"to",
"create",
"a",
"Host",
"fingerprint"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/host.go#L17-L20 |
132,430 | hashicorp/nomad | client/pluginmanager/group.go | New | func New(logger log.Logger) *PluginGroup {
return &PluginGroup{
managers: []PluginManager{},
logger: logger.Named("plugin"),
}
} | go | func New(logger log.Logger) *PluginGroup {
return &PluginGroup{
managers: []PluginManager{},
logger: logger.Named("plugin"),
}
} | [
"func",
"New",
"(",
"logger",
"log",
".",
"Logger",
")",
"*",
"PluginGroup",
"{",
"return",
"&",
"PluginGroup",
"{",
"managers",
":",
"[",
"]",
"PluginManager",
"{",
"}",
",",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"}",
"... | // New returns an initialized PluginGroup | [
"New",
"returns",
"an",
"initialized",
"PluginGroup"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/group.go#L27-L32 |
132,431 | hashicorp/nomad | client/pluginmanager/group.go | RegisterAndRun | func (m *PluginGroup) RegisterAndRun(manager PluginManager) error {
m.mLock.Lock()
defer m.mLock.Unlock()
if m.shutdown {
return fmt.Errorf("plugin group already shutdown")
}
m.managers = append(m.managers, manager)
m.logger.Info("starting plugin manager", "plugin-type", manager.PluginType())
manager.Run()
r... | go | func (m *PluginGroup) RegisterAndRun(manager PluginManager) error {
m.mLock.Lock()
defer m.mLock.Unlock()
if m.shutdown {
return fmt.Errorf("plugin group already shutdown")
}
m.managers = append(m.managers, manager)
m.logger.Info("starting plugin manager", "plugin-type", manager.PluginType())
manager.Run()
r... | [
"func",
"(",
"m",
"*",
"PluginGroup",
")",
"RegisterAndRun",
"(",
"manager",
"PluginManager",
")",
"error",
"{",
"m",
".",
"mLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"m",
".",
"shutdown",
... | // RegisterAndRun registers the manager and starts it in a separate goroutine | [
"RegisterAndRun",
"registers",
"the",
"manager",
"and",
"starts",
"it",
"in",
"a",
"separate",
"goroutine"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/group.go#L35-L46 |
132,432 | hashicorp/nomad | client/pluginmanager/group.go | WaitForFirstFingerprint | func (m *PluginGroup) WaitForFirstFingerprint(ctx context.Context) (<-chan struct{}, error) {
m.mLock.Lock()
defer m.mLock.Unlock()
if m.shutdown {
return nil, fmt.Errorf("plugin group already shutdown")
}
var wg sync.WaitGroup
for i := range m.managers {
manager, ok := m.managers[i].(FingerprintingPluginMan... | go | func (m *PluginGroup) WaitForFirstFingerprint(ctx context.Context) (<-chan struct{}, error) {
m.mLock.Lock()
defer m.mLock.Unlock()
if m.shutdown {
return nil, fmt.Errorf("plugin group already shutdown")
}
var wg sync.WaitGroup
for i := range m.managers {
manager, ok := m.managers[i].(FingerprintingPluginMan... | [
"func",
"(",
"m",
"*",
"PluginGroup",
")",
"WaitForFirstFingerprint",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"struct",
"{",
"}",
",",
"error",
")",
"{",
"m",
".",
"mLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mLo... | // Ready returns a channel which will be closed once all plugin managers are ready.
// A timeout for waiting on each manager is given | [
"Ready",
"returns",
"a",
"channel",
"which",
"will",
"be",
"closed",
"once",
"all",
"plugin",
"managers",
"are",
"ready",
".",
"A",
"timeout",
"for",
"waiting",
"on",
"each",
"manager",
"is",
"given"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/group.go#L50-L86 |
132,433 | hashicorp/nomad | client/pluginmanager/group.go | Shutdown | func (m *PluginGroup) Shutdown() {
m.mLock.Lock()
defer m.mLock.Unlock()
for i := len(m.managers) - 1; i >= 0; i-- {
m.logger.Info("shutting down plugin manager", "plugin-type", m.managers[i].PluginType())
m.managers[i].Shutdown()
m.logger.Info("plugin manager finished", "plugin-type", m.managers[i].PluginType... | go | func (m *PluginGroup) Shutdown() {
m.mLock.Lock()
defer m.mLock.Unlock()
for i := len(m.managers) - 1; i >= 0; i-- {
m.logger.Info("shutting down plugin manager", "plugin-type", m.managers[i].PluginType())
m.managers[i].Shutdown()
m.logger.Info("plugin manager finished", "plugin-type", m.managers[i].PluginType... | [
"func",
"(",
"m",
"*",
"PluginGroup",
")",
"Shutdown",
"(",
")",
"{",
"m",
".",
"mLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mLock",
".",
"Unlock",
"(",
")",
"\n",
"for",
"i",
":=",
"len",
"(",
"m",
".",
"managers",
")",
"-",
"1"... | // Shutdown shutsdown all registered PluginManagers in reverse order of how
// they were started. | [
"Shutdown",
"shutsdown",
"all",
"registered",
"PluginManagers",
"in",
"reverse",
"order",
"of",
"how",
"they",
"were",
"started",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/group.go#L90-L99 |
132,434 | hashicorp/nomad | nomad/drainer/watch_jobs.go | NewDrainingJobWatcher | func NewDrainingJobWatcher(ctx context.Context, limiter *rate.Limiter, state *state.StateStore, logger log.Logger) *drainingJobWatcher {
// Create a context that can cancel the blocking query so that when a new
// job gets registered it is handled.
queryCtx, queryCancel := context.WithCancel(ctx)
w := &drainingJo... | go | func NewDrainingJobWatcher(ctx context.Context, limiter *rate.Limiter, state *state.StateStore, logger log.Logger) *drainingJobWatcher {
// Create a context that can cancel the blocking query so that when a new
// job gets registered it is handled.
queryCtx, queryCancel := context.WithCancel(ctx)
w := &drainingJo... | [
"func",
"NewDrainingJobWatcher",
"(",
"ctx",
"context",
".",
"Context",
",",
"limiter",
"*",
"rate",
".",
"Limiter",
",",
"state",
"*",
"state",
".",
"StateStore",
",",
"logger",
"log",
".",
"Logger",
")",
"*",
"drainingJobWatcher",
"{",
"// Create a context t... | // NewDrainingJobWatcher returns a new job watcher. The caller is expected to
// cancel the context to clean up the drainer. | [
"NewDrainingJobWatcher",
"returns",
"a",
"new",
"job",
"watcher",
".",
"The",
"caller",
"is",
"expected",
"to",
"cancel",
"the",
"context",
"to",
"clean",
"up",
"the",
"drainer",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L71-L91 |
132,435 | hashicorp/nomad | nomad/drainer/watch_jobs.go | RegisterJobs | func (w *drainingJobWatcher) RegisterJobs(jobs []structs.NamespacedID) {
w.l.Lock()
defer w.l.Unlock()
updated := false
for _, jns := range jobs {
if _, ok := w.jobs[jns]; ok {
continue
}
// Add the job and cancel the context
w.logger.Trace("registering job", "job", jns)
w.jobs[jns] = struct{}{}
up... | go | func (w *drainingJobWatcher) RegisterJobs(jobs []structs.NamespacedID) {
w.l.Lock()
defer w.l.Unlock()
updated := false
for _, jns := range jobs {
if _, ok := w.jobs[jns]; ok {
continue
}
// Add the job and cancel the context
w.logger.Trace("registering job", "job", jns)
w.jobs[jns] = struct{}{}
up... | [
"func",
"(",
"w",
"*",
"drainingJobWatcher",
")",
"RegisterJobs",
"(",
"jobs",
"[",
"]",
"structs",
".",
"NamespacedID",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"updated",
":=",... | // RegisterJob marks the given job as draining and adds it to being watched. | [
"RegisterJob",
"marks",
"the",
"given",
"job",
"as",
"draining",
"and",
"adds",
"it",
"to",
"being",
"watched",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L94-L116 |
132,436 | hashicorp/nomad | nomad/drainer/watch_jobs.go | deregisterJob | func (w *drainingJobWatcher) deregisterJob(jobID, namespace string) {
w.l.Lock()
defer w.l.Unlock()
jns := structs.NamespacedID{
ID: jobID,
Namespace: namespace,
}
delete(w.jobs, jns)
w.logger.Trace("deregistering job", "job", jns)
} | go | func (w *drainingJobWatcher) deregisterJob(jobID, namespace string) {
w.l.Lock()
defer w.l.Unlock()
jns := structs.NamespacedID{
ID: jobID,
Namespace: namespace,
}
delete(w.jobs, jns)
w.logger.Trace("deregistering job", "job", jns)
} | [
"func",
"(",
"w",
"*",
"drainingJobWatcher",
")",
"deregisterJob",
"(",
"jobID",
",",
"namespace",
"string",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"jns",
":=",
"structs",
".",
... | // deregisterJob removes the job from being watched. | [
"deregisterJob",
"removes",
"the",
"job",
"from",
"being",
"watched",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L130-L139 |
132,437 | hashicorp/nomad | nomad/drainer/watch_jobs.go | handleJob | func handleJob(snap *state.StateSnapshot, job *structs.Job, allocs []*structs.Allocation, lastHandledIndex uint64) (*jobResult, error) {
r := newJobResult()
batch := job.Type == structs.JobTypeBatch
taskGroups := make(map[string]*structs.TaskGroup, len(job.TaskGroups))
for _, tg := range job.TaskGroups {
// Only ... | go | func handleJob(snap *state.StateSnapshot, job *structs.Job, allocs []*structs.Allocation, lastHandledIndex uint64) (*jobResult, error) {
r := newJobResult()
batch := job.Type == structs.JobTypeBatch
taskGroups := make(map[string]*structs.TaskGroup, len(job.TaskGroups))
for _, tg := range job.TaskGroups {
// Only ... | [
"func",
"handleJob",
"(",
"snap",
"*",
"state",
".",
"StateSnapshot",
",",
"job",
"*",
"structs",
".",
"Job",
",",
"allocs",
"[",
"]",
"*",
"structs",
".",
"Allocation",
",",
"lastHandledIndex",
"uint64",
")",
"(",
"*",
"jobResult",
",",
"error",
")",
... | // handleJob takes the state of a draining job and returns the desired actions. | [
"handleJob",
"takes",
"the",
"state",
"of",
"a",
"draining",
"job",
"and",
"returns",
"the",
"desired",
"actions",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L301-L331 |
132,438 | hashicorp/nomad | nomad/drainer/watch_jobs.go | handleTaskGroup | func handleTaskGroup(snap *state.StateSnapshot, batch bool, tg *structs.TaskGroup,
allocs []*structs.Allocation, lastHandledIndex uint64, result *jobResult) error {
// Determine how many allocations can be drained
drainingNodes := make(map[string]bool, 4)
healthy := 0
remainingDrainingAlloc := false
var drainabl... | go | func handleTaskGroup(snap *state.StateSnapshot, batch bool, tg *structs.TaskGroup,
allocs []*structs.Allocation, lastHandledIndex uint64, result *jobResult) error {
// Determine how many allocations can be drained
drainingNodes := make(map[string]bool, 4)
healthy := 0
remainingDrainingAlloc := false
var drainabl... | [
"func",
"handleTaskGroup",
"(",
"snap",
"*",
"state",
".",
"StateSnapshot",
",",
"batch",
"bool",
",",
"tg",
"*",
"structs",
".",
"TaskGroup",
",",
"allocs",
"[",
"]",
"*",
"structs",
".",
"Allocation",
",",
"lastHandledIndex",
"uint64",
",",
"result",
"*"... | // handleTaskGroup takes the state of a draining task group and computes the
// desired actions. For batch jobs we only notify when they have been migrated
// and never mark them for drain. Batch jobs are allowed to complete up until
// the deadline, after which they are force killed. | [
"handleTaskGroup",
"takes",
"the",
"state",
"of",
"a",
"draining",
"task",
"group",
"and",
"computes",
"the",
"desired",
"actions",
".",
"For",
"batch",
"jobs",
"we",
"only",
"notify",
"when",
"they",
"have",
"been",
"migrated",
"and",
"never",
"mark",
"them... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L337-L416 |
132,439 | hashicorp/nomad | nomad/drainer/watch_jobs.go | getJobAllocs | func (w *drainingJobWatcher) getJobAllocs(ctx context.Context, minIndex uint64) (map[structs.NamespacedID][]*structs.Allocation, uint64, error) {
if err := w.limiter.Wait(ctx); err != nil {
return nil, 0, err
}
resp, index, err := w.state.BlockingQuery(w.getJobAllocsImpl, minIndex, ctx)
if err != nil {
return ... | go | func (w *drainingJobWatcher) getJobAllocs(ctx context.Context, minIndex uint64) (map[structs.NamespacedID][]*structs.Allocation, uint64, error) {
if err := w.limiter.Wait(ctx); err != nil {
return nil, 0, err
}
resp, index, err := w.state.BlockingQuery(w.getJobAllocsImpl, minIndex, ctx)
if err != nil {
return ... | [
"func",
"(",
"w",
"*",
"drainingJobWatcher",
")",
"getJobAllocs",
"(",
"ctx",
"context",
".",
"Context",
",",
"minIndex",
"uint64",
")",
"(",
"map",
"[",
"structs",
".",
"NamespacedID",
"]",
"[",
"]",
"*",
"structs",
".",
"Allocation",
",",
"uint64",
","... | // getJobAllocs returns all allocations for draining jobs | [
"getJobAllocs",
"returns",
"all",
"allocations",
"for",
"draining",
"jobs"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L419-L433 |
132,440 | hashicorp/nomad | nomad/drainer/watch_jobs.go | getJobAllocsImpl | func (w *drainingJobWatcher) getJobAllocsImpl(ws memdb.WatchSet, state *state.StateStore) (interface{}, uint64, error) {
index, err := state.Index("allocs")
if err != nil {
return nil, 0, err
}
// Capture the draining jobs.
draining := w.drainingJobs()
l := len(draining)
if l == 0 {
return nil, index, nil
... | go | func (w *drainingJobWatcher) getJobAllocsImpl(ws memdb.WatchSet, state *state.StateStore) (interface{}, uint64, error) {
index, err := state.Index("allocs")
if err != nil {
return nil, 0, err
}
// Capture the draining jobs.
draining := w.drainingJobs()
l := len(draining)
if l == 0 {
return nil, index, nil
... | [
"func",
"(",
"w",
"*",
"drainingJobWatcher",
")",
"getJobAllocsImpl",
"(",
"ws",
"memdb",
".",
"WatchSet",
",",
"state",
"*",
"state",
".",
"StateStore",
")",
"(",
"interface",
"{",
"}",
",",
"uint64",
",",
"error",
")",
"{",
"index",
",",
"err",
":=",... | // getJobAllocsImpl returns a map of draining jobs to their allocations. | [
"getJobAllocsImpl",
"returns",
"a",
"map",
"of",
"draining",
"jobs",
"to",
"their",
"allocations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L436-L473 |
132,441 | hashicorp/nomad | nomad/drainer/watch_jobs.go | drainingJobs | func (w *drainingJobWatcher) drainingJobs() map[structs.NamespacedID]struct{} {
w.l.RLock()
defer w.l.RUnlock()
l := len(w.jobs)
if l == 0 {
return nil
}
draining := make(map[structs.NamespacedID]struct{}, l)
for k := range w.jobs {
draining[k] = struct{}{}
}
return draining
} | go | func (w *drainingJobWatcher) drainingJobs() map[structs.NamespacedID]struct{} {
w.l.RLock()
defer w.l.RUnlock()
l := len(w.jobs)
if l == 0 {
return nil
}
draining := make(map[structs.NamespacedID]struct{}, l)
for k := range w.jobs {
draining[k] = struct{}{}
}
return draining
} | [
"func",
"(",
"w",
"*",
"drainingJobWatcher",
")",
"drainingJobs",
"(",
")",
"map",
"[",
"structs",
".",
"NamespacedID",
"]",
"struct",
"{",
"}",
"{",
"w",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"RUnlock",
"(",
")",
"... | // drainingJobs captures the set of draining jobs. | [
"drainingJobs",
"captures",
"the",
"set",
"of",
"draining",
"jobs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L476-L491 |
132,442 | hashicorp/nomad | nomad/drainer/watch_jobs.go | getQueryCtx | func (w *drainingJobWatcher) getQueryCtx() context.Context {
w.l.RLock()
defer w.l.RUnlock()
return w.queryCtx
} | go | func (w *drainingJobWatcher) getQueryCtx() context.Context {
w.l.RLock()
defer w.l.RUnlock()
return w.queryCtx
} | [
"func",
"(",
"w",
"*",
"drainingJobWatcher",
")",
"getQueryCtx",
"(",
")",
"context",
".",
"Context",
"{",
"w",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"w",
".",
"queryCtx",
"\n",
... | // getQueryCtx is a helper for getting the query context. | [
"getQueryCtx",
"is",
"a",
"helper",
"for",
"getting",
"the",
"query",
"context",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_jobs.go#L494-L498 |
132,443 | hashicorp/nomad | nomad/blocked_evals.go | NewBlockedEvals | func NewBlockedEvals(evalBroker *EvalBroker, logger log.Logger) *BlockedEvals {
return &BlockedEvals{
logger: logger.Named("blocked_evals"),
evalBroker: evalBroker,
captured: make(map[string]wrappedEval),
escaped: make(map[string]wrappedEval),
jobs: make(map[struc... | go | func NewBlockedEvals(evalBroker *EvalBroker, logger log.Logger) *BlockedEvals {
return &BlockedEvals{
logger: logger.Named("blocked_evals"),
evalBroker: evalBroker,
captured: make(map[string]wrappedEval),
escaped: make(map[string]wrappedEval),
jobs: make(map[struc... | [
"func",
"NewBlockedEvals",
"(",
"evalBroker",
"*",
"EvalBroker",
",",
"logger",
"log",
".",
"Logger",
")",
"*",
"BlockedEvals",
"{",
"return",
"&",
"BlockedEvals",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"evalBroker",
":",
... | // NewBlockedEvals creates a new blocked eval tracker that will enqueue
// unblocked evals into the passed broker. | [
"NewBlockedEvals",
"creates",
"a",
"new",
"blocked",
"eval",
"tracker",
"that",
"will",
"enqueue",
"unblocked",
"evals",
"into",
"the",
"passed",
"broker",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L110-L123 |
132,444 | hashicorp/nomad | nomad/blocked_evals.go | SetEnabled | func (b *BlockedEvals) SetEnabled(enabled bool) {
b.l.Lock()
if b.enabled == enabled {
// No-op
b.l.Unlock()
return
} else if enabled {
go b.watchCapacity(b.stopCh, b.capacityChangeCh)
go b.prune(b.stopCh)
} else {
close(b.stopCh)
}
b.enabled = enabled
b.l.Unlock()
if !enabled {
b.Flush()
}
} | go | func (b *BlockedEvals) SetEnabled(enabled bool) {
b.l.Lock()
if b.enabled == enabled {
// No-op
b.l.Unlock()
return
} else if enabled {
go b.watchCapacity(b.stopCh, b.capacityChangeCh)
go b.prune(b.stopCh)
} else {
close(b.stopCh)
}
b.enabled = enabled
b.l.Unlock()
if !enabled {
b.Flush()
}
} | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"SetEnabled",
"(",
"enabled",
"bool",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"if",
"b",
".",
"enabled",
"==",
"enabled",
"{",
"// No-op",
"b",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"... | // SetEnabled is used to control if the blocked eval tracker is enabled. The
// tracker should only be enabled on the active leader. | [
"SetEnabled",
"is",
"used",
"to",
"control",
"if",
"the",
"blocked",
"eval",
"tracker",
"is",
"enabled",
".",
"The",
"tracker",
"should",
"only",
"be",
"enabled",
"on",
"the",
"active",
"leader",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L134-L151 |
132,445 | hashicorp/nomad | nomad/blocked_evals.go | Reblock | func (b *BlockedEvals) Reblock(eval *structs.Evaluation, token string) {
b.processBlock(eval, token)
} | go | func (b *BlockedEvals) Reblock(eval *structs.Evaluation, token string) {
b.processBlock(eval, token)
} | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"Reblock",
"(",
"eval",
"*",
"structs",
".",
"Evaluation",
",",
"token",
"string",
")",
"{",
"b",
".",
"processBlock",
"(",
"eval",
",",
"token",
")",
"\n",
"}"
] | // Reblock tracks the passed evaluation and enqueues it into the eval broker when
// a suitable node calls unblock. Reblock should be used over Block when the
// blocking is occurring by an outstanding evaluation. The token is the
// evaluation's token. | [
"Reblock",
"tracks",
"the",
"passed",
"evaluation",
"and",
"enqueues",
"it",
"into",
"the",
"eval",
"broker",
"when",
"a",
"suitable",
"node",
"calls",
"unblock",
".",
"Reblock",
"should",
"be",
"used",
"over",
"Block",
"when",
"the",
"blocking",
"is",
"occu... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L169-L171 |
132,446 | hashicorp/nomad | nomad/blocked_evals.go | processBlock | func (b *BlockedEvals) processBlock(eval *structs.Evaluation, token string) {
b.l.Lock()
defer b.l.Unlock()
// Do nothing if not enabled
if !b.enabled {
return
}
// Handle the new evaluation being for a job we are already tracking.
if b.processBlockJobDuplicate(eval) {
// If process block job duplicate ret... | go | func (b *BlockedEvals) processBlock(eval *structs.Evaluation, token string) {
b.l.Lock()
defer b.l.Unlock()
// Do nothing if not enabled
if !b.enabled {
return
}
// Handle the new evaluation being for a job we are already tracking.
if b.processBlockJobDuplicate(eval) {
// If process block job duplicate ret... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"processBlock",
"(",
"eval",
"*",
"structs",
".",
"Evaluation",
",",
"token",
"string",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"//... | // processBlock is the implementation of blocking an evaluation. It supports
// taking an optional evaluation token to use when reblocking an evaluation that
// may be outstanding. | [
"processBlock",
"is",
"the",
"implementation",
"of",
"blocking",
"an",
"evaluation",
".",
"It",
"supports",
"taking",
"an",
"optional",
"evaluation",
"token",
"to",
"use",
"when",
"reblocking",
"an",
"evaluation",
"that",
"may",
"be",
"outstanding",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L176-L233 |
132,447 | hashicorp/nomad | nomad/blocked_evals.go | processBlockJobDuplicate | func (b *BlockedEvals) processBlockJobDuplicate(eval *structs.Evaluation) (newCancelled bool) {
existingID, hasExisting := b.jobs[structs.NewNamespacedID(eval.JobID, eval.Namespace)]
if !hasExisting {
return
}
var dup *structs.Evaluation
existingW, ok := b.captured[existingID]
if ok {
if latestEvalIndex(exis... | go | func (b *BlockedEvals) processBlockJobDuplicate(eval *structs.Evaluation) (newCancelled bool) {
existingID, hasExisting := b.jobs[structs.NewNamespacedID(eval.JobID, eval.Namespace)]
if !hasExisting {
return
}
var dup *structs.Evaluation
existingW, ok := b.captured[existingID]
if ok {
if latestEvalIndex(exis... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"processBlockJobDuplicate",
"(",
"eval",
"*",
"structs",
".",
"Evaluation",
")",
"(",
"newCancelled",
"bool",
")",
"{",
"existingID",
",",
"hasExisting",
":=",
"b",
".",
"jobs",
"[",
"structs",
".",
"NewNamespacedI... | // processBlockJobDuplicate handles the case where the new eval is for a job
// that we are already tracking. If the eval is a duplicate, we add the older
// evaluation by Raft index to the list of duplicates such that it can be
// cancelled. We only ever want one blocked evaluation per job, otherwise we
// would creat... | [
"processBlockJobDuplicate",
"handles",
"the",
"case",
"where",
"the",
"new",
"eval",
"is",
"for",
"a",
"job",
"that",
"we",
"are",
"already",
"tracking",
".",
"If",
"the",
"eval",
"is",
"a",
"duplicate",
"we",
"add",
"the",
"older",
"evaluation",
"by",
"Ra... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L244-L289 |
132,448 | hashicorp/nomad | nomad/blocked_evals.go | missedUnblock | func (b *BlockedEvals) missedUnblock(eval *structs.Evaluation) bool {
var max uint64 = 0
for id, index := range b.unblockIndexes {
// Calculate the max unblock index
if max < index {
max = index
}
// The evaluation is blocked because it has hit a quota limit not class
// eligibility
if eval.QuotaLimit... | go | func (b *BlockedEvals) missedUnblock(eval *structs.Evaluation) bool {
var max uint64 = 0
for id, index := range b.unblockIndexes {
// Calculate the max unblock index
if max < index {
max = index
}
// The evaluation is blocked because it has hit a quota limit not class
// eligibility
if eval.QuotaLimit... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"missedUnblock",
"(",
"eval",
"*",
"structs",
".",
"Evaluation",
")",
"bool",
"{",
"var",
"max",
"uint64",
"=",
"0",
"\n",
"for",
"id",
",",
"index",
":=",
"range",
"b",
".",
"unblockIndexes",
"{",
"// Calcul... | // missedUnblock returns whether an evaluation missed an unblock while it was in
// the scheduler. Since the scheduler can operate at an index in the past, the
// evaluation may have been processed missing data that would allow it to
// complete. This method returns if that is the case and should be called with
// the ... | [
"missedUnblock",
"returns",
"whether",
"an",
"evaluation",
"missed",
"an",
"unblock",
"while",
"it",
"was",
"in",
"the",
"scheduler",
".",
"Since",
"the",
"scheduler",
"can",
"operate",
"at",
"an",
"index",
"in",
"the",
"past",
"the",
"evaluation",
"may",
"h... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L305-L352 |
132,449 | hashicorp/nomad | nomad/blocked_evals.go | Untrack | func (b *BlockedEvals) Untrack(jobID, namespace string) {
b.l.Lock()
defer b.l.Unlock()
// Do nothing if not enabled
if !b.enabled {
return
}
nsID := structs.NewNamespacedID(jobID, namespace)
// Get the evaluation ID to cancel
evalID, ok := b.jobs[nsID]
if !ok {
// No blocked evaluation so exit
return... | go | func (b *BlockedEvals) Untrack(jobID, namespace string) {
b.l.Lock()
defer b.l.Unlock()
// Do nothing if not enabled
if !b.enabled {
return
}
nsID := structs.NewNamespacedID(jobID, namespace)
// Get the evaluation ID to cancel
evalID, ok := b.jobs[nsID]
if !ok {
// No blocked evaluation so exit
return... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"Untrack",
"(",
"jobID",
",",
"namespace",
"string",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// Do nothing if not enabled",
"if",
"!",... | // Untrack causes any blocked evaluation for the passed job to be no longer
// tracked. Untrack is called when there is a successful evaluation for the job
// and a blocked evaluation is no longer needed. | [
"Untrack",
"causes",
"any",
"blocked",
"evaluation",
"for",
"the",
"passed",
"job",
"to",
"be",
"no",
"longer",
"tracked",
".",
"Untrack",
"is",
"called",
"when",
"there",
"is",
"a",
"successful",
"evaluation",
"for",
"the",
"job",
"and",
"a",
"blocked",
"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L357-L394 |
132,450 | hashicorp/nomad | nomad/blocked_evals.go | Unblock | func (b *BlockedEvals) Unblock(computedClass string, index uint64) {
b.l.Lock()
// Do nothing if not enabled
if !b.enabled {
b.l.Unlock()
return
}
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger
// occurre... | go | func (b *BlockedEvals) Unblock(computedClass string, index uint64) {
b.l.Lock()
// Do nothing if not enabled
if !b.enabled {
b.l.Unlock()
return
}
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger
// occurre... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"Unblock",
"(",
"computedClass",
"string",
",",
"index",
"uint64",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n\n",
"// Do nothing if not enabled",
"if",
"!",
"b",
".",
"enabled",
"{",
"b",
".",
"l",
... | // Unblock causes any evaluation that could potentially make progress on a
// capacity change on the passed computed node class to be enqueued into the
// eval broker. | [
"Unblock",
"causes",
"any",
"evaluation",
"that",
"could",
"potentially",
"make",
"progress",
"on",
"a",
"capacity",
"change",
"on",
"the",
"passed",
"computed",
"node",
"class",
"to",
"be",
"enqueued",
"into",
"the",
"eval",
"broker",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L399-L418 |
132,451 | hashicorp/nomad | nomad/blocked_evals.go | UnblockQuota | func (b *BlockedEvals) UnblockQuota(quota string, index uint64) {
// Nothing to do
if quota == "" {
return
}
b.l.Lock()
// Do nothing if not enabled
if !b.enabled {
b.l.Unlock()
return
}
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation w... | go | func (b *BlockedEvals) UnblockQuota(quota string, index uint64) {
// Nothing to do
if quota == "" {
return
}
b.l.Lock()
// Do nothing if not enabled
if !b.enabled {
b.l.Unlock()
return
}
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation w... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"UnblockQuota",
"(",
"quota",
"string",
",",
"index",
"uint64",
")",
"{",
"// Nothing to do",
"if",
"quota",
"==",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n\n",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n\n",... | // UnblockQuota causes any evaluation that could potentially make progress on a
// capacity change on the passed quota to be enqueued into the eval broker. | [
"UnblockQuota",
"causes",
"any",
"evaluation",
"that",
"could",
"potentially",
"make",
"progress",
"on",
"a",
"capacity",
"change",
"on",
"the",
"passed",
"quota",
"to",
"be",
"enqueued",
"into",
"the",
"eval",
"broker",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L422-L446 |
132,452 | hashicorp/nomad | nomad/blocked_evals.go | UnblockClassAndQuota | func (b *BlockedEvals) UnblockClassAndQuota(class, quota string, index uint64) {
b.l.Lock()
// Do nothing if not enabled
if !b.enabled {
b.l.Unlock()
return
}
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger... | go | func (b *BlockedEvals) UnblockClassAndQuota(class, quota string, index uint64) {
b.l.Lock()
// Do nothing if not enabled
if !b.enabled {
b.l.Unlock()
return
}
// Store the index in which the unblock happened. We use this on subsequent
// block calls in case the evaluation was in the scheduler when a trigger... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"UnblockClassAndQuota",
"(",
"class",
",",
"quota",
"string",
",",
"index",
"uint64",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n\n",
"// Do nothing if not enabled",
"if",
"!",
"b",
".",
"enabled",
"{",... | // UnblockClassAndQuota causes any evaluation that could potentially make
// progress on a capacity change on the passed computed node class or quota to
// be enqueued into the eval broker. | [
"UnblockClassAndQuota",
"causes",
"any",
"evaluation",
"that",
"could",
"potentially",
"make",
"progress",
"on",
"a",
"capacity",
"change",
"on",
"the",
"passed",
"computed",
"node",
"class",
"or",
"quota",
"to",
"be",
"enqueued",
"into",
"the",
"eval",
"broker"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L451-L474 |
132,453 | hashicorp/nomad | nomad/blocked_evals.go | watchCapacity | func (b *BlockedEvals) watchCapacity(stopCh <-chan struct{}, changeCh <-chan *capacityUpdate) {
for {
select {
case <-stopCh:
return
case update := <-changeCh:
b.unblock(update.computedClass, update.quotaChange, update.index)
}
}
} | go | func (b *BlockedEvals) watchCapacity(stopCh <-chan struct{}, changeCh <-chan *capacityUpdate) {
for {
select {
case <-stopCh:
return
case update := <-changeCh:
b.unblock(update.computedClass, update.quotaChange, update.index)
}
}
} | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"watchCapacity",
"(",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
",",
"changeCh",
"<-",
"chan",
"*",
"capacityUpdate",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"stopCh",
":",
"return",
"\n",
"case"... | // watchCapacity is a long lived function that watches for capacity changes in
// nodes and unblocks the correct set of evals. | [
"watchCapacity",
"is",
"a",
"long",
"lived",
"function",
"that",
"watches",
"for",
"capacity",
"changes",
"in",
"nodes",
"and",
"unblocks",
"the",
"correct",
"set",
"of",
"evals",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L478-L487 |
132,454 | hashicorp/nomad | nomad/blocked_evals.go | UnblockFailed | func (b *BlockedEvals) UnblockFailed() {
b.l.Lock()
defer b.l.Unlock()
// Do nothing if not enabled
if !b.enabled {
return
}
quotaLimit := 0
unblocked := make(map[*structs.Evaluation]string, 4)
for id, wrapped := range b.captured {
if wrapped.eval.TriggeredBy == structs.EvalTriggerMaxPlans {
unblocked[... | go | func (b *BlockedEvals) UnblockFailed() {
b.l.Lock()
defer b.l.Unlock()
// Do nothing if not enabled
if !b.enabled {
return
}
quotaLimit := 0
unblocked := make(map[*structs.Evaluation]string, 4)
for id, wrapped := range b.captured {
if wrapped.eval.TriggeredBy == structs.EvalTriggerMaxPlans {
unblocked[... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"UnblockFailed",
"(",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// Do nothing if not enabled",
"if",
"!",
"b",
".",
"enabled",
"{",
"r... | // UnblockFailed unblocks all blocked evaluation that were due to scheduler
// failure. | [
"UnblockFailed",
"unblocks",
"all",
"blocked",
"evaluation",
"that",
"were",
"due",
"to",
"scheduler",
"failure",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L555-L594 |
132,455 | hashicorp/nomad | nomad/blocked_evals.go | GetDuplicates | func (b *BlockedEvals) GetDuplicates(timeout time.Duration) []*structs.Evaluation {
var timeoutTimer *time.Timer
var timeoutCh <-chan time.Time
SCAN:
b.l.Lock()
if len(b.duplicates) != 0 {
dups := b.duplicates
b.duplicates = nil
b.l.Unlock()
return dups
}
// Capture chans inside the lock to prevent a rac... | go | func (b *BlockedEvals) GetDuplicates(timeout time.Duration) []*structs.Evaluation {
var timeoutTimer *time.Timer
var timeoutCh <-chan time.Time
SCAN:
b.l.Lock()
if len(b.duplicates) != 0 {
dups := b.duplicates
b.duplicates = nil
b.l.Unlock()
return dups
}
// Capture chans inside the lock to prevent a rac... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"GetDuplicates",
"(",
"timeout",
"time",
".",
"Duration",
")",
"[",
"]",
"*",
"structs",
".",
"Evaluation",
"{",
"var",
"timeoutTimer",
"*",
"time",
".",
"Timer",
"\n",
"var",
"timeoutCh",
"<-",
"chan",
"time",... | // GetDuplicates returns all the duplicate evaluations and blocks until the
// passed timeout. | [
"GetDuplicates",
"returns",
"all",
"the",
"duplicate",
"evaluations",
"and",
"blocks",
"until",
"the",
"passed",
"timeout",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L598-L631 |
132,456 | hashicorp/nomad | nomad/blocked_evals.go | Flush | func (b *BlockedEvals) Flush() {
b.l.Lock()
defer b.l.Unlock()
// Reset the blocked eval tracker.
b.stats.TotalEscaped = 0
b.stats.TotalBlocked = 0
b.stats.TotalQuotaLimit = 0
b.captured = make(map[string]wrappedEval)
b.escaped = make(map[string]wrappedEval)
b.jobs = make(map[structs.NamespacedID]string)
b.u... | go | func (b *BlockedEvals) Flush() {
b.l.Lock()
defer b.l.Unlock()
// Reset the blocked eval tracker.
b.stats.TotalEscaped = 0
b.stats.TotalBlocked = 0
b.stats.TotalQuotaLimit = 0
b.captured = make(map[string]wrappedEval)
b.escaped = make(map[string]wrappedEval)
b.jobs = make(map[structs.NamespacedID]string)
b.u... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"Flush",
"(",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// Reset the blocked eval tracker.",
"b",
".",
"stats",
".",
"TotalEscaped",
"="... | // Flush is used to clear the state of blocked evaluations. | [
"Flush",
"is",
"used",
"to",
"clear",
"the",
"state",
"of",
"blocked",
"evaluations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L634-L651 |
132,457 | hashicorp/nomad | nomad/blocked_evals.go | Stats | func (b *BlockedEvals) Stats() *BlockedStats {
// Allocate a new stats struct
stats := new(BlockedStats)
b.l.RLock()
defer b.l.RUnlock()
// Copy all the stats
stats.TotalEscaped = b.stats.TotalEscaped
stats.TotalBlocked = b.stats.TotalBlocked
stats.TotalQuotaLimit = b.stats.TotalQuotaLimit
return stats
} | go | func (b *BlockedEvals) Stats() *BlockedStats {
// Allocate a new stats struct
stats := new(BlockedStats)
b.l.RLock()
defer b.l.RUnlock()
// Copy all the stats
stats.TotalEscaped = b.stats.TotalEscaped
stats.TotalBlocked = b.stats.TotalBlocked
stats.TotalQuotaLimit = b.stats.TotalQuotaLimit
return stats
} | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"Stats",
"(",
")",
"*",
"BlockedStats",
"{",
"// Allocate a new stats struct",
"stats",
":=",
"new",
"(",
"BlockedStats",
")",
"\n\n",
"b",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"b",
".",
"l",
".",... | // Stats is used to query the state of the blocked eval tracker. | [
"Stats",
"is",
"used",
"to",
"query",
"the",
"state",
"of",
"the",
"blocked",
"eval",
"tracker",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L654-L666 |
132,458 | hashicorp/nomad | nomad/blocked_evals.go | prune | func (b *BlockedEvals) prune(stopCh <-chan struct{}) {
ticker := time.NewTicker(pruneInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return
case <-ticker.C:
b.pruneUnblockIndexes()
}
}
} | go | func (b *BlockedEvals) prune(stopCh <-chan struct{}) {
ticker := time.NewTicker(pruneInterval)
defer ticker.Stop()
for {
select {
case <-stopCh:
return
case <-ticker.C:
b.pruneUnblockIndexes()
}
}
} | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"prune",
"(",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"pruneInterval",
")",
"\n",
"defer",
"ticker",
".",
"Stop",
"(",
")",
"\n\n",
"for",
"{",
... | // prune is a long lived function that prunes unnecessary objects on a timer. | [
"prune",
"is",
"a",
"long",
"lived",
"function",
"that",
"prunes",
"unnecessary",
"objects",
"on",
"a",
"timer",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L684-L696 |
132,459 | hashicorp/nomad | nomad/blocked_evals.go | pruneUnblockIndexes | func (b *BlockedEvals) pruneUnblockIndexes() {
b.l.Lock()
defer b.l.Unlock()
if b.timetable == nil {
return
}
cutoff := time.Now().UTC().Add(-1 * pruneThreshold)
oldThreshold := b.timetable.NearestIndex(cutoff)
for key, index := range b.unblockIndexes {
if index < oldThreshold {
delete(b.unblockIndexes... | go | func (b *BlockedEvals) pruneUnblockIndexes() {
b.l.Lock()
defer b.l.Unlock()
if b.timetable == nil {
return
}
cutoff := time.Now().UTC().Add(-1 * pruneThreshold)
oldThreshold := b.timetable.NearestIndex(cutoff)
for key, index := range b.unblockIndexes {
if index < oldThreshold {
delete(b.unblockIndexes... | [
"func",
"(",
"b",
"*",
"BlockedEvals",
")",
"pruneUnblockIndexes",
"(",
")",
"{",
"b",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"timetable",
"==",
"nil",
"{",
"return",
"\n",
... | // pruneUnblockIndexes is used to prune any tracked entry that is excessively
// old. This protects againsts unbounded growth of the map. | [
"pruneUnblockIndexes",
"is",
"used",
"to",
"prune",
"any",
"tracked",
"entry",
"that",
"is",
"excessively",
"old",
".",
"This",
"protects",
"againsts",
"unbounded",
"growth",
"of",
"the",
"map",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/blocked_evals.go#L700-L716 |
132,460 | hashicorp/nomad | nomad/config.go | CheckVersion | func (c *Config) CheckVersion() error {
if c.ProtocolVersion < ProtocolVersionMin {
return fmt.Errorf("Protocol version '%d' too low. Must be in range: [%d, %d]",
c.ProtocolVersion, ProtocolVersionMin, ProtocolVersionMax)
} else if c.ProtocolVersion > ProtocolVersionMax {
return fmt.Errorf("Protocol version '%... | go | func (c *Config) CheckVersion() error {
if c.ProtocolVersion < ProtocolVersionMin {
return fmt.Errorf("Protocol version '%d' too low. Must be in range: [%d, %d]",
c.ProtocolVersion, ProtocolVersionMin, ProtocolVersionMax)
} else if c.ProtocolVersion > ProtocolVersionMax {
return fmt.Errorf("Protocol version '%... | [
"func",
"(",
"c",
"*",
"Config",
")",
"CheckVersion",
"(",
")",
"error",
"{",
"if",
"c",
".",
"ProtocolVersion",
"<",
"ProtocolVersionMin",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c",
".",
"ProtocolVersion",
",",
"ProtocolVersionMin",
... | // CheckVersion is used to check if the ProtocolVersion is valid | [
"CheckVersion",
"is",
"used",
"to",
"check",
"if",
"the",
"ProtocolVersion",
"is",
"valid"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/config.go#L313-L322 |
132,461 | hashicorp/nomad | client/fingerprint/consul.go | NewConsulFingerprint | func NewConsulFingerprint(logger log.Logger) Fingerprint {
return &ConsulFingerprint{logger: logger.Named("consul"), lastState: consulUnavailable}
} | go | func NewConsulFingerprint(logger log.Logger) Fingerprint {
return &ConsulFingerprint{logger: logger.Named("consul"), lastState: consulUnavailable}
} | [
"func",
"NewConsulFingerprint",
"(",
"logger",
"log",
".",
"Logger",
")",
"Fingerprint",
"{",
"return",
"&",
"ConsulFingerprint",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"lastState",
":",
"consulUnavailable",
"}",
"\n",
"}"
] | // NewConsulFingerprint is used to create a Consul fingerprint | [
"NewConsulFingerprint",
"is",
"used",
"to",
"create",
"a",
"Consul",
"fingerprint"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/consul.go#L25-L27 |
132,462 | hashicorp/nomad | client/fingerprint/consul.go | clearConsulAttributes | func (f *ConsulFingerprint) clearConsulAttributes(r *FingerprintResponse) {
r.RemoveAttribute("consul.server")
r.RemoveAttribute("consul.version")
r.RemoveAttribute("consul.revision")
r.RemoveAttribute("unique.consul.name")
r.RemoveAttribute("consul.datacenter")
r.RemoveLink("consul")
} | go | func (f *ConsulFingerprint) clearConsulAttributes(r *FingerprintResponse) {
r.RemoveAttribute("consul.server")
r.RemoveAttribute("consul.version")
r.RemoveAttribute("consul.revision")
r.RemoveAttribute("unique.consul.name")
r.RemoveAttribute("consul.datacenter")
r.RemoveLink("consul")
} | [
"func",
"(",
"f",
"*",
"ConsulFingerprint",
")",
"clearConsulAttributes",
"(",
"r",
"*",
"FingerprintResponse",
")",
"{",
"r",
".",
"RemoveAttribute",
"(",
"\"",
"\"",
")",
"\n",
"r",
".",
"RemoveAttribute",
"(",
"\"",
"\"",
")",
"\n",
"r",
".",
"RemoveA... | // clearConsulAttributes removes consul attributes and links from the passed
// Node. | [
"clearConsulAttributes",
"removes",
"consul",
"attributes",
"and",
"links",
"from",
"the",
"passed",
"Node",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/consul.go#L105-L112 |
132,463 | hashicorp/nomad | nomad/search_endpoint.go | getMatches | func (s *Search) getMatches(iter memdb.ResultIterator, prefix string) ([]string, bool) {
var matches []string
for i := 0; i < truncateLimit; i++ {
raw := iter.Next()
if raw == nil {
break
}
var id string
switch t := raw.(type) {
case *structs.Job:
id = raw.(*structs.Job).ID
case *structs.Evaluat... | go | func (s *Search) getMatches(iter memdb.ResultIterator, prefix string) ([]string, bool) {
var matches []string
for i := 0; i < truncateLimit; i++ {
raw := iter.Next()
if raw == nil {
break
}
var id string
switch t := raw.(type) {
case *structs.Job:
id = raw.(*structs.Job).ID
case *structs.Evaluat... | [
"func",
"(",
"s",
"*",
"Search",
")",
"getMatches",
"(",
"iter",
"memdb",
".",
"ResultIterator",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"bool",
")",
"{",
"var",
"matches",
"[",
"]",
"string",
"\n\n",
"for",
"i",
":=",
"0",
";",... | // getMatches extracts matches for an iterator, and returns a list of ids for
// these matches. | [
"getMatches",
"extracts",
"matches",
"for",
"an",
"iterator",
"and",
"returns",
"a",
"list",
"of",
"ids",
"for",
"these",
"matches",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/search_endpoint.go#L43-L82 |
132,464 | hashicorp/nomad | nomad/search_endpoint.go | getResourceIter | func getResourceIter(context structs.Context, aclObj *acl.ACL, namespace, prefix string, ws memdb.WatchSet, state *state.StateStore) (memdb.ResultIterator, error) {
switch context {
case structs.Jobs:
return state.JobsByIDPrefix(ws, namespace, prefix)
case structs.Evals:
return state.EvalsByIDPrefix(ws, namespac... | go | func getResourceIter(context structs.Context, aclObj *acl.ACL, namespace, prefix string, ws memdb.WatchSet, state *state.StateStore) (memdb.ResultIterator, error) {
switch context {
case structs.Jobs:
return state.JobsByIDPrefix(ws, namespace, prefix)
case structs.Evals:
return state.EvalsByIDPrefix(ws, namespac... | [
"func",
"getResourceIter",
"(",
"context",
"structs",
".",
"Context",
",",
"aclObj",
"*",
"acl",
".",
"ACL",
",",
"namespace",
",",
"prefix",
"string",
",",
"ws",
"memdb",
".",
"WatchSet",
",",
"state",
"*",
"state",
".",
"StateStore",
")",
"(",
"memdb",... | // getResourceIter takes a context and returns a memdb iterator specific to
// that context | [
"getResourceIter",
"takes",
"a",
"context",
"and",
"returns",
"a",
"memdb",
"iterator",
"specific",
"to",
"that",
"context"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/search_endpoint.go#L86-L101 |
132,465 | hashicorp/nomad | nomad/search_endpoint.go | roundUUIDDownIfOdd | func roundUUIDDownIfOdd(prefix string, context structs.Context) string {
if context == structs.Jobs {
return prefix
}
// We ignore the count of hyphens when calculating if the prefix is even:
// E.g "e3671fa4-21"
numHyphens := strings.Count(prefix, "-")
l := len(prefix) - numHyphens
if l%2 == 0 {
return pre... | go | func roundUUIDDownIfOdd(prefix string, context structs.Context) string {
if context == structs.Jobs {
return prefix
}
// We ignore the count of hyphens when calculating if the prefix is even:
// E.g "e3671fa4-21"
numHyphens := strings.Count(prefix, "-")
l := len(prefix) - numHyphens
if l%2 == 0 {
return pre... | [
"func",
"roundUUIDDownIfOdd",
"(",
"prefix",
"string",
",",
"context",
"structs",
".",
"Context",
")",
"string",
"{",
"if",
"context",
"==",
"structs",
".",
"Jobs",
"{",
"return",
"prefix",
"\n",
"}",
"\n\n",
"// We ignore the count of hyphens when calculating if th... | // If the length of a prefix is odd, return a subset to the last even character
// This only applies to UUIDs, jobs are excluded | [
"If",
"the",
"length",
"of",
"a",
"prefix",
"is",
"odd",
"return",
"a",
"subset",
"to",
"the",
"last",
"even",
"character",
"This",
"only",
"applies",
"to",
"UUIDs",
"jobs",
"are",
"excluded"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/search_endpoint.go#L105-L118 |
132,466 | hashicorp/nomad | client/allocdir/task_dir.go | Build | func (t *TaskDir) Build(createChroot bool, chroot map[string]string) error {
if err := os.MkdirAll(t.Dir, 0777); err != nil {
return err
}
// Make the task directory have non-root permissions.
if err := dropDirPermissions(t.Dir, os.ModePerm); err != nil {
return err
}
// Create a local directory that each t... | go | func (t *TaskDir) Build(createChroot bool, chroot map[string]string) error {
if err := os.MkdirAll(t.Dir, 0777); err != nil {
return err
}
// Make the task directory have non-root permissions.
if err := dropDirPermissions(t.Dir, os.ModePerm); err != nil {
return err
}
// Create a local directory that each t... | [
"func",
"(",
"t",
"*",
"TaskDir",
")",
"Build",
"(",
"createChroot",
"bool",
",",
"chroot",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"t",
".",
"Dir",
",",
"0777",
")",
";",
"err",
"!="... | // Build default directories and permissions in a task directory. chrootCreated
// allows skipping chroot creation if the caller knows it has already been
// done. | [
"Build",
"default",
"directories",
"and",
"permissions",
"in",
"a",
"task",
"directory",
".",
"chrootCreated",
"allows",
"skipping",
"chroot",
"creation",
"if",
"the",
"caller",
"knows",
"it",
"has",
"already",
"been",
"done",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/task_dir.go#L77-L139 |
132,467 | hashicorp/nomad | client/allocdir/task_dir.go | buildChroot | func (t *TaskDir) buildChroot(entries map[string]string) error {
return t.embedDirs(entries)
} | go | func (t *TaskDir) buildChroot(entries map[string]string) error {
return t.embedDirs(entries)
} | [
"func",
"(",
"t",
"*",
"TaskDir",
")",
"buildChroot",
"(",
"entries",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"t",
".",
"embedDirs",
"(",
"entries",
")",
"\n",
"}"
] | // buildChroot takes a mapping of absolute directory or file paths on the host
// to their intended, relative location within the task directory. This
// attempts hardlink and then defaults to copying. If the path exists on the
// host and can't be embedded an error is returned. | [
"buildChroot",
"takes",
"a",
"mapping",
"of",
"absolute",
"directory",
"or",
"file",
"paths",
"on",
"the",
"host",
"to",
"their",
"intended",
"relative",
"location",
"within",
"the",
"task",
"directory",
".",
"This",
"attempts",
"hardlink",
"and",
"then",
"def... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/task_dir.go#L145-L147 |
132,468 | hashicorp/nomad | nomad/fsm_registry_oss.go | persistEnterpriseTables | func (s *nomadSnapshot) persistEnterpriseTables(sink raft.SnapshotSink, encoder *codec.Encoder) error {
return nil
} | go | func (s *nomadSnapshot) persistEnterpriseTables(sink raft.SnapshotSink, encoder *codec.Encoder) error {
return nil
} | [
"func",
"(",
"s",
"*",
"nomadSnapshot",
")",
"persistEnterpriseTables",
"(",
"sink",
"raft",
".",
"SnapshotSink",
",",
"encoder",
"*",
"codec",
".",
"Encoder",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // persistEnterpriseTables is a no-op for open-source only FSMs. | [
"persistEnterpriseTables",
"is",
"a",
"no",
"-",
"op",
"for",
"open",
"-",
"source",
"only",
"FSMs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm_registry_oss.go#L17-L19 |
132,469 | hashicorp/nomad | nomad/structs/config/tls.go | LoadKeyPair | func (k *KeyLoader) LoadKeyPair(certFile, keyFile string) (*tls.Certificate, error) {
k.cacheLock.Lock()
defer k.cacheLock.Unlock()
// Allow downgrading
if certFile == "" && keyFile == "" {
k.certificate = nil
return nil, nil
}
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return ni... | go | func (k *KeyLoader) LoadKeyPair(certFile, keyFile string) (*tls.Certificate, error) {
k.cacheLock.Lock()
defer k.cacheLock.Unlock()
// Allow downgrading
if certFile == "" && keyFile == "" {
k.certificate = nil
return nil, nil
}
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return ni... | [
"func",
"(",
"k",
"*",
"KeyLoader",
")",
"LoadKeyPair",
"(",
"certFile",
",",
"keyFile",
"string",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"k",
".",
"cacheLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"k",
".",
"cacheLock",
... | // LoadKeyPair reloads the TLS certificate based on the specified certificate
// and key file. If successful, stores the certificate for further use. | [
"LoadKeyPair",
"reloads",
"the",
"TLS",
"certificate",
"based",
"on",
"the",
"specified",
"certificate",
"and",
"key",
"file",
".",
"If",
"successful",
"stores",
"the",
"certificate",
"for",
"further",
"use",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L81-L98 |
132,470 | hashicorp/nomad | nomad/structs/config/tls.go | GetOutgoingCertificate | func (k *KeyLoader) GetOutgoingCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error) {
k.cacheLock.Lock()
defer k.cacheLock.Unlock()
return k.certificate, nil
} | go | func (k *KeyLoader) GetOutgoingCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error) {
k.cacheLock.Lock()
defer k.cacheLock.Unlock()
return k.certificate, nil
} | [
"func",
"(",
"k",
"*",
"KeyLoader",
")",
"GetOutgoingCertificate",
"(",
"*",
"tls",
".",
"ClientHelloInfo",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"k",
".",
"cacheLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"k",
".",
"cach... | // GetOutgoingCertificate fetches the currently-loaded certificate when
// accepting a TLS connection. This currently does not consider information in
// the ClientHello and only returns the certificate that was last loaded. | [
"GetOutgoingCertificate",
"fetches",
"the",
"currently",
"-",
"loaded",
"certificate",
"when",
"accepting",
"a",
"TLS",
"connection",
".",
"This",
"currently",
"does",
"not",
"consider",
"information",
"in",
"the",
"ClientHello",
"and",
"only",
"returns",
"the",
"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L109-L113 |
132,471 | hashicorp/nomad | nomad/structs/config/tls.go | GetClientCertificate | func (k *KeyLoader) GetClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
k.cacheLock.Lock()
defer k.cacheLock.Unlock()
return k.certificate, nil
} | go | func (k *KeyLoader) GetClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
k.cacheLock.Lock()
defer k.cacheLock.Unlock()
return k.certificate, nil
} | [
"func",
"(",
"k",
"*",
"KeyLoader",
")",
"GetClientCertificate",
"(",
"*",
"tls",
".",
"CertificateRequestInfo",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"k",
".",
"cacheLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"k",
".",
... | // GetClientCertificate fetches the currently-loaded certificate when the Server
// requests a certificate from the caller. This currently does not consider
// information in the ClientHello and only returns the certificate that was last
// loaded. | [
"GetClientCertificate",
"fetches",
"the",
"currently",
"-",
"loaded",
"certificate",
"when",
"the",
"Server",
"requests",
"a",
"certificate",
"from",
"the",
"caller",
".",
"This",
"currently",
"does",
"not",
"consider",
"information",
"in",
"the",
"ClientHello",
"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L119-L123 |
132,472 | hashicorp/nomad | nomad/structs/config/tls.go | GetKeyLoader | func (t *TLSConfig) GetKeyLoader() *KeyLoader {
t.keyloaderLock.Lock()
defer t.keyloaderLock.Unlock()
// If the keyloader has not yet been initialized, do it here
if t.KeyLoader == nil {
t.KeyLoader = &KeyLoader{}
}
return t.KeyLoader
} | go | func (t *TLSConfig) GetKeyLoader() *KeyLoader {
t.keyloaderLock.Lock()
defer t.keyloaderLock.Unlock()
// If the keyloader has not yet been initialized, do it here
if t.KeyLoader == nil {
t.KeyLoader = &KeyLoader{}
}
return t.KeyLoader
} | [
"func",
"(",
"t",
"*",
"TLSConfig",
")",
"GetKeyLoader",
"(",
")",
"*",
"KeyLoader",
"{",
"t",
".",
"keyloaderLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"keyloaderLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// If the keyloader has not yet been initi... | // GetKeyLoader returns the keyloader for a TLSConfig object. If the keyloader
// has not been initialized, it will first do so. | [
"GetKeyLoader",
"returns",
"the",
"keyloader",
"for",
"a",
"TLSConfig",
"object",
".",
"If",
"the",
"keyloader",
"has",
"not",
"been",
"initialized",
"it",
"will",
"first",
"do",
"so",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L137-L146 |
132,473 | hashicorp/nomad | nomad/structs/config/tls.go | Copy | func (t *TLSConfig) Copy() *TLSConfig {
if t == nil {
return t
}
new := &TLSConfig{}
new.EnableHTTP = t.EnableHTTP
new.EnableRPC = t.EnableRPC
new.VerifyServerHostname = t.VerifyServerHostname
new.CAFile = t.CAFile
new.CertFile = t.CertFile
t.keyloaderLock.Lock()
new.KeyLoader = t.KeyLoader.Copy()
t.keyl... | go | func (t *TLSConfig) Copy() *TLSConfig {
if t == nil {
return t
}
new := &TLSConfig{}
new.EnableHTTP = t.EnableHTTP
new.EnableRPC = t.EnableRPC
new.VerifyServerHostname = t.VerifyServerHostname
new.CAFile = t.CAFile
new.CertFile = t.CertFile
t.keyloaderLock.Lock()
new.KeyLoader = t.KeyLoader.Copy()
t.keyl... | [
"func",
"(",
"t",
"*",
"TLSConfig",
")",
"Copy",
"(",
")",
"*",
"TLSConfig",
"{",
"if",
"t",
"==",
"nil",
"{",
"return",
"t",
"\n",
"}",
"\n\n",
"new",
":=",
"&",
"TLSConfig",
"{",
"}",
"\n",
"new",
".",
"EnableHTTP",
"=",
"t",
".",
"EnableHTTP",... | // Copy copies the fields of TLSConfig to another TLSConfig object. Required as
// to not copy mutexes between objects. | [
"Copy",
"copies",
"the",
"fields",
"of",
"TLSConfig",
"to",
"another",
"TLSConfig",
"object",
".",
"Required",
"as",
"to",
"not",
"copy",
"mutexes",
"between",
"objects",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L150-L178 |
132,474 | hashicorp/nomad | nomad/structs/config/tls.go | Merge | func (t *TLSConfig) Merge(b *TLSConfig) *TLSConfig {
result := t.Copy()
if b.EnableHTTP {
result.EnableHTTP = true
}
if b.EnableRPC {
result.EnableRPC = true
}
if b.VerifyServerHostname {
result.VerifyServerHostname = true
}
if b.CAFile != "" {
result.CAFile = b.CAFile
}
if b.CertFile != "" {
resul... | go | func (t *TLSConfig) Merge(b *TLSConfig) *TLSConfig {
result := t.Copy()
if b.EnableHTTP {
result.EnableHTTP = true
}
if b.EnableRPC {
result.EnableRPC = true
}
if b.VerifyServerHostname {
result.VerifyServerHostname = true
}
if b.CAFile != "" {
result.CAFile = b.CAFile
}
if b.CertFile != "" {
resul... | [
"func",
"(",
"t",
"*",
"TLSConfig",
")",
"Merge",
"(",
"b",
"*",
"TLSConfig",
")",
"*",
"TLSConfig",
"{",
"result",
":=",
"t",
".",
"Copy",
"(",
")",
"\n\n",
"if",
"b",
".",
"EnableHTTP",
"{",
"result",
".",
"EnableHTTP",
"=",
"true",
"\n",
"}",
... | // Merge is used to merge two TLS configs together | [
"Merge",
"is",
"used",
"to",
"merge",
"two",
"TLS",
"configs",
"together"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L195-L232 |
132,475 | hashicorp/nomad | nomad/structs/config/tls.go | CertificateInfoIsEqual | func (t *TLSConfig) CertificateInfoIsEqual(newConfig *TLSConfig) (bool, error) {
if t == nil || newConfig == nil {
return t == newConfig, nil
}
if t.IsEmpty() && newConfig.IsEmpty() {
return true, nil
} else if t.IsEmpty() || newConfig.IsEmpty() {
return false, nil
}
// Set the checksum if it hasn't yet b... | go | func (t *TLSConfig) CertificateInfoIsEqual(newConfig *TLSConfig) (bool, error) {
if t == nil || newConfig == nil {
return t == newConfig, nil
}
if t.IsEmpty() && newConfig.IsEmpty() {
return true, nil
} else if t.IsEmpty() || newConfig.IsEmpty() {
return false, nil
}
// Set the checksum if it hasn't yet b... | [
"func",
"(",
"t",
"*",
"TLSConfig",
")",
"CertificateInfoIsEqual",
"(",
"newConfig",
"*",
"TLSConfig",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"t",
"==",
"nil",
"||",
"newConfig",
"==",
"nil",
"{",
"return",
"t",
"==",
"newConfig",
",",
"nil",
... | // CertificateInfoIsEqual compares the fields of two TLS configuration objects
// for the fields that are specific to configuring a TLS connection
// It is possible for either the calling TLSConfig to be nil, or the TLSConfig
// that it is being compared against, so we need to handle both places. See
// server.go Reloa... | [
"CertificateInfoIsEqual",
"compares",
"the",
"fields",
"of",
"two",
"TLS",
"configuration",
"objects",
"for",
"the",
"fields",
"that",
"are",
"specific",
"to",
"configuring",
"a",
"TLS",
"connection",
"It",
"is",
"possible",
"for",
"either",
"the",
"calling",
"T... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L239-L267 |
132,476 | hashicorp/nomad | nomad/structs/config/tls.go | SetChecksum | func (t *TLSConfig) SetChecksum() error {
newCertChecksum, err := createChecksumOfFiles(t.CAFile, t.CertFile, t.KeyFile)
if err != nil {
return err
}
t.Checksum = newCertChecksum
return nil
} | go | func (t *TLSConfig) SetChecksum() error {
newCertChecksum, err := createChecksumOfFiles(t.CAFile, t.CertFile, t.KeyFile)
if err != nil {
return err
}
t.Checksum = newCertChecksum
return nil
} | [
"func",
"(",
"t",
"*",
"TLSConfig",
")",
"SetChecksum",
"(",
")",
"error",
"{",
"newCertChecksum",
",",
"err",
":=",
"createChecksumOfFiles",
"(",
"t",
".",
"CAFile",
",",
"t",
".",
"CertFile",
",",
"t",
".",
"KeyFile",
")",
"\n",
"if",
"err",
"!=",
... | // SetChecksum generates and sets the checksum for a TLS configuration | [
"SetChecksum",
"generates",
"and",
"sets",
"the",
"checksum",
"for",
"a",
"TLS",
"configuration"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/tls.go#L270-L278 |
132,477 | hashicorp/nomad | drivers/docker/driver_windows.go | getPortBinding | func getPortBinding(ip string, port string) []docker.PortBinding {
return []docker.PortBinding{{HostIP: "", HostPort: port}}
} | go | func getPortBinding(ip string, port string) []docker.PortBinding {
return []docker.PortBinding{{HostIP: "", HostPort: port}}
} | [
"func",
"getPortBinding",
"(",
"ip",
"string",
",",
"port",
"string",
")",
"[",
"]",
"docker",
".",
"PortBinding",
"{",
"return",
"[",
"]",
"docker",
".",
"PortBinding",
"{",
"{",
"HostIP",
":",
"\"",
"\"",
",",
"HostPort",
":",
"port",
"}",
"}",
"\n... | //Currently Windows containers don't support host ip in port binding. | [
"Currently",
"Windows",
"containers",
"don",
"t",
"support",
"host",
"ip",
"in",
"port",
"binding",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver_windows.go#L11-L13 |
132,478 | hashicorp/nomad | client/allocrunner/taskrunner/task_dir_hook.go | setEnvvars | func setEnvvars(envBuilder *taskenv.Builder, fsi drivers.FSIsolation, taskDir *allocdir.TaskDir, conf *cconfig.Config) {
// Set driver-specific environment variables
switch fsi {
case drivers.FSIsolationNone:
// Use host paths
envBuilder.SetAllocDir(taskDir.SharedAllocDir)
envBuilder.SetTaskLocalDir(taskDir.Lo... | go | func setEnvvars(envBuilder *taskenv.Builder, fsi drivers.FSIsolation, taskDir *allocdir.TaskDir, conf *cconfig.Config) {
// Set driver-specific environment variables
switch fsi {
case drivers.FSIsolationNone:
// Use host paths
envBuilder.SetAllocDir(taskDir.SharedAllocDir)
envBuilder.SetTaskLocalDir(taskDir.Lo... | [
"func",
"setEnvvars",
"(",
"envBuilder",
"*",
"taskenv",
".",
"Builder",
",",
"fsi",
"drivers",
".",
"FSIsolation",
",",
"taskDir",
"*",
"allocdir",
".",
"TaskDir",
",",
"conf",
"*",
"cconfig",
".",
"Config",
")",
"{",
"// Set driver-specific environment variabl... | // setEnvvars sets path and host env vars depending on the FS isolation used. | [
"setEnvvars",
"sets",
"path",
"and",
"host",
"env",
"vars",
"depending",
"on",
"the",
"FS",
"isolation",
"used",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_dir_hook.go#L78-L98 |
132,479 | hashicorp/nomad | drivers/shared/executor/executor_universal_linux.go | runAs | func (e *UniversalExecutor) runAs(userid string) error {
u, err := user.Lookup(userid)
if err != nil {
return fmt.Errorf("Failed to identify user %v: %v", userid, err)
}
// Get the groups the user is a part of
gidStrings, err := u.GroupIds()
if err != nil {
return fmt.Errorf("Unable to lookup user's group me... | go | func (e *UniversalExecutor) runAs(userid string) error {
u, err := user.Lookup(userid)
if err != nil {
return fmt.Errorf("Failed to identify user %v: %v", userid, err)
}
// Get the groups the user is a part of
gidStrings, err := u.GroupIds()
if err != nil {
return fmt.Errorf("Unable to lookup user's group me... | [
"func",
"(",
"e",
"*",
"UniversalExecutor",
")",
"runAs",
"(",
"userid",
"string",
")",
"error",
"{",
"u",
",",
"err",
":=",
"user",
".",
"Lookup",
"(",
"userid",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
... | // runAs takes a user id as a string and looks up the user, and sets the command
// to execute as that user. | [
"runAs",
"takes",
"a",
"user",
"id",
"as",
"a",
"string",
"and",
"looks",
"up",
"the",
"user",
"and",
"sets",
"the",
"command",
"to",
"execute",
"as",
"that",
"user",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_universal_linux.go#L19-L65 |
132,480 | hashicorp/nomad | drivers/shared/executor/executor_universal_linux.go | configureResourceContainer | func (e *UniversalExecutor) configureResourceContainer(pid int) error {
cfg := &lconfigs.Config{
Cgroups: &lconfigs.Cgroup{
Resources: &lconfigs.Resources{
AllowAllDevices: helper.BoolToPtr(true),
},
},
}
configureBasicCgroups(cfg)
e.resConCtx.groups = cfg.Cgroups
return cgroups.EnterPid(cfg.Cgroups... | go | func (e *UniversalExecutor) configureResourceContainer(pid int) error {
cfg := &lconfigs.Config{
Cgroups: &lconfigs.Cgroup{
Resources: &lconfigs.Resources{
AllowAllDevices: helper.BoolToPtr(true),
},
},
}
configureBasicCgroups(cfg)
e.resConCtx.groups = cfg.Cgroups
return cgroups.EnterPid(cfg.Cgroups... | [
"func",
"(",
"e",
"*",
"UniversalExecutor",
")",
"configureResourceContainer",
"(",
"pid",
"int",
")",
"error",
"{",
"cfg",
":=",
"&",
"lconfigs",
".",
"Config",
"{",
"Cgroups",
":",
"&",
"lconfigs",
".",
"Cgroup",
"{",
"Resources",
":",
"&",
"lconfigs",
... | // configureResourceContainer configured the cgroups to be used to track pids
// created by the executor | [
"configureResourceContainer",
"configured",
"the",
"cgroups",
"to",
"be",
"used",
"to",
"track",
"pids",
"created",
"by",
"the",
"executor"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_universal_linux.go#L69-L81 |
132,481 | hashicorp/nomad | drivers/shared/executor/executor_universal_linux.go | DestroyCgroup | func DestroyCgroup(groups *lconfigs.Cgroup, executorPid int) error {
mErrs := new(multierror.Error)
if groups == nil {
return fmt.Errorf("Can't destroy: cgroup configuration empty")
}
// Move the executor into the global cgroup so that the task specific
// cgroup can be destroyed.
path, err := cgroups.GetInitC... | go | func DestroyCgroup(groups *lconfigs.Cgroup, executorPid int) error {
mErrs := new(multierror.Error)
if groups == nil {
return fmt.Errorf("Can't destroy: cgroup configuration empty")
}
// Move the executor into the global cgroup so that the task specific
// cgroup can be destroyed.
path, err := cgroups.GetInitC... | [
"func",
"DestroyCgroup",
"(",
"groups",
"*",
"lconfigs",
".",
"Cgroup",
",",
"executorPid",
"int",
")",
"error",
"{",
"mErrs",
":=",
"new",
"(",
"multierror",
".",
"Error",
")",
"\n",
"if",
"groups",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(... | // DestroyCgroup kills all processes in the cgroup and removes the cgroup
// configuration from the host. This function is idempotent. | [
"DestroyCgroup",
"kills",
"all",
"processes",
"in",
"the",
"cgroup",
"and",
"removes",
"the",
"cgroup",
"configuration",
"from",
"the",
"host",
".",
"This",
"function",
"is",
"idempotent",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_universal_linux.go#L85-L156 |
132,482 | hashicorp/nomad | nomad/structs/config/vault.go | Merge | func (a *VaultConfig) Merge(b *VaultConfig) *VaultConfig {
result := *a
if b.Token != "" {
result.Token = b.Token
}
if b.Namespace != "" {
result.Namespace = b.Namespace
}
if b.Role != "" {
result.Role = b.Role
}
if b.TaskTokenTTL != "" {
result.TaskTokenTTL = b.TaskTokenTTL
}
if b.Addr != "" {
res... | go | func (a *VaultConfig) Merge(b *VaultConfig) *VaultConfig {
result := *a
if b.Token != "" {
result.Token = b.Token
}
if b.Namespace != "" {
result.Namespace = b.Namespace
}
if b.Role != "" {
result.Role = b.Role
}
if b.TaskTokenTTL != "" {
result.TaskTokenTTL = b.TaskTokenTTL
}
if b.Addr != "" {
res... | [
"func",
"(",
"a",
"*",
"VaultConfig",
")",
"Merge",
"(",
"b",
"*",
"VaultConfig",
")",
"*",
"VaultConfig",
"{",
"result",
":=",
"*",
"a",
"\n\n",
"if",
"b",
".",
"Token",
"!=",
"\"",
"\"",
"{",
"result",
".",
"Token",
"=",
"b",
".",
"Token",
"\n"... | // Merge merges two Vault configurations together. | [
"Merge",
"merges",
"two",
"Vault",
"configurations",
"together",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/vault.go#L107-L154 |
132,483 | hashicorp/nomad | nomad/structs/config/vault.go | Copy | func (c *VaultConfig) Copy() *VaultConfig {
if c == nil {
return nil
}
nc := new(VaultConfig)
*nc = *c
return nc
} | go | func (c *VaultConfig) Copy() *VaultConfig {
if c == nil {
return nil
}
nc := new(VaultConfig)
*nc = *c
return nc
} | [
"func",
"(",
"c",
"*",
"VaultConfig",
")",
"Copy",
"(",
")",
"*",
"VaultConfig",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"nc",
":=",
"new",
"(",
"VaultConfig",
")",
"\n",
"*",
"nc",
"=",
"*",
"c",
"\n",
"return",
"... | // Copy returns a copy of this Vault config. | [
"Copy",
"returns",
"a",
"copy",
"of",
"this",
"Vault",
"config",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/vault.go#L182-L190 |
132,484 | hashicorp/nomad | nomad/structs/config/vault.go | IsEqual | func (a *VaultConfig) IsEqual(b *VaultConfig) bool {
if a == nil && b != nil {
return false
}
if a != nil && b == nil {
return false
}
if a.Token != b.Token {
return false
}
if a.Role != b.Role {
return false
}
if a.TaskTokenTTL != b.TaskTokenTTL {
return false
}
if a.Addr != b.Addr {
return fal... | go | func (a *VaultConfig) IsEqual(b *VaultConfig) bool {
if a == nil && b != nil {
return false
}
if a != nil && b == nil {
return false
}
if a.Token != b.Token {
return false
}
if a.Role != b.Role {
return false
}
if a.TaskTokenTTL != b.TaskTokenTTL {
return false
}
if a.Addr != b.Addr {
return fal... | [
"func",
"(",
"a",
"*",
"VaultConfig",
")",
"IsEqual",
"(",
"b",
"*",
"VaultConfig",
")",
"bool",
"{",
"if",
"a",
"==",
"nil",
"&&",
"b",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"a",
"!=",
"nil",
"&&",
"b",
"==",
"nil",
"{",
... | // IsEqual compares two Vault configurations and returns a boolean indicating
// if they are equal. | [
"IsEqual",
"compares",
"two",
"Vault",
"configurations",
"and",
"returns",
"a",
"boolean",
"indicating",
"if",
"they",
"are",
"equal",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/vault.go#L194-L242 |
132,485 | hashicorp/nomad | lib/kheap/score_heap.go | Push | func (pq *ScoreHeap) Push(x interface{}) {
item := x.(HeapItem)
if len(pq.items) < pq.capacity {
pq.items = append(pq.items, item)
} else {
// Pop the lowest scoring element if this item's Score is
// greater than the min Score so far
minIndex := 0
min := pq.items[minIndex]
if item.Score() > min.Score() ... | go | func (pq *ScoreHeap) Push(x interface{}) {
item := x.(HeapItem)
if len(pq.items) < pq.capacity {
pq.items = append(pq.items, item)
} else {
// Pop the lowest scoring element if this item's Score is
// greater than the min Score so far
minIndex := 0
min := pq.items[minIndex]
if item.Score() > min.Score() ... | [
"func",
"(",
"pq",
"*",
"ScoreHeap",
")",
"Push",
"(",
"x",
"interface",
"{",
"}",
")",
"{",
"item",
":=",
"x",
".",
"(",
"HeapItem",
")",
"\n",
"if",
"len",
"(",
"pq",
".",
"items",
")",
"<",
"pq",
".",
"capacity",
"{",
"pq",
".",
"items",
"... | // Push implements heap.Interface and only stores
// the top K elements by Score | [
"Push",
"implements",
"heap",
".",
"Interface",
"and",
"only",
"stores",
"the",
"top",
"K",
"elements",
"by",
"Score"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/lib/kheap/score_heap.go#L37-L52 |
132,486 | hashicorp/nomad | lib/kheap/score_heap.go | Pop | func (pq *ScoreHeap) Pop() interface{} {
old := pq.items
n := len(old)
item := old[n-1]
pq.items = old[0 : n-1]
return item
} | go | func (pq *ScoreHeap) Pop() interface{} {
old := pq.items
n := len(old)
item := old[n-1]
pq.items = old[0 : n-1]
return item
} | [
"func",
"(",
"pq",
"*",
"ScoreHeap",
")",
"Pop",
"(",
")",
"interface",
"{",
"}",
"{",
"old",
":=",
"pq",
".",
"items",
"\n",
"n",
":=",
"len",
"(",
"old",
")",
"\n",
"item",
":=",
"old",
"[",
"n",
"-",
"1",
"]",
"\n",
"pq",
".",
"items",
"... | // Push implements heap.Interface and returns the top K scoring
// elements in increasing order of Score. Callers must reverse the order
// of returned elements to get the top K scoring elements in descending order | [
"Push",
"implements",
"heap",
".",
"Interface",
"and",
"returns",
"the",
"top",
"K",
"scoring",
"elements",
"in",
"increasing",
"order",
"of",
"Score",
".",
"Callers",
"must",
"reverse",
"the",
"order",
"of",
"returned",
"elements",
"to",
"get",
"the",
"top"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/lib/kheap/score_heap.go#L57-L63 |
132,487 | hashicorp/nomad | lib/kheap/score_heap.go | GetItemsReverse | func (pq *ScoreHeap) GetItemsReverse() []interface{} {
ret := make([]interface{}, pq.Len())
i := pq.Len() - 1
for pq.Len() > 0 {
item := heap.Pop(pq)
ret[i] = item
i--
}
return ret
} | go | func (pq *ScoreHeap) GetItemsReverse() []interface{} {
ret := make([]interface{}, pq.Len())
i := pq.Len() - 1
for pq.Len() > 0 {
item := heap.Pop(pq)
ret[i] = item
i--
}
return ret
} | [
"func",
"(",
"pq",
"*",
"ScoreHeap",
")",
"GetItemsReverse",
"(",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"pq",
".",
"Len",
"(",
")",
")",
"\n",
"i",
":=",
"pq",
".",
"Len",
"... | // GetItemsReverse returns the items in this min heap in reverse order
// sorted by score descending | [
"GetItemsReverse",
"returns",
"the",
"items",
"in",
"this",
"min",
"heap",
"in",
"reverse",
"order",
"sorted",
"by",
"score",
"descending"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/lib/kheap/score_heap.go#L67-L76 |
132,488 | hashicorp/nomad | scheduler/generic_sched.go | NewServiceScheduler | func NewServiceScheduler(logger log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{
logger: logger.Named("service_sched"),
state: state,
planner: planner,
batch: false,
}
return s
} | go | func NewServiceScheduler(logger log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{
logger: logger.Named("service_sched"),
state: state,
planner: planner,
batch: false,
}
return s
} | [
"func",
"NewServiceScheduler",
"(",
"logger",
"log",
".",
"Logger",
",",
"state",
"State",
",",
"planner",
"Planner",
")",
"Scheduler",
"{",
"s",
":=",
"&",
"GenericScheduler",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"state... | // NewServiceScheduler is a factory function to instantiate a new service scheduler | [
"NewServiceScheduler",
"is",
"a",
"factory",
"function",
"to",
"instantiate",
"a",
"new",
"service",
"scheduler"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L97-L105 |
132,489 | hashicorp/nomad | scheduler/generic_sched.go | NewBatchScheduler | func NewBatchScheduler(logger log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{
logger: logger.Named("batch_sched"),
state: state,
planner: planner,
batch: true,
}
return s
} | go | func NewBatchScheduler(logger log.Logger, state State, planner Planner) Scheduler {
s := &GenericScheduler{
logger: logger.Named("batch_sched"),
state: state,
planner: planner,
batch: true,
}
return s
} | [
"func",
"NewBatchScheduler",
"(",
"logger",
"log",
".",
"Logger",
",",
"state",
"State",
",",
"planner",
"Planner",
")",
"Scheduler",
"{",
"s",
":=",
"&",
"GenericScheduler",
"{",
"logger",
":",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"state",... | // NewBatchScheduler is a factory function to instantiate a new batch scheduler | [
"NewBatchScheduler",
"is",
"a",
"factory",
"function",
"to",
"instantiate",
"a",
"new",
"batch",
"scheduler"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L108-L116 |
132,490 | hashicorp/nomad | scheduler/generic_sched.go | Process | func (s *GenericScheduler) Process(eval *structs.Evaluation) error {
// Store the evaluation
s.eval = eval
// Update our logger with the eval's information
s.logger = s.logger.With("eval_id", eval.ID, "job_id", eval.JobID, "namespace", eval.Namespace)
// Verify the evaluation trigger reason is understood
switch... | go | func (s *GenericScheduler) Process(eval *structs.Evaluation) error {
// Store the evaluation
s.eval = eval
// Update our logger with the eval's information
s.logger = s.logger.With("eval_id", eval.ID, "job_id", eval.JobID, "namespace", eval.Namespace)
// Verify the evaluation trigger reason is understood
switch... | [
"func",
"(",
"s",
"*",
"GenericScheduler",
")",
"Process",
"(",
"eval",
"*",
"structs",
".",
"Evaluation",
")",
"error",
"{",
"// Store the evaluation",
"s",
".",
"eval",
"=",
"eval",
"\n\n",
"// Update our logger with the eval's information",
"s",
".",
"logger",
... | // Process is used to handle a single evaluation | [
"Process",
"is",
"used",
"to",
"handle",
"a",
"single",
"evaluation"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L119-L182 |
132,491 | hashicorp/nomad | scheduler/generic_sched.go | createBlockedEval | func (s *GenericScheduler) createBlockedEval(planFailure bool) error {
e := s.ctx.Eligibility()
escaped := e.HasEscaped()
// Only store the eligible classes if the eval hasn't escaped.
var classEligibility map[string]bool
if !escaped {
classEligibility = e.GetClasses()
}
s.blocked = s.eval.CreateBlockedEval(... | go | func (s *GenericScheduler) createBlockedEval(planFailure bool) error {
e := s.ctx.Eligibility()
escaped := e.HasEscaped()
// Only store the eligible classes if the eval hasn't escaped.
var classEligibility map[string]bool
if !escaped {
classEligibility = e.GetClasses()
}
s.blocked = s.eval.CreateBlockedEval(... | [
"func",
"(",
"s",
"*",
"GenericScheduler",
")",
"createBlockedEval",
"(",
"planFailure",
"bool",
")",
"error",
"{",
"e",
":=",
"s",
".",
"ctx",
".",
"Eligibility",
"(",
")",
"\n",
"escaped",
":=",
"e",
".",
"HasEscaped",
"(",
")",
"\n\n",
"// Only store ... | // createBlockedEval creates a blocked eval and submits it to the planner. If
// failure is set to true, the eval's trigger reason reflects that. | [
"createBlockedEval",
"creates",
"a",
"blocked",
"eval",
"and",
"submits",
"it",
"to",
"the",
"planner",
".",
"If",
"failure",
"is",
"set",
"to",
"true",
"the",
"eval",
"s",
"trigger",
"reason",
"reflects",
"that",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L186-L205 |
132,492 | hashicorp/nomad | scheduler/generic_sched.go | getSelectOptions | func getSelectOptions(prevAllocation *structs.Allocation, preferredNode *structs.Node) *SelectOptions {
selectOptions := &SelectOptions{}
if prevAllocation != nil {
penaltyNodes := make(map[string]struct{})
penaltyNodes[prevAllocation.NodeID] = struct{}{}
if prevAllocation.RescheduleTracker != nil {
for _, r... | go | func getSelectOptions(prevAllocation *structs.Allocation, preferredNode *structs.Node) *SelectOptions {
selectOptions := &SelectOptions{}
if prevAllocation != nil {
penaltyNodes := make(map[string]struct{})
penaltyNodes[prevAllocation.NodeID] = struct{}{}
if prevAllocation.RescheduleTracker != nil {
for _, r... | [
"func",
"getSelectOptions",
"(",
"prevAllocation",
"*",
"structs",
".",
"Allocation",
",",
"preferredNode",
"*",
"structs",
".",
"Node",
")",
"*",
"SelectOptions",
"{",
"selectOptions",
":=",
"&",
"SelectOptions",
"{",
"}",
"\n",
"if",
"prevAllocation",
"!=",
... | // getSelectOptions sets up preferred nodes and penalty nodes | [
"getSelectOptions",
"sets",
"up",
"preferred",
"nodes",
"and",
"penalty",
"nodes"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L559-L575 |
132,493 | hashicorp/nomad | scheduler/generic_sched.go | updateRescheduleTracker | func updateRescheduleTracker(alloc *structs.Allocation, prev *structs.Allocation, now time.Time) {
reschedPolicy := prev.ReschedulePolicy()
var rescheduleEvents []*structs.RescheduleEvent
if prev.RescheduleTracker != nil {
var interval time.Duration
if reschedPolicy != nil {
interval = reschedPolicy.Interval
... | go | func updateRescheduleTracker(alloc *structs.Allocation, prev *structs.Allocation, now time.Time) {
reschedPolicy := prev.ReschedulePolicy()
var rescheduleEvents []*structs.RescheduleEvent
if prev.RescheduleTracker != nil {
var interval time.Duration
if reschedPolicy != nil {
interval = reschedPolicy.Interval
... | [
"func",
"updateRescheduleTracker",
"(",
"alloc",
"*",
"structs",
".",
"Allocation",
",",
"prev",
"*",
"structs",
".",
"Allocation",
",",
"now",
"time",
".",
"Time",
")",
"{",
"reschedPolicy",
":=",
"prev",
".",
"ReschedulePolicy",
"(",
")",
"\n",
"var",
"r... | // updateRescheduleTracker carries over previous restart attempts and adds the most recent restart | [
"updateRescheduleTracker",
"carries",
"over",
"previous",
"restart",
"attempts",
"and",
"adds",
"the",
"most",
"recent",
"restart"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L578-L612 |
132,494 | hashicorp/nomad | scheduler/generic_sched.go | findPreferredNode | func (s *GenericScheduler) findPreferredNode(place placementResult) (*structs.Node, error) {
if prev := place.PreviousAllocation(); prev != nil && place.TaskGroup().EphemeralDisk.Sticky == true {
var preferredNode *structs.Node
ws := memdb.NewWatchSet()
preferredNode, err := s.state.NodeByID(ws, prev.NodeID)
i... | go | func (s *GenericScheduler) findPreferredNode(place placementResult) (*structs.Node, error) {
if prev := place.PreviousAllocation(); prev != nil && place.TaskGroup().EphemeralDisk.Sticky == true {
var preferredNode *structs.Node
ws := memdb.NewWatchSet()
preferredNode, err := s.state.NodeByID(ws, prev.NodeID)
i... | [
"func",
"(",
"s",
"*",
"GenericScheduler",
")",
"findPreferredNode",
"(",
"place",
"placementResult",
")",
"(",
"*",
"structs",
".",
"Node",
",",
"error",
")",
"{",
"if",
"prev",
":=",
"place",
".",
"PreviousAllocation",
"(",
")",
";",
"prev",
"!=",
"nil... | // findPreferredNode finds the preferred node for an allocation | [
"findPreferredNode",
"finds",
"the",
"preferred",
"node",
"for",
"an",
"allocation"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched.go#L615-L629 |
132,495 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | HasHealth | func (a *allocHealthSetter) HasHealth() bool {
a.ar.stateLock.Lock()
defer a.ar.stateLock.Unlock()
return a.ar.state.DeploymentStatus.HasHealth()
} | go | func (a *allocHealthSetter) HasHealth() bool {
a.ar.stateLock.Lock()
defer a.ar.stateLock.Unlock()
return a.ar.state.DeploymentStatus.HasHealth()
} | [
"func",
"(",
"a",
"*",
"allocHealthSetter",
")",
"HasHealth",
"(",
")",
"bool",
"{",
"a",
".",
"ar",
".",
"stateLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"ar",
".",
"stateLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"a",
".",
"ar"... | // HasHealth returns true if a deployment status is already set. | [
"HasHealth",
"returns",
"true",
"if",
"a",
"deployment",
"status",
"is",
"already",
"set",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L19-L23 |
132,496 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | ClearHealth | func (a *allocHealthSetter) ClearHealth() {
a.ar.stateLock.Lock()
a.ar.state.ClearDeploymentStatus()
a.ar.persistDeploymentStatus(nil)
a.ar.stateLock.Unlock()
} | go | func (a *allocHealthSetter) ClearHealth() {
a.ar.stateLock.Lock()
a.ar.state.ClearDeploymentStatus()
a.ar.persistDeploymentStatus(nil)
a.ar.stateLock.Unlock()
} | [
"func",
"(",
"a",
"*",
"allocHealthSetter",
")",
"ClearHealth",
"(",
")",
"{",
"a",
".",
"ar",
".",
"stateLock",
".",
"Lock",
"(",
")",
"\n",
"a",
".",
"ar",
".",
"state",
".",
"ClearDeploymentStatus",
"(",
")",
"\n",
"a",
".",
"ar",
".",
"persistD... | // ClearHealth allows the health watcher hook to clear the alloc's deployment
// health if the deployment id changes. It does not update the server as the
// status is only cleared when already receiving an update from the server.
//
// Only for use by health hook. | [
"ClearHealth",
"allows",
"the",
"health",
"watcher",
"hook",
"to",
"clear",
"the",
"alloc",
"s",
"deployment",
"health",
"if",
"the",
"deployment",
"id",
"changes",
".",
"It",
"does",
"not",
"update",
"the",
"server",
"as",
"the",
"status",
"is",
"only",
"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L30-L35 |
132,497 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | initRunnerHooks | func (ar *allocRunner) initRunnerHooks() {
hookLogger := ar.logger.Named("runner_hook")
// create health setting shim
hs := &allocHealthSetter{ar}
// Create the alloc directory hook. This is run first to ensure the
// directory path exists for other hooks.
ar.runnerHooks = []interfaces.RunnerHook{
newAllocDir... | go | func (ar *allocRunner) initRunnerHooks() {
hookLogger := ar.logger.Named("runner_hook")
// create health setting shim
hs := &allocHealthSetter{ar}
// Create the alloc directory hook. This is run first to ensure the
// directory path exists for other hooks.
ar.runnerHooks = []interfaces.RunnerHook{
newAllocDir... | [
"func",
"(",
"ar",
"*",
"allocRunner",
")",
"initRunnerHooks",
"(",
")",
"{",
"hookLogger",
":=",
"ar",
".",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
"\n\n",
"// create health setting shim",
"hs",
":=",
"&",
"allocHealthSetter",
"{",
"ar",
"}",
"\n\n"... | // initRunnerHooks intializes the runners hooks. | [
"initRunnerHooks",
"intializes",
"the",
"runners",
"hooks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L79-L93 |
132,498 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | prerun | func (ar *allocRunner) prerun() error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running pre-run hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished pre-run hooks", "end", end, "duration", end.Sub(start))
}()
}
for _, hook := range ar.runnerHooks {
... | go | func (ar *allocRunner) prerun() error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running pre-run hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished pre-run hooks", "end", end, "duration", end.Sub(start))
}()
}
for _, hook := range ar.runnerHooks {
... | [
"func",
"(",
"ar",
"*",
"allocRunner",
")",
"prerun",
"(",
")",
"error",
"{",
"if",
"ar",
".",
"logger",
".",
"IsTrace",
"(",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"ar",
".",
"logger",
".",
"Trace",
"(",
"\"",
"\"",
",",
... | // prerun is used to run the runners prerun hooks. | [
"prerun",
"is",
"used",
"to",
"run",
"the",
"runners",
"prerun",
"hooks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L96-L130 |
132,499 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | update | func (ar *allocRunner) update(update *structs.Allocation) error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running update hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished update hooks", "end", end, "duration", end.Sub(start))
}()
}
req := &interfa... | go | func (ar *allocRunner) update(update *structs.Allocation) error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running update hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished update hooks", "end", end, "duration", end.Sub(start))
}()
}
req := &interfa... | [
"func",
"(",
"ar",
"*",
"allocRunner",
")",
"update",
"(",
"update",
"*",
"structs",
".",
"Allocation",
")",
"error",
"{",
"if",
"ar",
".",
"logger",
".",
"IsTrace",
"(",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"ar",
".",
"lo... | // update runs the alloc runner update hooks. Update hooks are run
// asynchronously with all other alloc runner operations. | [
"update",
"runs",
"the",
"alloc",
"runner",
"update",
"hooks",
".",
"Update",
"hooks",
"are",
"run",
"asynchronously",
"with",
"all",
"other",
"alloc",
"runner",
"operations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L134-L173 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.