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,700 | hashicorp/nomad | api/tasks.go | Constrain | func (g *TaskGroup) Constrain(c *Constraint) *TaskGroup {
g.Constraints = append(g.Constraints, c)
return g
} | go | func (g *TaskGroup) Constrain(c *Constraint) *TaskGroup {
g.Constraints = append(g.Constraints, c)
return g
} | [
"func",
"(",
"g",
"*",
"TaskGroup",
")",
"Constrain",
"(",
"c",
"*",
"Constraint",
")",
"*",
"TaskGroup",
"{",
"g",
".",
"Constraints",
"=",
"append",
"(",
"g",
".",
"Constraints",
",",
"c",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // Constrain is used to add a constraint to a task group. | [
"Constrain",
"is",
"used",
"to",
"add",
"a",
"constraint",
"to",
"a",
"task",
"group",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L609-L612 |
132,701 | hashicorp/nomad | api/tasks.go | AddTask | func (g *TaskGroup) AddTask(t *Task) *TaskGroup {
g.Tasks = append(g.Tasks, t)
return g
} | go | func (g *TaskGroup) AddTask(t *Task) *TaskGroup {
g.Tasks = append(g.Tasks, t)
return g
} | [
"func",
"(",
"g",
"*",
"TaskGroup",
")",
"AddTask",
"(",
"t",
"*",
"Task",
")",
"*",
"TaskGroup",
"{",
"g",
".",
"Tasks",
"=",
"append",
"(",
"g",
".",
"Tasks",
",",
"t",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // AddTask is used to add a new task to a task group. | [
"AddTask",
"is",
"used",
"to",
"add",
"a",
"new",
"task",
"to",
"a",
"task",
"group",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L624-L627 |
132,702 | hashicorp/nomad | api/tasks.go | AddAffinity | func (g *TaskGroup) AddAffinity(a *Affinity) *TaskGroup {
g.Affinities = append(g.Affinities, a)
return g
} | go | func (g *TaskGroup) AddAffinity(a *Affinity) *TaskGroup {
g.Affinities = append(g.Affinities, a)
return g
} | [
"func",
"(",
"g",
"*",
"TaskGroup",
")",
"AddAffinity",
"(",
"a",
"*",
"Affinity",
")",
"*",
"TaskGroup",
"{",
"g",
".",
"Affinities",
"=",
"append",
"(",
"g",
".",
"Affinities",
",",
"a",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // AddAffinity is used to add a new affinity to a task group. | [
"AddAffinity",
"is",
"used",
"to",
"add",
"a",
"new",
"affinity",
"to",
"a",
"task",
"group",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L630-L633 |
132,703 | hashicorp/nomad | api/tasks.go | RequireDisk | func (g *TaskGroup) RequireDisk(disk *EphemeralDisk) *TaskGroup {
g.EphemeralDisk = disk
return g
} | go | func (g *TaskGroup) RequireDisk(disk *EphemeralDisk) *TaskGroup {
g.EphemeralDisk = disk
return g
} | [
"func",
"(",
"g",
"*",
"TaskGroup",
")",
"RequireDisk",
"(",
"disk",
"*",
"EphemeralDisk",
")",
"*",
"TaskGroup",
"{",
"g",
".",
"EphemeralDisk",
"=",
"disk",
"\n",
"return",
"g",
"\n",
"}"
] | // RequireDisk adds a ephemeral disk to the task group | [
"RequireDisk",
"adds",
"a",
"ephemeral",
"disk",
"to",
"the",
"task",
"group"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L636-L639 |
132,704 | hashicorp/nomad | api/tasks.go | AddSpread | func (g *TaskGroup) AddSpread(s *Spread) *TaskGroup {
g.Spreads = append(g.Spreads, s)
return g
} | go | func (g *TaskGroup) AddSpread(s *Spread) *TaskGroup {
g.Spreads = append(g.Spreads, s)
return g
} | [
"func",
"(",
"g",
"*",
"TaskGroup",
")",
"AddSpread",
"(",
"s",
"*",
"Spread",
")",
"*",
"TaskGroup",
"{",
"g",
".",
"Spreads",
"=",
"append",
"(",
"g",
".",
"Spreads",
",",
"s",
")",
"\n",
"return",
"g",
"\n",
"}"
] | // AddSpread is used to add a new spread preference to a task group. | [
"AddSpread",
"is",
"used",
"to",
"add",
"a",
"new",
"spread",
"preference",
"to",
"a",
"task",
"group",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L642-L645 |
132,705 | hashicorp/nomad | api/tasks.go | NewTask | func NewTask(name, driver string) *Task {
return &Task{
Name: name,
Driver: driver,
}
} | go | func NewTask(name, driver string) *Task {
return &Task{
Name: name,
Driver: driver,
}
} | [
"func",
"NewTask",
"(",
"name",
",",
"driver",
"string",
")",
"*",
"Task",
"{",
"return",
"&",
"Task",
"{",
"Name",
":",
"name",
",",
"Driver",
":",
"driver",
",",
"}",
"\n",
"}"
] | // NewTask creates and initializes a new Task. | [
"NewTask",
"creates",
"and",
"initializes",
"a",
"new",
"Task",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L835-L840 |
132,706 | hashicorp/nomad | api/tasks.go | Require | func (t *Task) Require(r *Resources) *Task {
t.Resources = r
return t
} | go | func (t *Task) Require(r *Resources) *Task {
t.Resources = r
return t
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Require",
"(",
"r",
"*",
"Resources",
")",
"*",
"Task",
"{",
"t",
".",
"Resources",
"=",
"r",
"\n",
"return",
"t",
"\n",
"}"
] | // Require is used to add resource requirements to a task. | [
"Require",
"is",
"used",
"to",
"add",
"resource",
"requirements",
"to",
"a",
"task",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L862-L865 |
132,707 | hashicorp/nomad | api/tasks.go | Constrain | func (t *Task) Constrain(c *Constraint) *Task {
t.Constraints = append(t.Constraints, c)
return t
} | go | func (t *Task) Constrain(c *Constraint) *Task {
t.Constraints = append(t.Constraints, c)
return t
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Constrain",
"(",
"c",
"*",
"Constraint",
")",
"*",
"Task",
"{",
"t",
".",
"Constraints",
"=",
"append",
"(",
"t",
".",
"Constraints",
",",
"c",
")",
"\n",
"return",
"t",
"\n",
"}"
] | // Constraint adds a new constraints to a single task. | [
"Constraint",
"adds",
"a",
"new",
"constraints",
"to",
"a",
"single",
"task",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L868-L871 |
132,708 | hashicorp/nomad | api/tasks.go | AddAffinity | func (t *Task) AddAffinity(a *Affinity) *Task {
t.Affinities = append(t.Affinities, a)
return t
} | go | func (t *Task) AddAffinity(a *Affinity) *Task {
t.Affinities = append(t.Affinities, a)
return t
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"AddAffinity",
"(",
"a",
"*",
"Affinity",
")",
"*",
"Task",
"{",
"t",
".",
"Affinities",
"=",
"append",
"(",
"t",
".",
"Affinities",
",",
"a",
")",
"\n",
"return",
"t",
"\n",
"}"
] | // AddAffinity adds a new affinity to a single task. | [
"AddAffinity",
"adds",
"a",
"new",
"affinity",
"to",
"a",
"single",
"task",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L874-L877 |
132,709 | hashicorp/nomad | api/tasks.go | SetLogConfig | func (t *Task) SetLogConfig(l *LogConfig) *Task {
t.LogConfig = l
return t
} | go | func (t *Task) SetLogConfig(l *LogConfig) *Task {
t.LogConfig = l
return t
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"SetLogConfig",
"(",
"l",
"*",
"LogConfig",
")",
"*",
"Task",
"{",
"t",
".",
"LogConfig",
"=",
"l",
"\n",
"return",
"t",
"\n",
"}"
] | // SetLogConfig sets a log config to a task | [
"SetLogConfig",
"sets",
"a",
"log",
"config",
"to",
"a",
"task"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L880-L883 |
132,710 | hashicorp/nomad | client/fingerprint/structs.go | AddAttribute | func (f *FingerprintResponse) AddAttribute(name, value string) {
// initialize Attributes if it has not been already
if f.Attributes == nil {
f.Attributes = make(map[string]string, 0)
}
f.Attributes[name] = value
} | go | func (f *FingerprintResponse) AddAttribute(name, value string) {
// initialize Attributes if it has not been already
if f.Attributes == nil {
f.Attributes = make(map[string]string, 0)
}
f.Attributes[name] = value
} | [
"func",
"(",
"f",
"*",
"FingerprintResponse",
")",
"AddAttribute",
"(",
"name",
",",
"value",
"string",
")",
"{",
"// initialize Attributes if it has not been already",
"if",
"f",
".",
"Attributes",
"==",
"nil",
"{",
"f",
".",
"Attributes",
"=",
"make",
"(",
"... | // AddAttribute adds the name and value for a node attribute to the fingerprint
// response | [
"AddAttribute",
"adds",
"the",
"name",
"and",
"value",
"for",
"a",
"node",
"attribute",
"to",
"the",
"fingerprint",
"response"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/structs.go#L30-L37 |
132,711 | hashicorp/nomad | client/fingerprint/structs.go | RemoveAttribute | func (f *FingerprintResponse) RemoveAttribute(name string) {
// initialize Attributes if it has not been already
if f.Attributes == nil {
f.Attributes = make(map[string]string, 0)
}
f.Attributes[name] = ""
} | go | func (f *FingerprintResponse) RemoveAttribute(name string) {
// initialize Attributes if it has not been already
if f.Attributes == nil {
f.Attributes = make(map[string]string, 0)
}
f.Attributes[name] = ""
} | [
"func",
"(",
"f",
"*",
"FingerprintResponse",
")",
"RemoveAttribute",
"(",
"name",
"string",
")",
"{",
"// initialize Attributes if it has not been already",
"if",
"f",
".",
"Attributes",
"==",
"nil",
"{",
"f",
".",
"Attributes",
"=",
"make",
"(",
"map",
"[",
... | // RemoveAttribute sets the given attribute to empty, which will later remove
// it entirely from the node | [
"RemoveAttribute",
"sets",
"the",
"given",
"attribute",
"to",
"empty",
"which",
"will",
"later",
"remove",
"it",
"entirely",
"from",
"the",
"node"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/structs.go#L41-L48 |
132,712 | hashicorp/nomad | client/fingerprint/structs.go | AddLink | func (f *FingerprintResponse) AddLink(name, value string) {
// initialize Links if it has not been already
if f.Links == nil {
f.Links = make(map[string]string, 0)
}
f.Links[name] = value
} | go | func (f *FingerprintResponse) AddLink(name, value string) {
// initialize Links if it has not been already
if f.Links == nil {
f.Links = make(map[string]string, 0)
}
f.Links[name] = value
} | [
"func",
"(",
"f",
"*",
"FingerprintResponse",
")",
"AddLink",
"(",
"name",
",",
"value",
"string",
")",
"{",
"// initialize Links if it has not been already",
"if",
"f",
".",
"Links",
"==",
"nil",
"{",
"f",
".",
"Links",
"=",
"make",
"(",
"map",
"[",
"stri... | // AddLink adds a link entry to the fingerprint response | [
"AddLink",
"adds",
"a",
"link",
"entry",
"to",
"the",
"fingerprint",
"response"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/structs.go#L51-L58 |
132,713 | hashicorp/nomad | client/fingerprint/structs.go | RemoveLink | func (f *FingerprintResponse) RemoveLink(name string) {
// initialize Links if it has not been already
if f.Links == nil {
f.Links = make(map[string]string, 0)
}
f.Links[name] = ""
} | go | func (f *FingerprintResponse) RemoveLink(name string) {
// initialize Links if it has not been already
if f.Links == nil {
f.Links = make(map[string]string, 0)
}
f.Links[name] = ""
} | [
"func",
"(",
"f",
"*",
"FingerprintResponse",
")",
"RemoveLink",
"(",
"name",
"string",
")",
"{",
"// initialize Links if it has not been already",
"if",
"f",
".",
"Links",
"==",
"nil",
"{",
"f",
".",
"Links",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"... | // RemoveLink removes a link entry from the fingerprint response. This will
// later remove it entirely from the node | [
"RemoveLink",
"removes",
"a",
"link",
"entry",
"from",
"the",
"fingerprint",
"response",
".",
"This",
"will",
"later",
"remove",
"it",
"entirely",
"from",
"the",
"node"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/structs.go#L62-L69 |
132,714 | hashicorp/nomad | helper/pluginutils/loader/loader.go | String | func (id PluginID) String() string {
return fmt.Sprintf("%q (%v)", id.Name, id.PluginType)
} | go | func (id PluginID) String() string {
return fmt.Sprintf("%q (%v)", id.Name, id.PluginType)
} | [
"func",
"(",
"id",
"PluginID",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"id",
".",
"Name",
",",
"id",
".",
"PluginType",
")",
"\n",
"}"
] | // String returns a friendly representation of the plugin. | [
"String",
"returns",
"a",
"friendly",
"representation",
"of",
"the",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L47-L49 |
132,715 | hashicorp/nomad | helper/pluginutils/loader/loader.go | NewPluginLoader | func NewPluginLoader(config *PluginLoaderConfig) (*PluginLoader, error) {
if err := validateConfig(config); err != nil {
return nil, fmt.Errorf("invalid plugin loader configuration passed: %v", err)
}
// Convert the versions
supportedVersions := make(map[string][]*version.Version, len(config.SupportedVersions))
... | go | func NewPluginLoader(config *PluginLoaderConfig) (*PluginLoader, error) {
if err := validateConfig(config); err != nil {
return nil, fmt.Errorf("invalid plugin loader configuration passed: %v", err)
}
// Convert the versions
supportedVersions := make(map[string][]*version.Version, len(config.SupportedVersions))
... | [
"func",
"NewPluginLoader",
"(",
"config",
"*",
"PluginLoaderConfig",
")",
"(",
"*",
"PluginLoader",
",",
"error",
")",
"{",
"if",
"err",
":=",
"validateConfig",
"(",
"config",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",... | // NewPluginLoader returns an instance of a plugin loader or an error if the
// plugins could not be loaded | [
"NewPluginLoader",
"returns",
"an",
"instance",
"of",
"a",
"plugin",
"loader",
"or",
"an",
"error",
"if",
"the",
"plugins",
"could",
"not",
"be",
"loaded"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L111-L139 |
132,716 | hashicorp/nomad | helper/pluginutils/loader/loader.go | Dispense | func (l *PluginLoader) Dispense(name, pluginType string, config *base.AgentConfig, logger log.Logger) (PluginInstance, error) {
id := PluginID{
Name: name,
PluginType: pluginType,
}
pinfo, ok := l.plugins[id]
if !ok {
return nil, fmt.Errorf("unknown plugin with name %q and type %q", name, pluginType)
}... | go | func (l *PluginLoader) Dispense(name, pluginType string, config *base.AgentConfig, logger log.Logger) (PluginInstance, error) {
id := PluginID{
Name: name,
PluginType: pluginType,
}
pinfo, ok := l.plugins[id]
if !ok {
return nil, fmt.Errorf("unknown plugin with name %q and type %q", name, pluginType)
}... | [
"func",
"(",
"l",
"*",
"PluginLoader",
")",
"Dispense",
"(",
"name",
",",
"pluginType",
"string",
",",
"config",
"*",
"base",
".",
"AgentConfig",
",",
"logger",
"log",
".",
"Logger",
")",
"(",
"PluginInstance",
",",
"error",
")",
"{",
"id",
":=",
"Plug... | // Dispense returns a plugin instance, loading it either internally or by
// launching an external plugin. | [
"Dispense",
"returns",
"a",
"plugin",
"instance",
"loading",
"it",
"either",
"internally",
"or",
"by",
"launching",
"an",
"external",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L143-L185 |
132,717 | hashicorp/nomad | helper/pluginutils/loader/loader.go | Reattach | func (l *PluginLoader) Reattach(name, pluginType string, config *plugin.ReattachConfig) (PluginInstance, error) {
return l.dispensePlugin(pluginType, "", "", nil, config, l.logger)
} | go | func (l *PluginLoader) Reattach(name, pluginType string, config *plugin.ReattachConfig) (PluginInstance, error) {
return l.dispensePlugin(pluginType, "", "", nil, config, l.logger)
} | [
"func",
"(",
"l",
"*",
"PluginLoader",
")",
"Reattach",
"(",
"name",
",",
"pluginType",
"string",
",",
"config",
"*",
"plugin",
".",
"ReattachConfig",
")",
"(",
"PluginInstance",
",",
"error",
")",
"{",
"return",
"l",
".",
"dispensePlugin",
"(",
"pluginTyp... | // Reattach reattaches to a previously launched external plugin. | [
"Reattach",
"reattaches",
"to",
"a",
"previously",
"launched",
"external",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L188-L190 |
132,718 | hashicorp/nomad | helper/pluginutils/loader/loader.go | dispensePlugin | func (l *PluginLoader) dispensePlugin(
pluginType, apiVersion, cmd string, args []string, reattach *plugin.ReattachConfig,
logger log.Logger) (PluginInstance, error) {
var pluginCmd *exec.Cmd
if cmd != "" && reattach != nil {
return nil, fmt.Errorf("both launch command and reattach config specified")
} else if ... | go | func (l *PluginLoader) dispensePlugin(
pluginType, apiVersion, cmd string, args []string, reattach *plugin.ReattachConfig,
logger log.Logger) (PluginInstance, error) {
var pluginCmd *exec.Cmd
if cmd != "" && reattach != nil {
return nil, fmt.Errorf("both launch command and reattach config specified")
} else if ... | [
"func",
"(",
"l",
"*",
"PluginLoader",
")",
"dispensePlugin",
"(",
"pluginType",
",",
"apiVersion",
",",
"cmd",
"string",
",",
"args",
"[",
"]",
"string",
",",
"reattach",
"*",
"plugin",
".",
"ReattachConfig",
",",
"logger",
"log",
".",
"Logger",
")",
"(... | // dispensePlugin is used to launch or reattach to an external plugin. | [
"dispensePlugin",
"is",
"used",
"to",
"launch",
"or",
"reattach",
"to",
"an",
"external",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L193-L259 |
132,719 | hashicorp/nomad | helper/pluginutils/loader/loader.go | getPluginMap | func getPluginMap(pluginType string, logger log.Logger) map[string]plugin.Plugin {
pmap := map[string]plugin.Plugin{
base.PluginTypeBase: &base.PluginBase{},
}
switch pluginType {
case base.PluginTypeDevice:
pmap[base.PluginTypeDevice] = &device.PluginDevice{}
case base.PluginTypeDriver:
pmap[base.PluginTyp... | go | func getPluginMap(pluginType string, logger log.Logger) map[string]plugin.Plugin {
pmap := map[string]plugin.Plugin{
base.PluginTypeBase: &base.PluginBase{},
}
switch pluginType {
case base.PluginTypeDevice:
pmap[base.PluginTypeDevice] = &device.PluginDevice{}
case base.PluginTypeDriver:
pmap[base.PluginTyp... | [
"func",
"getPluginMap",
"(",
"pluginType",
"string",
",",
"logger",
"log",
".",
"Logger",
")",
"map",
"[",
"string",
"]",
"plugin",
".",
"Plugin",
"{",
"pmap",
":=",
"map",
"[",
"string",
"]",
"plugin",
".",
"Plugin",
"{",
"base",
".",
"PluginTypeBase",
... | // getPluginMap returns a plugin map based on the type of plugin being launched. | [
"getPluginMap",
"returns",
"a",
"plugin",
"map",
"based",
"on",
"the",
"type",
"of",
"plugin",
"being",
"launched",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L262-L275 |
132,720 | hashicorp/nomad | helper/pluginutils/loader/loader.go | Catalog | func (l *PluginLoader) Catalog() map[string][]*base.PluginInfoResponse {
c := make(map[string][]*base.PluginInfoResponse, 3)
for id, info := range l.plugins {
c[id.PluginType] = append(c[id.PluginType], info.baseInfo)
}
return c
} | go | func (l *PluginLoader) Catalog() map[string][]*base.PluginInfoResponse {
c := make(map[string][]*base.PluginInfoResponse, 3)
for id, info := range l.plugins {
c[id.PluginType] = append(c[id.PluginType], info.baseInfo)
}
return c
} | [
"func",
"(",
"l",
"*",
"PluginLoader",
")",
"Catalog",
"(",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"base",
".",
"PluginInfoResponse",
"{",
"c",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"base",
".",
"PluginInfoResponse",
... | // Catalog returns the catalog of all plugins | [
"Catalog",
"returns",
"the",
"catalog",
"of",
"all",
"plugins"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/loader.go#L278-L284 |
132,721 | hashicorp/nomad | client/config/config.go | ReadDefault | func (c *Config) ReadDefault(id string, defaultValue string) string {
val, ok := c.Options[id]
if !ok {
return defaultValue
}
return val
} | go | func (c *Config) ReadDefault(id string, defaultValue string) string {
val, ok := c.Options[id]
if !ok {
return defaultValue
}
return val
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadDefault",
"(",
"id",
"string",
",",
"defaultValue",
"string",
")",
"string",
"{",
"val",
",",
"ok",
":=",
"c",
".",
"Options",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"defaultValue",
"\n",
"}... | // ReadDefault returns the specified configuration value, or the specified
// default value if none is set. | [
"ReadDefault",
"returns",
"the",
"specified",
"configuration",
"value",
"or",
"the",
"specified",
"default",
"value",
"if",
"none",
"is",
"set",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L264-L270 |
132,722 | hashicorp/nomad | client/config/config.go | ReadBool | func (c *Config) ReadBool(id string) (bool, error) {
val, ok := c.Options[id]
if !ok {
return false, fmt.Errorf("Specified config is missing from options")
}
bval, err := strconv.ParseBool(val)
if err != nil {
return false, fmt.Errorf("Failed to parse %s as bool: %s", val, err)
}
return bval, nil
} | go | func (c *Config) ReadBool(id string) (bool, error) {
val, ok := c.Options[id]
if !ok {
return false, fmt.Errorf("Specified config is missing from options")
}
bval, err := strconv.ParseBool(val)
if err != nil {
return false, fmt.Errorf("Failed to parse %s as bool: %s", val, err)
}
return bval, nil
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadBool",
"(",
"id",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"c",
".",
"Options",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
",",
"fmt",
".",
"Err... | // ReadBool parses the specified option as a boolean. | [
"ReadBool",
"parses",
"the",
"specified",
"option",
"as",
"a",
"boolean",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L273-L283 |
132,723 | hashicorp/nomad | client/config/config.go | ReadBoolDefault | func (c *Config) ReadBoolDefault(id string, defaultValue bool) bool {
val, err := c.ReadBool(id)
if err != nil {
return defaultValue
}
return val
} | go | func (c *Config) ReadBoolDefault(id string, defaultValue bool) bool {
val, err := c.ReadBool(id)
if err != nil {
return defaultValue
}
return val
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadBoolDefault",
"(",
"id",
"string",
",",
"defaultValue",
"bool",
")",
"bool",
"{",
"val",
",",
"err",
":=",
"c",
".",
"ReadBool",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaultValue",... | // ReadBoolDefault tries to parse the specified option as a boolean. If there is
// an error in parsing, the default option is returned. | [
"ReadBoolDefault",
"tries",
"to",
"parse",
"the",
"specified",
"option",
"as",
"a",
"boolean",
".",
"If",
"there",
"is",
"an",
"error",
"in",
"parsing",
"the",
"default",
"option",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L287-L293 |
132,724 | hashicorp/nomad | client/config/config.go | ReadInt | func (c *Config) ReadInt(id string) (int, error) {
val, ok := c.Options[id]
if !ok {
return 0, fmt.Errorf("Specified config is missing from options")
}
ival, err := strconv.Atoi(val)
if err != nil {
return 0, fmt.Errorf("Failed to parse %s as int: %s", val, err)
}
return ival, nil
} | go | func (c *Config) ReadInt(id string) (int, error) {
val, ok := c.Options[id]
if !ok {
return 0, fmt.Errorf("Specified config is missing from options")
}
ival, err := strconv.Atoi(val)
if err != nil {
return 0, fmt.Errorf("Failed to parse %s as int: %s", val, err)
}
return ival, nil
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadInt",
"(",
"id",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"c",
".",
"Options",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
... | // ReadInt parses the specified option as a int. | [
"ReadInt",
"parses",
"the",
"specified",
"option",
"as",
"a",
"int",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L296-L306 |
132,725 | hashicorp/nomad | client/config/config.go | ReadIntDefault | func (c *Config) ReadIntDefault(id string, defaultValue int) int {
val, err := c.ReadInt(id)
if err != nil {
return defaultValue
}
return val
} | go | func (c *Config) ReadIntDefault(id string, defaultValue int) int {
val, err := c.ReadInt(id)
if err != nil {
return defaultValue
}
return val
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadIntDefault",
"(",
"id",
"string",
",",
"defaultValue",
"int",
")",
"int",
"{",
"val",
",",
"err",
":=",
"c",
".",
"ReadInt",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaultValue",
"... | // ReadIntDefault tries to parse the specified option as a int. If there is
// an error in parsing, the default option is returned. | [
"ReadIntDefault",
"tries",
"to",
"parse",
"the",
"specified",
"option",
"as",
"a",
"int",
".",
"If",
"there",
"is",
"an",
"error",
"in",
"parsing",
"the",
"default",
"option",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L310-L316 |
132,726 | hashicorp/nomad | client/config/config.go | ReadDuration | func (c *Config) ReadDuration(id string) (time.Duration, error) {
val, ok := c.Options[id]
if !ok {
return time.Duration(0), fmt.Errorf("Specified config is missing from options")
}
dval, err := time.ParseDuration(val)
if err != nil {
return time.Duration(0), fmt.Errorf("Failed to parse %s as time duration: %s... | go | func (c *Config) ReadDuration(id string) (time.Duration, error) {
val, ok := c.Options[id]
if !ok {
return time.Duration(0), fmt.Errorf("Specified config is missing from options")
}
dval, err := time.ParseDuration(val)
if err != nil {
return time.Duration(0), fmt.Errorf("Failed to parse %s as time duration: %s... | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadDuration",
"(",
"id",
"string",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"val",
",",
"ok",
":=",
"c",
".",
"Options",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"time",
"."... | // ReadDuration parses the specified option as a duration. | [
"ReadDuration",
"parses",
"the",
"specified",
"option",
"as",
"a",
"duration",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L319-L329 |
132,727 | hashicorp/nomad | client/config/config.go | ReadDurationDefault | func (c *Config) ReadDurationDefault(id string, defaultValue time.Duration) time.Duration {
val, err := c.ReadDuration(id)
if err != nil {
return defaultValue
}
return val
} | go | func (c *Config) ReadDurationDefault(id string, defaultValue time.Duration) time.Duration {
val, err := c.ReadDuration(id)
if err != nil {
return defaultValue
}
return val
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ReadDurationDefault",
"(",
"id",
"string",
",",
"defaultValue",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"val",
",",
"err",
":=",
"c",
".",
"ReadDuration",
"(",
"id",
")",
"\n",
"if",
"err",
"... | // ReadDurationDefault tries to parse the specified option as a duration. If there is
// an error in parsing, the default option is returned. | [
"ReadDurationDefault",
"tries",
"to",
"parse",
"the",
"specified",
"option",
"as",
"a",
"duration",
".",
"If",
"there",
"is",
"an",
"error",
"in",
"parsing",
"the",
"default",
"option",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L333-L339 |
132,728 | hashicorp/nomad | client/config/config.go | NomadPluginConfig | func (c *Config) NomadPluginConfig() *base.AgentConfig {
return &base.AgentConfig{
Driver: &base.ClientDriverConfig{
ClientMinPort: c.ClientMinPort,
ClientMaxPort: c.ClientMaxPort,
},
}
} | go | func (c *Config) NomadPluginConfig() *base.AgentConfig {
return &base.AgentConfig{
Driver: &base.ClientDriverConfig{
ClientMinPort: c.ClientMinPort,
ClientMaxPort: c.ClientMaxPort,
},
}
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"NomadPluginConfig",
"(",
")",
"*",
"base",
".",
"AgentConfig",
"{",
"return",
"&",
"base",
".",
"AgentConfig",
"{",
"Driver",
":",
"&",
"base",
".",
"ClientDriverConfig",
"{",
"ClientMinPort",
":",
"c",
".",
"Client... | // NomadPluginConfig produces the NomadConfig struct which is sent to Nomad plugins | [
"NomadPluginConfig",
"produces",
"the",
"NomadConfig",
"struct",
"which",
"is",
"sent",
"to",
"Nomad",
"plugins"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/config/config.go#L374-L381 |
132,729 | hashicorp/nomad | drivers/mock/driver.go | GetHandle | func (d *Driver) GetHandle(taskID string) *taskHandle {
h, _ := d.tasks.Get(taskID)
return h
} | go | func (d *Driver) GetHandle(taskID string) *taskHandle {
h, _ := d.tasks.Get(taskID)
return h
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"GetHandle",
"(",
"taskID",
"string",
")",
"*",
"taskHandle",
"{",
"h",
",",
"_",
":=",
"d",
".",
"tasks",
".",
"Get",
"(",
"taskID",
")",
"\n",
"return",
"h",
"\n",
"}"
] | // GetHandle is unique to the mock driver and for testing purposes only. It
// returns the handle of the given task ID | [
"GetHandle",
"is",
"unique",
"to",
"the",
"mock",
"driver",
"and",
"for",
"testing",
"purposes",
"only",
".",
"It",
"returns",
"the",
"handle",
"of",
"the",
"given",
"task",
"ID"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/mock/driver.go#L571-L574 |
132,730 | hashicorp/nomad | scheduler/stack_oss.go | NewGenericStack | func NewGenericStack(batch bool, ctx Context) *GenericStack {
// Create a new stack
s := &GenericStack{
batch: batch,
ctx: ctx,
}
// Create the source iterator. We randomize the order we visit nodes
// to reduce collisions between schedulers and to do a basic load
// balancing across eligible nodes.
s.sou... | go | func NewGenericStack(batch bool, ctx Context) *GenericStack {
// Create a new stack
s := &GenericStack{
batch: batch,
ctx: ctx,
}
// Create the source iterator. We randomize the order we visit nodes
// to reduce collisions between schedulers and to do a basic load
// balancing across eligible nodes.
s.sou... | [
"func",
"NewGenericStack",
"(",
"batch",
"bool",
",",
"ctx",
"Context",
")",
"*",
"GenericStack",
"{",
"// Create a new stack",
"s",
":=",
"&",
"GenericStack",
"{",
"batch",
":",
"batch",
",",
"ctx",
":",
"ctx",
",",
"}",
"\n\n",
"// Create the source iterator... | // NewGenericStack constructs a stack used for selecting service placements | [
"NewGenericStack",
"constructs",
"a",
"stack",
"used",
"for",
"selecting",
"service",
"placements"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/stack_oss.go#L6-L78 |
132,731 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | NewDeploymentsWatcher | func NewDeploymentsWatcher(logger log.Logger,
raft DeploymentRaftEndpoints, stateQueriesPerSecond float64,
updateBatchDuration time.Duration) *Watcher {
return &Watcher{
raft: raft,
queryLimiter: rate.NewLimiter(rate.Limit(stateQueriesPerSecond), 100),
updateBatchDuration: updateBatchDur... | go | func NewDeploymentsWatcher(logger log.Logger,
raft DeploymentRaftEndpoints, stateQueriesPerSecond float64,
updateBatchDuration time.Duration) *Watcher {
return &Watcher{
raft: raft,
queryLimiter: rate.NewLimiter(rate.Limit(stateQueriesPerSecond), 100),
updateBatchDuration: updateBatchDur... | [
"func",
"NewDeploymentsWatcher",
"(",
"logger",
"log",
".",
"Logger",
",",
"raft",
"DeploymentRaftEndpoints",
",",
"stateQueriesPerSecond",
"float64",
",",
"updateBatchDuration",
"time",
".",
"Duration",
")",
"*",
"Watcher",
"{",
"return",
"&",
"Watcher",
"{",
"ra... | // NewDeploymentsWatcher returns a deployments watcher that is used to watch
// deployments and trigger the scheduler as needed. | [
"NewDeploymentsWatcher",
"returns",
"a",
"deployments",
"watcher",
"that",
"is",
"used",
"to",
"watch",
"deployments",
"and",
"trigger",
"the",
"scheduler",
"as",
"needed",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L94-L104 |
132,732 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | SetEnabled | func (w *Watcher) SetEnabled(enabled bool, state *state.StateStore) {
w.l.Lock()
defer w.l.Unlock()
wasEnabled := w.enabled
w.enabled = enabled
if state != nil {
w.state = state
}
// Flush the state to create the necessary objects
w.flush()
// If we are starting now, launch the watch daemon
if enabled &... | go | func (w *Watcher) SetEnabled(enabled bool, state *state.StateStore) {
w.l.Lock()
defer w.l.Unlock()
wasEnabled := w.enabled
w.enabled = enabled
if state != nil {
w.state = state
}
// Flush the state to create the necessary objects
w.flush()
// If we are starting now, launch the watch daemon
if enabled &... | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"SetEnabled",
"(",
"enabled",
"bool",
",",
"state",
"*",
"state",
".",
"StateStore",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"wasEnabled... | // SetEnabled is used to control if the watcher is enabled. The watcher
// should only be enabled on the active leader. When being enabled the state is
// passed in as it is no longer valid once a leader election has taken place. | [
"SetEnabled",
"is",
"used",
"to",
"control",
"if",
"the",
"watcher",
"is",
"enabled",
".",
"The",
"watcher",
"should",
"only",
"be",
"enabled",
"on",
"the",
"active",
"leader",
".",
"When",
"being",
"enabled",
"the",
"state",
"is",
"passed",
"in",
"as",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L109-L127 |
132,733 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | watchDeployments | func (w *Watcher) watchDeployments(ctx context.Context) {
dindex := uint64(1)
for {
// Block getting all deployments using the last deployment index.
deployments, idx, err := w.getDeploys(ctx, dindex)
if err != nil {
if err == context.Canceled {
return
}
w.logger.Error("failed to retrieve deployme... | go | func (w *Watcher) watchDeployments(ctx context.Context) {
dindex := uint64(1)
for {
// Block getting all deployments using the last deployment index.
deployments, idx, err := w.getDeploys(ctx, dindex)
if err != nil {
if err == context.Canceled {
return
}
w.logger.Error("failed to retrieve deployme... | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"watchDeployments",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"dindex",
":=",
"uint64",
"(",
"1",
")",
"\n",
"for",
"{",
"// Block getting all deployments using the last deployment index.",
"deployments",
",",
"idx",
... | // watchDeployments is the long lived go-routine that watches for deployments to
// add and remove watchers on. | [
"watchDeployments",
"is",
"the",
"long",
"lived",
"go",
"-",
"routine",
"that",
"watches",
"for",
"deployments",
"to",
"add",
"and",
"remove",
"watchers",
"on",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L148-L176 |
132,734 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | getDeploys | func (w *Watcher) getDeploys(ctx context.Context, minIndex uint64) ([]*structs.Deployment, uint64, error) {
resp, index, err := w.state.BlockingQuery(w.getDeploysImpl, minIndex, ctx)
if err != nil {
return nil, 0, err
}
return resp.([]*structs.Deployment), index, nil
} | go | func (w *Watcher) getDeploys(ctx context.Context, minIndex uint64) ([]*structs.Deployment, uint64, error) {
resp, index, err := w.state.BlockingQuery(w.getDeploysImpl, minIndex, ctx)
if err != nil {
return nil, 0, err
}
return resp.([]*structs.Deployment), index, nil
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"getDeploys",
"(",
"ctx",
"context",
".",
"Context",
",",
"minIndex",
"uint64",
")",
"(",
"[",
"]",
"*",
"structs",
".",
"Deployment",
",",
"uint64",
",",
"error",
")",
"{",
"resp",
",",
"index",
",",
"err",
"... | // getDeploys retrieves all deployments blocking at the given index. | [
"getDeploys",
"retrieves",
"all",
"deployments",
"blocking",
"at",
"the",
"given",
"index",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L179-L186 |
132,735 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | add | func (w *Watcher) add(d *structs.Deployment) error {
w.l.Lock()
defer w.l.Unlock()
_, err := w.addLocked(d)
return err
} | go | func (w *Watcher) add(d *structs.Deployment) error {
w.l.Lock()
defer w.l.Unlock()
_, err := w.addLocked(d)
return err
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"add",
"(",
"d",
"*",
"structs",
".",
"Deployment",
")",
"error",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"w",
"."... | // add adds a deployment to the watch list | [
"add",
"adds",
"a",
"deployment",
"to",
"the",
"watch",
"list"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L216-L221 |
132,736 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | addLocked | func (w *Watcher) addLocked(d *structs.Deployment) (*deploymentWatcher, error) {
// Not enabled so no-op
if !w.enabled {
return nil, nil
}
if !d.Active() {
return nil, fmt.Errorf("deployment %q is terminal", d.ID)
}
// Already watched so just update the deployment
if w, ok := w.watchers[d.ID]; ok {
w.upd... | go | func (w *Watcher) addLocked(d *structs.Deployment) (*deploymentWatcher, error) {
// Not enabled so no-op
if !w.enabled {
return nil, nil
}
if !d.Active() {
return nil, fmt.Errorf("deployment %q is terminal", d.ID)
}
// Already watched so just update the deployment
if w, ok := w.watchers[d.ID]; ok {
w.upd... | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"addLocked",
"(",
"d",
"*",
"structs",
".",
"Deployment",
")",
"(",
"*",
"deploymentWatcher",
",",
"error",
")",
"{",
"// Not enabled so no-op",
"if",
"!",
"w",
".",
"enabled",
"{",
"return",
"nil",
",",
"nil",
"\... | // addLocked adds a deployment to the watch list and should only be called when
// locked. | [
"addLocked",
"adds",
"a",
"deployment",
"to",
"the",
"watch",
"list",
"and",
"should",
"only",
"be",
"called",
"when",
"locked",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L225-L258 |
132,737 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | remove | func (w *Watcher) remove(d *structs.Deployment) {
w.l.Lock()
defer w.l.Unlock()
// Not enabled so no-op
if !w.enabled {
return
}
if watcher, ok := w.watchers[d.ID]; ok {
watcher.StopWatch()
delete(w.watchers, d.ID)
}
} | go | func (w *Watcher) remove(d *structs.Deployment) {
w.l.Lock()
defer w.l.Unlock()
// Not enabled so no-op
if !w.enabled {
return
}
if watcher, ok := w.watchers[d.ID]; ok {
watcher.StopWatch()
delete(w.watchers, d.ID)
}
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"remove",
"(",
"d",
"*",
"structs",
".",
"Deployment",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// Not enabled so no-op",
"if",
"!",
"w"... | // remove stops watching a deployment. This can be because the deployment is
// complete or being deleted. | [
"remove",
"stops",
"watching",
"a",
"deployment",
".",
"This",
"can",
"be",
"because",
"the",
"deployment",
"is",
"complete",
"or",
"being",
"deleted",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L262-L275 |
132,738 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | forceAdd | func (w *Watcher) forceAdd(dID string) (*deploymentWatcher, error) {
snap, err := w.state.Snapshot()
if err != nil {
return nil, err
}
deployment, err := snap.DeploymentByID(nil, dID)
if err != nil {
return nil, err
}
if deployment == nil {
return nil, fmt.Errorf("unknown deployment %q", dID)
}
return... | go | func (w *Watcher) forceAdd(dID string) (*deploymentWatcher, error) {
snap, err := w.state.Snapshot()
if err != nil {
return nil, err
}
deployment, err := snap.DeploymentByID(nil, dID)
if err != nil {
return nil, err
}
if deployment == nil {
return nil, fmt.Errorf("unknown deployment %q", dID)
}
return... | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"forceAdd",
"(",
"dID",
"string",
")",
"(",
"*",
"deploymentWatcher",
",",
"error",
")",
"{",
"snap",
",",
"err",
":=",
"w",
".",
"state",
".",
"Snapshot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // forceAdd is used to force a lookup of the given deployment object and create
// a watcher. If the deployment does not exist or is terminal an error is
// returned. | [
"forceAdd",
"is",
"used",
"to",
"force",
"a",
"lookup",
"of",
"the",
"given",
"deployment",
"object",
"and",
"create",
"a",
"watcher",
".",
"If",
"the",
"deployment",
"does",
"not",
"exist",
"or",
"is",
"terminal",
"an",
"error",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L280-L296 |
132,739 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | getOrCreateWatcher | func (w *Watcher) getOrCreateWatcher(dID string) (*deploymentWatcher, error) {
w.l.Lock()
defer w.l.Unlock()
// Not enabled so no-op
if !w.enabled {
return nil, notEnabled
}
watcher, ok := w.watchers[dID]
if ok {
return watcher, nil
}
return w.forceAdd(dID)
} | go | func (w *Watcher) getOrCreateWatcher(dID string) (*deploymentWatcher, error) {
w.l.Lock()
defer w.l.Unlock()
// Not enabled so no-op
if !w.enabled {
return nil, notEnabled
}
watcher, ok := w.watchers[dID]
if ok {
return watcher, nil
}
return w.forceAdd(dID)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"getOrCreateWatcher",
"(",
"dID",
"string",
")",
"(",
"*",
"deploymentWatcher",
",",
"error",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"/... | // getOrCreateWatcher returns the deployment watcher for the given deployment ID. | [
"getOrCreateWatcher",
"returns",
"the",
"deployment",
"watcher",
"for",
"the",
"given",
"deployment",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L299-L314 |
132,740 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | SetAllocHealth | func (w *Watcher) SetAllocHealth(req *structs.DeploymentAllocHealthRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.SetAllocHealth(req, resp)
} | go | func (w *Watcher) SetAllocHealth(req *structs.DeploymentAllocHealthRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.SetAllocHealth(req, resp)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"SetAllocHealth",
"(",
"req",
"*",
"structs",
".",
"DeploymentAllocHealthRequest",
",",
"resp",
"*",
"structs",
".",
"DeploymentUpdateResponse",
")",
"error",
"{",
"watcher",
",",
"err",
":=",
"w",
".",
"getOrCreateWatche... | // SetAllocHealth is used to set the health of allocations for a deployment. If
// there are any unhealthy allocations, the deployment is updated to be failed.
// Otherwise the allocations are updated and an evaluation is created. | [
"SetAllocHealth",
"is",
"used",
"to",
"set",
"the",
"health",
"of",
"allocations",
"for",
"a",
"deployment",
".",
"If",
"there",
"are",
"any",
"unhealthy",
"allocations",
"the",
"deployment",
"is",
"updated",
"to",
"be",
"failed",
".",
"Otherwise",
"the",
"a... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L319-L326 |
132,741 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | PromoteDeployment | func (w *Watcher) PromoteDeployment(req *structs.DeploymentPromoteRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.PromoteDeployment(req, resp)
} | go | func (w *Watcher) PromoteDeployment(req *structs.DeploymentPromoteRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.PromoteDeployment(req, resp)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"PromoteDeployment",
"(",
"req",
"*",
"structs",
".",
"DeploymentPromoteRequest",
",",
"resp",
"*",
"structs",
".",
"DeploymentUpdateResponse",
")",
"error",
"{",
"watcher",
",",
"err",
":=",
"w",
".",
"getOrCreateWatcher... | // PromoteDeployment is used to promote a deployment. If promote is false,
// deployment is marked as failed. Otherwise the deployment is updated and an
// evaluation is created. | [
"PromoteDeployment",
"is",
"used",
"to",
"promote",
"a",
"deployment",
".",
"If",
"promote",
"is",
"false",
"deployment",
"is",
"marked",
"as",
"failed",
".",
"Otherwise",
"the",
"deployment",
"is",
"updated",
"and",
"an",
"evaluation",
"is",
"created",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L331-L338 |
132,742 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | PauseDeployment | func (w *Watcher) PauseDeployment(req *structs.DeploymentPauseRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.PauseDeployment(req, resp)
} | go | func (w *Watcher) PauseDeployment(req *structs.DeploymentPauseRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.PauseDeployment(req, resp)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"PauseDeployment",
"(",
"req",
"*",
"structs",
".",
"DeploymentPauseRequest",
",",
"resp",
"*",
"structs",
".",
"DeploymentUpdateResponse",
")",
"error",
"{",
"watcher",
",",
"err",
":=",
"w",
".",
"getOrCreateWatcher",
... | // PauseDeployment is used to toggle the pause state on a deployment. If the
// deployment is being unpaused, an evaluation is created. | [
"PauseDeployment",
"is",
"used",
"to",
"toggle",
"the",
"pause",
"state",
"on",
"a",
"deployment",
".",
"If",
"the",
"deployment",
"is",
"being",
"unpaused",
"an",
"evaluation",
"is",
"created",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L342-L349 |
132,743 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | FailDeployment | func (w *Watcher) FailDeployment(req *structs.DeploymentFailRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.FailDeployment(req, resp)
} | go | func (w *Watcher) FailDeployment(req *structs.DeploymentFailRequest, resp *structs.DeploymentUpdateResponse) error {
watcher, err := w.getOrCreateWatcher(req.DeploymentID)
if err != nil {
return err
}
return watcher.FailDeployment(req, resp)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"FailDeployment",
"(",
"req",
"*",
"structs",
".",
"DeploymentFailRequest",
",",
"resp",
"*",
"structs",
".",
"DeploymentUpdateResponse",
")",
"error",
"{",
"watcher",
",",
"err",
":=",
"w",
".",
"getOrCreateWatcher",
"... | // FailDeployment is used to fail the deployment. | [
"FailDeployment",
"is",
"used",
"to",
"fail",
"the",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L352-L359 |
132,744 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | createUpdate | func (w *Watcher) createUpdate(allocs map[string]*structs.DesiredTransition, eval *structs.Evaluation) (uint64, error) {
return w.allocUpdateBatcher.CreateUpdate(allocs, eval).Results()
} | go | func (w *Watcher) createUpdate(allocs map[string]*structs.DesiredTransition, eval *structs.Evaluation) (uint64, error) {
return w.allocUpdateBatcher.CreateUpdate(allocs, eval).Results()
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"createUpdate",
"(",
"allocs",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"DesiredTransition",
",",
"eval",
"*",
"structs",
".",
"Evaluation",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"w",
".",
... | // createUpdate commits the given allocation desired transition and evaluation
// to Raft but batches the commit with other calls. | [
"createUpdate",
"commits",
"the",
"given",
"allocation",
"desired",
"transition",
"and",
"evaluation",
"to",
"Raft",
"but",
"batches",
"the",
"commit",
"with",
"other",
"calls",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L363-L365 |
132,745 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | upsertJob | func (w *Watcher) upsertJob(job *structs.Job) (uint64, error) {
return w.raft.UpsertJob(job)
} | go | func (w *Watcher) upsertJob(job *structs.Job) (uint64, error) {
return w.raft.UpsertJob(job)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"upsertJob",
"(",
"job",
"*",
"structs",
".",
"Job",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"w",
".",
"raft",
".",
"UpsertJob",
"(",
"job",
")",
"\n",
"}"
] | // upsertJob commits the given job to Raft | [
"upsertJob",
"commits",
"the",
"given",
"job",
"to",
"Raft"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L368-L370 |
132,746 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | upsertDeploymentStatusUpdate | func (w *Watcher) upsertDeploymentStatusUpdate(
u *structs.DeploymentStatusUpdate,
e *structs.Evaluation,
j *structs.Job) (uint64, error) {
return w.raft.UpdateDeploymentStatus(&structs.DeploymentStatusUpdateRequest{
DeploymentUpdate: u,
Eval: e,
Job: j,
})
} | go | func (w *Watcher) upsertDeploymentStatusUpdate(
u *structs.DeploymentStatusUpdate,
e *structs.Evaluation,
j *structs.Job) (uint64, error) {
return w.raft.UpdateDeploymentStatus(&structs.DeploymentStatusUpdateRequest{
DeploymentUpdate: u,
Eval: e,
Job: j,
})
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"upsertDeploymentStatusUpdate",
"(",
"u",
"*",
"structs",
".",
"DeploymentStatusUpdate",
",",
"e",
"*",
"structs",
".",
"Evaluation",
",",
"j",
"*",
"structs",
".",
"Job",
")",
"(",
"uint64",
",",
"error",
")",
"{",... | // upsertDeploymentStatusUpdate commits the given deployment update and optional
// evaluation to Raft | [
"upsertDeploymentStatusUpdate",
"commits",
"the",
"given",
"deployment",
"update",
"and",
"optional",
"evaluation",
"to",
"Raft"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L374-L383 |
132,747 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | upsertDeploymentPromotion | func (w *Watcher) upsertDeploymentPromotion(req *structs.ApplyDeploymentPromoteRequest) (uint64, error) {
return w.raft.UpdateDeploymentPromotion(req)
} | go | func (w *Watcher) upsertDeploymentPromotion(req *structs.ApplyDeploymentPromoteRequest) (uint64, error) {
return w.raft.UpdateDeploymentPromotion(req)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"upsertDeploymentPromotion",
"(",
"req",
"*",
"structs",
".",
"ApplyDeploymentPromoteRequest",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"w",
".",
"raft",
".",
"UpdateDeploymentPromotion",
"(",
"req",
")",
"... | // upsertDeploymentPromotion commits the given deployment promotion to Raft | [
"upsertDeploymentPromotion",
"commits",
"the",
"given",
"deployment",
"promotion",
"to",
"Raft"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L386-L388 |
132,748 | hashicorp/nomad | nomad/deploymentwatcher/deployments_watcher.go | upsertDeploymentAllocHealth | func (w *Watcher) upsertDeploymentAllocHealth(req *structs.ApplyDeploymentAllocHealthRequest) (uint64, error) {
return w.raft.UpdateDeploymentAllocHealth(req)
} | go | func (w *Watcher) upsertDeploymentAllocHealth(req *structs.ApplyDeploymentAllocHealthRequest) (uint64, error) {
return w.raft.UpdateDeploymentAllocHealth(req)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"upsertDeploymentAllocHealth",
"(",
"req",
"*",
"structs",
".",
"ApplyDeploymentAllocHealthRequest",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"w",
".",
"raft",
".",
"UpdateDeploymentAllocHealth",
"(",
"req",
... | // upsertDeploymentAllocHealth commits the given allocation health changes to
// Raft | [
"upsertDeploymentAllocHealth",
"commits",
"the",
"given",
"allocation",
"health",
"changes",
"to",
"Raft"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployments_watcher.go#L392-L394 |
132,749 | hashicorp/nomad | command/agent/plugins.go | setupPlugins | func (a *Agent) setupPlugins() error {
// Get our internal plugins
internal, err := a.internalPluginConfigs()
if err != nil {
return err
}
// Build the plugin loader
config := &loader.PluginLoaderConfig{
Logger: a.logger,
PluginDir: a.config.PluginDir,
Configs: a.config.Plugi... | go | func (a *Agent) setupPlugins() error {
// Get our internal plugins
internal, err := a.internalPluginConfigs()
if err != nil {
return err
}
// Build the plugin loader
config := &loader.PluginLoaderConfig{
Logger: a.logger,
PluginDir: a.config.PluginDir,
Configs: a.config.Plugi... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"setupPlugins",
"(",
")",
"error",
"{",
"// Get our internal plugins",
"internal",
",",
"err",
":=",
"a",
".",
"internalPluginConfigs",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n"... | // setupPlugins is used to setup the plugin loaders. | [
"setupPlugins",
"is",
"used",
"to",
"setup",
"the",
"plugin",
"loaders",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/plugins.go#L12-L43 |
132,750 | hashicorp/nomad | nomad/structs/node_class.go | ComputeClass | func (n *Node) ComputeClass() error {
hash, err := hashstructure.Hash(n, nil)
if err != nil {
return err
}
n.ComputedClass = fmt.Sprintf("v1:%d", hash)
return nil
} | go | func (n *Node) ComputeClass() error {
hash, err := hashstructure.Hash(n, nil)
if err != nil {
return err
}
n.ComputedClass = fmt.Sprintf("v1:%d", hash)
return nil
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"ComputeClass",
"(",
")",
"error",
"{",
"hash",
",",
"err",
":=",
"hashstructure",
".",
"Hash",
"(",
"n",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"n",
".",
"C... | // ComputeClass computes a derived class for the node based on its attributes.
// ComputedClass is a unique id that identifies nodes with a common set of
// attributes and capabilities. Thus, when calculating a node's computed class
// we avoid including any uniquely identifying fields. | [
"ComputeClass",
"computes",
"a",
"derived",
"class",
"for",
"the",
"node",
"based",
"on",
"its",
"attributes",
".",
"ComputedClass",
"is",
"a",
"unique",
"id",
"that",
"identifies",
"nodes",
"with",
"a",
"common",
"set",
"of",
"attributes",
"and",
"capabilitie... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node_class.go#L31-L39 |
132,751 | hashicorp/nomad | nomad/structs/node_class.go | HashInclude | func (n Node) HashInclude(field string, v interface{}) (bool, error) {
switch field {
case "Datacenter", "Attributes", "Meta", "NodeClass", "NodeResources":
return true, nil
default:
return false, nil
}
} | go | func (n Node) HashInclude(field string, v interface{}) (bool, error) {
switch field {
case "Datacenter", "Attributes", "Meta", "NodeClass", "NodeResources":
return true, nil
default:
return false, nil
}
} | [
"func",
"(",
"n",
"Node",
")",
"HashInclude",
"(",
"field",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"switch",
"field",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",... | // HashInclude is used to blacklist uniquely identifying node fields from being
// included in the computed node class. | [
"HashInclude",
"is",
"used",
"to",
"blacklist",
"uniquely",
"identifying",
"node",
"fields",
"from",
"being",
"included",
"in",
"the",
"computed",
"node",
"class",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node_class.go#L43-L50 |
132,752 | hashicorp/nomad | nomad/structs/node_class.go | HashIncludeMap | func (n Node) HashIncludeMap(field string, k, v interface{}) (bool, error) {
key, ok := k.(string)
if !ok {
return false, fmt.Errorf("map key %v not a string", k)
}
switch field {
case "Meta", "Attributes":
return !IsUniqueNamespace(key), nil
default:
return false, fmt.Errorf("unexpected map field: %v", fi... | go | func (n Node) HashIncludeMap(field string, k, v interface{}) (bool, error) {
key, ok := k.(string)
if !ok {
return false, fmt.Errorf("map key %v not a string", k)
}
switch field {
case "Meta", "Attributes":
return !IsUniqueNamespace(key), nil
default:
return false, fmt.Errorf("unexpected map field: %v", fi... | [
"func",
"(",
"n",
"Node",
")",
"HashIncludeMap",
"(",
"field",
"string",
",",
"k",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"key",
",",
"ok",
":=",
"k",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"r... | // HashIncludeMap is used to blacklist uniquely identifying node map keys from being
// included in the computed node class. | [
"HashIncludeMap",
"is",
"used",
"to",
"blacklist",
"uniquely",
"identifying",
"node",
"map",
"keys",
"from",
"being",
"included",
"in",
"the",
"computed",
"node",
"class",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node_class.go#L54-L66 |
132,753 | hashicorp/nomad | nomad/structs/node_class.go | EscapedConstraints | func EscapedConstraints(constraints []*Constraint) []*Constraint {
var escaped []*Constraint
for _, c := range constraints {
if constraintTargetEscapes(c.LTarget) || constraintTargetEscapes(c.RTarget) {
escaped = append(escaped, c)
}
}
return escaped
} | go | func EscapedConstraints(constraints []*Constraint) []*Constraint {
var escaped []*Constraint
for _, c := range constraints {
if constraintTargetEscapes(c.LTarget) || constraintTargetEscapes(c.RTarget) {
escaped = append(escaped, c)
}
}
return escaped
} | [
"func",
"EscapedConstraints",
"(",
"constraints",
"[",
"]",
"*",
"Constraint",
")",
"[",
"]",
"*",
"Constraint",
"{",
"var",
"escaped",
"[",
"]",
"*",
"Constraint",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"constraints",
"{",
"if",
"constraintTargetEscap... | // EscapedConstraints takes a set of constraints and returns the set that
// escapes computed node classes. | [
"EscapedConstraints",
"takes",
"a",
"set",
"of",
"constraints",
"and",
"returns",
"the",
"set",
"that",
"escapes",
"computed",
"node",
"classes",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node_class.go#L108-L117 |
132,754 | hashicorp/nomad | nomad/structs/node_class.go | constraintTargetEscapes | func constraintTargetEscapes(target string) bool {
switch {
case strings.HasPrefix(target, "${node.unique."):
return true
case strings.HasPrefix(target, "${attr.unique."):
return true
case strings.HasPrefix(target, "${meta.unique."):
return true
default:
return false
}
} | go | func constraintTargetEscapes(target string) bool {
switch {
case strings.HasPrefix(target, "${node.unique."):
return true
case strings.HasPrefix(target, "${attr.unique."):
return true
case strings.HasPrefix(target, "${meta.unique."):
return true
default:
return false
}
} | [
"func",
"constraintTargetEscapes",
"(",
"target",
"string",
")",
"bool",
"{",
"switch",
"{",
"case",
"strings",
".",
"HasPrefix",
"(",
"target",
",",
"\"",
"\"",
")",
":",
"return",
"true",
"\n",
"case",
"strings",
".",
"HasPrefix",
"(",
"target",
",",
"... | // constraintTargetEscapes returns whether the target of a constraint escapes
// computed node class optimization. | [
"constraintTargetEscapes",
"returns",
"whether",
"the",
"target",
"of",
"a",
"constraint",
"escapes",
"computed",
"node",
"class",
"optimization",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node_class.go#L121-L132 |
132,755 | hashicorp/nomad | command/job_plan.go | addPreemptions | func (c *JobPlanCommand) addPreemptions(resp *api.JobPlanResponse) {
c.Ui.Output(c.Colorize().Color("[bold][yellow]Preemptions:\n[reset]"))
if len(resp.Annotations.PreemptedAllocs) < preemptionDisplayThreshold {
var allocs []string
allocs = append(allocs, fmt.Sprintf("Alloc ID|Job ID|Task Group"))
for _, alloc ... | go | func (c *JobPlanCommand) addPreemptions(resp *api.JobPlanResponse) {
c.Ui.Output(c.Colorize().Color("[bold][yellow]Preemptions:\n[reset]"))
if len(resp.Annotations.PreemptedAllocs) < preemptionDisplayThreshold {
var allocs []string
allocs = append(allocs, fmt.Sprintf("Alloc ID|Job ID|Task Group"))
for _, alloc ... | [
"func",
"(",
"c",
"*",
"JobPlanCommand",
")",
"addPreemptions",
"(",
"resp",
"*",
"api",
".",
"JobPlanResponse",
")",
"{",
"c",
".",
"Ui",
".",
"Output",
"(",
"c",
".",
"Colorize",
"(",
")",
".",
"Color",
"(",
"\"",
"\\n",
"\"",
")",
")",
"\n",
"... | // addPreemptions shows details about preempted allocations | [
"addPreemptions",
"shows",
"details",
"about",
"preempted",
"allocations"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L191-L243 |
132,756 | hashicorp/nomad | command/job_plan.go | formatJobModifyIndex | func formatJobModifyIndex(jobModifyIndex uint64, jobName string) string {
help := fmt.Sprintf(jobModifyIndexHelp, jobModifyIndex, jobName)
out := fmt.Sprintf("[reset][bold]Job Modify Index: %d[reset]\n%s", jobModifyIndex, help)
return out
} | go | func formatJobModifyIndex(jobModifyIndex uint64, jobName string) string {
help := fmt.Sprintf(jobModifyIndexHelp, jobModifyIndex, jobName)
out := fmt.Sprintf("[reset][bold]Job Modify Index: %d[reset]\n%s", jobModifyIndex, help)
return out
} | [
"func",
"formatJobModifyIndex",
"(",
"jobModifyIndex",
"uint64",
",",
"jobName",
"string",
")",
"string",
"{",
"help",
":=",
"fmt",
".",
"Sprintf",
"(",
"jobModifyIndexHelp",
",",
"jobModifyIndex",
",",
"jobName",
")",
"\n",
"out",
":=",
"fmt",
".",
"Sprintf",... | // formatJobModifyIndex produces a help string that displays the job modify
// index and how to submit a job with it. | [
"formatJobModifyIndex",
"produces",
"a",
"help",
"string",
"that",
"displays",
"the",
"job",
"modify",
"index",
"and",
"how",
"to",
"submit",
"a",
"job",
"with",
"it",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L266-L270 |
132,757 | hashicorp/nomad | command/job_plan.go | formatDryRun | func formatDryRun(resp *api.JobPlanResponse, job *api.Job) string {
var rolling *api.Evaluation
for _, eval := range resp.CreatedEvals {
if eval.TriggeredBy == "rolling-update" {
rolling = eval
}
}
var out string
if len(resp.FailedTGAllocs) == 0 {
out = "[bold][green]- All tasks successfully allocated.[r... | go | func formatDryRun(resp *api.JobPlanResponse, job *api.Job) string {
var rolling *api.Evaluation
for _, eval := range resp.CreatedEvals {
if eval.TriggeredBy == "rolling-update" {
rolling = eval
}
}
var out string
if len(resp.FailedTGAllocs) == 0 {
out = "[bold][green]- All tasks successfully allocated.[r... | [
"func",
"formatDryRun",
"(",
"resp",
"*",
"api",
".",
"JobPlanResponse",
",",
"job",
"*",
"api",
".",
"Job",
")",
"string",
"{",
"var",
"rolling",
"*",
"api",
".",
"Evaluation",
"\n",
"for",
"_",
",",
"eval",
":=",
"range",
"resp",
".",
"CreatedEvals",... | // formatDryRun produces a string explaining the results of the dry run. | [
"formatDryRun",
"produces",
"a",
"string",
"explaining",
"the",
"results",
"of",
"the",
"dry",
"run",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L273-L324 |
132,758 | hashicorp/nomad | command/job_plan.go | formatJobDiff | func formatJobDiff(job *api.JobDiff, verbose bool) string {
marker, _ := getDiffString(job.Type)
out := fmt.Sprintf("%s[bold]Job: %q\n", marker, job.ID)
// Determine the longest markers and fields so that the output can be
// properly aligned.
longestField, longestMarker := getLongestPrefixes(job.Fields, job.Obje... | go | func formatJobDiff(job *api.JobDiff, verbose bool) string {
marker, _ := getDiffString(job.Type)
out := fmt.Sprintf("%s[bold]Job: %q\n", marker, job.ID)
// Determine the longest markers and fields so that the output can be
// properly aligned.
longestField, longestMarker := getLongestPrefixes(job.Fields, job.Obje... | [
"func",
"formatJobDiff",
"(",
"job",
"*",
"api",
".",
"JobDiff",
",",
"verbose",
"bool",
")",
"string",
"{",
"marker",
",",
"_",
":=",
"getDiffString",
"(",
"job",
".",
"Type",
")",
"\n",
"out",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
... | // formatJobDiff produces an annotated diff of the job. If verbose mode is
// set, added or deleted task groups and tasks are expanded. | [
"formatJobDiff",
"produces",
"an",
"annotated",
"diff",
"of",
"the",
"job",
".",
"If",
"verbose",
"mode",
"is",
"set",
"added",
"or",
"deleted",
"task",
"groups",
"and",
"tasks",
"are",
"expanded",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L328-L359 |
132,759 | hashicorp/nomad | command/job_plan.go | formatTaskGroupDiff | func formatTaskGroupDiff(tg *api.TaskGroupDiff, tgPrefix int, verbose bool) string {
marker, _ := getDiffString(tg.Type)
out := fmt.Sprintf("%s%s[bold]Task Group: %q[reset]", marker, strings.Repeat(" ", tgPrefix), tg.Name)
// Append the updates and colorize them
if l := len(tg.Updates); l > 0 {
order := make([]s... | go | func formatTaskGroupDiff(tg *api.TaskGroupDiff, tgPrefix int, verbose bool) string {
marker, _ := getDiffString(tg.Type)
out := fmt.Sprintf("%s%s[bold]Task Group: %q[reset]", marker, strings.Repeat(" ", tgPrefix), tg.Name)
// Append the updates and colorize them
if l := len(tg.Updates); l > 0 {
order := make([]s... | [
"func",
"formatTaskGroupDiff",
"(",
"tg",
"*",
"api",
".",
"TaskGroupDiff",
",",
"tgPrefix",
"int",
",",
"verbose",
"bool",
")",
"string",
"{",
"marker",
",",
"_",
":=",
"getDiffString",
"(",
"tg",
".",
"Type",
")",
"\n",
"out",
":=",
"fmt",
".",
"Spri... | // formatTaskGroupDiff produces an annotated diff of a task group. If the
// verbose field is set, the task groups fields and objects are expanded even if
// the full object is an addition or removal. tgPrefix is the number of spaces to prefix
// the output of the task group. | [
"formatTaskGroupDiff",
"produces",
"an",
"annotated",
"diff",
"of",
"a",
"task",
"group",
".",
"If",
"the",
"verbose",
"field",
"is",
"set",
"the",
"task",
"groups",
"fields",
"and",
"objects",
"are",
"expanded",
"even",
"if",
"the",
"full",
"object",
"is",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L365-L431 |
132,760 | hashicorp/nomad | command/job_plan.go | formatTaskDiff | func formatTaskDiff(task *api.TaskDiff, startPrefix, taskPrefix int, verbose bool) string {
marker, _ := getDiffString(task.Type)
out := fmt.Sprintf("%s%s%s[bold]Task: %q",
strings.Repeat(" ", startPrefix), marker, strings.Repeat(" ", taskPrefix), task.Name)
if len(task.Annotations) != 0 {
out += fmt.Sprintf(" [... | go | func formatTaskDiff(task *api.TaskDiff, startPrefix, taskPrefix int, verbose bool) string {
marker, _ := getDiffString(task.Type)
out := fmt.Sprintf("%s%s%s[bold]Task: %q",
strings.Repeat(" ", startPrefix), marker, strings.Repeat(" ", taskPrefix), task.Name)
if len(task.Annotations) != 0 {
out += fmt.Sprintf(" [... | [
"func",
"formatTaskDiff",
"(",
"task",
"*",
"api",
".",
"TaskDiff",
",",
"startPrefix",
",",
"taskPrefix",
"int",
",",
"verbose",
"bool",
")",
"string",
"{",
"marker",
",",
"_",
":=",
"getDiffString",
"(",
"task",
".",
"Type",
")",
"\n",
"out",
":=",
"... | // formatTaskDiff produces an annotated diff of a task. If the verbose field is
// set, the tasks fields and objects are expanded even if the full object is an
// addition or removal. startPrefix is the number of spaces to prefix the output of
// the task and taskPrefix is the number of spaces to put between the marker... | [
"formatTaskDiff",
"produces",
"an",
"annotated",
"diff",
"of",
"a",
"task",
".",
"If",
"the",
"verbose",
"field",
"is",
"set",
"the",
"tasks",
"fields",
"and",
"objects",
"are",
"expanded",
"even",
"if",
"the",
"full",
"object",
"is",
"an",
"addition",
"or... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L438-L459 |
132,761 | hashicorp/nomad | command/job_plan.go | formatObjectDiff | func formatObjectDiff(diff *api.ObjectDiff, startPrefix, keyPrefix int) string {
start := strings.Repeat(" ", startPrefix)
marker, markerLen := getDiffString(diff.Type)
out := fmt.Sprintf("%s%s%s%s {\n", start, marker, strings.Repeat(" ", keyPrefix), diff.Name)
// Determine the length of the longest name and longe... | go | func formatObjectDiff(diff *api.ObjectDiff, startPrefix, keyPrefix int) string {
start := strings.Repeat(" ", startPrefix)
marker, markerLen := getDiffString(diff.Type)
out := fmt.Sprintf("%s%s%s%s {\n", start, marker, strings.Repeat(" ", keyPrefix), diff.Name)
// Determine the length of the longest name and longe... | [
"func",
"formatObjectDiff",
"(",
"diff",
"*",
"api",
".",
"ObjectDiff",
",",
"startPrefix",
",",
"keyPrefix",
"int",
")",
"string",
"{",
"start",
":=",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"startPrefix",
")",
"\n",
"marker",
",",
"markerLen",
... | // formatObjectDiff produces an annotated diff of an object. startPrefix is the
// number of spaces to prefix the output of the object and keyPrefix is the number
// of spaces to put between the marker and object name output. | [
"formatObjectDiff",
"produces",
"an",
"annotated",
"diff",
"of",
"an",
"object",
".",
"startPrefix",
"is",
"the",
"number",
"of",
"spaces",
"to",
"prefix",
"the",
"output",
"of",
"the",
"object",
"and",
"keyPrefix",
"is",
"the",
"number",
"of",
"spaces",
"to... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L464-L477 |
132,762 | hashicorp/nomad | command/job_plan.go | formatFieldDiff | func formatFieldDiff(diff *api.FieldDiff, startPrefix, keyPrefix, valuePrefix int) string {
marker, _ := getDiffString(diff.Type)
out := fmt.Sprintf("%s%s%s%s: %s",
strings.Repeat(" ", startPrefix),
marker, strings.Repeat(" ", keyPrefix),
diff.Name,
strings.Repeat(" ", valuePrefix))
switch diff.Type {
case... | go | func formatFieldDiff(diff *api.FieldDiff, startPrefix, keyPrefix, valuePrefix int) string {
marker, _ := getDiffString(diff.Type)
out := fmt.Sprintf("%s%s%s%s: %s",
strings.Repeat(" ", startPrefix),
marker, strings.Repeat(" ", keyPrefix),
diff.Name,
strings.Repeat(" ", valuePrefix))
switch diff.Type {
case... | [
"func",
"formatFieldDiff",
"(",
"diff",
"*",
"api",
".",
"FieldDiff",
",",
"startPrefix",
",",
"keyPrefix",
",",
"valuePrefix",
"int",
")",
"string",
"{",
"marker",
",",
"_",
":=",
"getDiffString",
"(",
"diff",
".",
"Type",
")",
"\n",
"out",
":=",
"fmt",... | // formatFieldDiff produces an annotated diff of a field. startPrefix is the
// number of spaces to prefix the output of the field, keyPrefix is the number
// of spaces to put between the marker and field name output and valuePrefix is
// the number of spaces to put infront of the value for aligning values. | [
"formatFieldDiff",
"produces",
"an",
"annotated",
"diff",
"of",
"a",
"field",
".",
"startPrefix",
"is",
"the",
"number",
"of",
"spaces",
"to",
"prefix",
"the",
"output",
"of",
"the",
"field",
"keyPrefix",
"is",
"the",
"number",
"of",
"spaces",
"to",
"put",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L483-L508 |
132,763 | hashicorp/nomad | command/job_plan.go | alignedFieldAndObjects | func alignedFieldAndObjects(fields []*api.FieldDiff, objects []*api.ObjectDiff,
startPrefix, longestField, longestMarker int) string {
var out string
numFields := len(fields)
numObjects := len(objects)
haveObjects := numObjects != 0
for i, field := range fields {
_, mLength := getDiffString(field.Type)
kPref... | go | func alignedFieldAndObjects(fields []*api.FieldDiff, objects []*api.ObjectDiff,
startPrefix, longestField, longestMarker int) string {
var out string
numFields := len(fields)
numObjects := len(objects)
haveObjects := numObjects != 0
for i, field := range fields {
_, mLength := getDiffString(field.Type)
kPref... | [
"func",
"alignedFieldAndObjects",
"(",
"fields",
"[",
"]",
"*",
"api",
".",
"FieldDiff",
",",
"objects",
"[",
"]",
"*",
"api",
".",
"ObjectDiff",
",",
"startPrefix",
",",
"longestField",
",",
"longestMarker",
"int",
")",
"string",
"{",
"var",
"out",
"strin... | // alignedFieldAndObjects is a helper method that prints fields and objects
// properly aligned. | [
"alignedFieldAndObjects",
"is",
"a",
"helper",
"method",
"that",
"prints",
"fields",
"and",
"objects",
"properly",
"aligned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L512-L543 |
132,764 | hashicorp/nomad | command/job_plan.go | getLongestPrefixes | func getLongestPrefixes(fields []*api.FieldDiff, objects []*api.ObjectDiff) (longestField, longestMarker int) {
for _, field := range fields {
if l := len(field.Name); l > longestField {
longestField = l
}
if _, l := getDiffString(field.Type); l > longestMarker {
longestMarker = l
}
}
for _, obj := ran... | go | func getLongestPrefixes(fields []*api.FieldDiff, objects []*api.ObjectDiff) (longestField, longestMarker int) {
for _, field := range fields {
if l := len(field.Name); l > longestField {
longestField = l
}
if _, l := getDiffString(field.Type); l > longestMarker {
longestMarker = l
}
}
for _, obj := ran... | [
"func",
"getLongestPrefixes",
"(",
"fields",
"[",
"]",
"*",
"api",
".",
"FieldDiff",
",",
"objects",
"[",
"]",
"*",
"api",
".",
"ObjectDiff",
")",
"(",
"longestField",
",",
"longestMarker",
"int",
")",
"{",
"for",
"_",
",",
"field",
":=",
"range",
"fie... | // getLongestPrefixes takes a list of fields and objects and determines the
// longest field name and the longest marker. | [
"getLongestPrefixes",
"takes",
"a",
"list",
"of",
"fields",
"and",
"objects",
"and",
"determines",
"the",
"longest",
"field",
"name",
"and",
"the",
"longest",
"marker",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L547-L562 |
132,765 | hashicorp/nomad | command/job_plan.go | colorAnnotations | func colorAnnotations(annotations []string) string {
l := len(annotations)
if l == 0 {
return ""
}
colored := make([]string, l)
for i, annotation := range annotations {
switch annotation {
case "forces create":
colored[i] = fmt.Sprintf("[green]%s[reset]", annotation)
case "forces destroy":
colored[i... | go | func colorAnnotations(annotations []string) string {
l := len(annotations)
if l == 0 {
return ""
}
colored := make([]string, l)
for i, annotation := range annotations {
switch annotation {
case "forces create":
colored[i] = fmt.Sprintf("[green]%s[reset]", annotation)
case "forces destroy":
colored[i... | [
"func",
"colorAnnotations",
"(",
"annotations",
"[",
"]",
"string",
")",
"string",
"{",
"l",
":=",
"len",
"(",
"annotations",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"colored",
":=",
"make",
"(",
"[",
"]",
"st... | // colorAnnotations returns a comma concatenated list of the annotations where
// the annotations are colored where possible. | [
"colorAnnotations",
"returns",
"a",
"comma",
"concatenated",
"list",
"of",
"the",
"annotations",
"where",
"the",
"annotations",
"are",
"colored",
"where",
"possible",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_plan.go#L581-L604 |
132,766 | hashicorp/nomad | nomad/structs/node.go | MergeHealthCheck | func (di *DriverInfo) MergeHealthCheck(other *DriverInfo) {
di.Healthy = other.Healthy
di.HealthDescription = other.HealthDescription
di.UpdateTime = other.UpdateTime
} | go | func (di *DriverInfo) MergeHealthCheck(other *DriverInfo) {
di.Healthy = other.Healthy
di.HealthDescription = other.HealthDescription
di.UpdateTime = other.UpdateTime
} | [
"func",
"(",
"di",
"*",
"DriverInfo",
")",
"MergeHealthCheck",
"(",
"other",
"*",
"DriverInfo",
")",
"{",
"di",
".",
"Healthy",
"=",
"other",
".",
"Healthy",
"\n",
"di",
".",
"HealthDescription",
"=",
"other",
".",
"HealthDescription",
"\n",
"di",
".",
"... | // MergeHealthCheck merges information from a health check for a drier into a
// node's driver info | [
"MergeHealthCheck",
"merges",
"information",
"from",
"a",
"health",
"check",
"for",
"a",
"drier",
"into",
"a",
"node",
"s",
"driver",
"info"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node.go#L32-L36 |
132,767 | hashicorp/nomad | nomad/structs/node.go | MergeFingerprintInfo | func (di *DriverInfo) MergeFingerprintInfo(other *DriverInfo) {
di.Detected = other.Detected
di.Attributes = other.Attributes
} | go | func (di *DriverInfo) MergeFingerprintInfo(other *DriverInfo) {
di.Detected = other.Detected
di.Attributes = other.Attributes
} | [
"func",
"(",
"di",
"*",
"DriverInfo",
")",
"MergeFingerprintInfo",
"(",
"other",
"*",
"DriverInfo",
")",
"{",
"di",
".",
"Detected",
"=",
"other",
".",
"Detected",
"\n",
"di",
".",
"Attributes",
"=",
"other",
".",
"Attributes",
"\n",
"}"
] | // MergeFingerprint merges information from fingerprinting a node for a driver
// into a node's driver info for that driver. | [
"MergeFingerprint",
"merges",
"information",
"from",
"fingerprinting",
"a",
"node",
"for",
"a",
"driver",
"into",
"a",
"node",
"s",
"driver",
"info",
"for",
"that",
"driver",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node.go#L40-L43 |
132,768 | hashicorp/nomad | nomad/structs/node.go | HealthCheckEquals | func (di *DriverInfo) HealthCheckEquals(other *DriverInfo) bool {
if di == nil && other == nil {
return true
}
if di.Healthy != other.Healthy {
return false
}
if di.HealthDescription != other.HealthDescription {
return false
}
return true
} | go | func (di *DriverInfo) HealthCheckEquals(other *DriverInfo) bool {
if di == nil && other == nil {
return true
}
if di.Healthy != other.Healthy {
return false
}
if di.HealthDescription != other.HealthDescription {
return false
}
return true
} | [
"func",
"(",
"di",
"*",
"DriverInfo",
")",
"HealthCheckEquals",
"(",
"other",
"*",
"DriverInfo",
")",
"bool",
"{",
"if",
"di",
"==",
"nil",
"&&",
"other",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"if",
"di",
".",
"Healthy",
"!=",
"other... | // DriverInfo determines if two driver info objects are equal..As this is used
// in the process of health checking, we only check the fields that are
// computed by the health checker. In the future, this will be merged. | [
"DriverInfo",
"determines",
"if",
"two",
"driver",
"info",
"objects",
"are",
"equal",
"..",
"As",
"this",
"is",
"used",
"in",
"the",
"process",
"of",
"health",
"checking",
"we",
"only",
"check",
"the",
"fields",
"that",
"are",
"computed",
"by",
"the",
"hea... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/node.go#L48-L62 |
132,769 | hashicorp/nomad | command/agent/search_endpoint.go | SearchRequest | func (s *HTTPServer) SearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method == "POST" || req.Method == "PUT" {
return s.newSearchRequest(resp, req)
}
return nil, CodedError(405, ErrInvalidMethod)
} | go | func (s *HTTPServer) SearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method == "POST" || req.Method == "PUT" {
return s.newSearchRequest(resp, req)
}
return nil, CodedError(405, ErrInvalidMethod)
} | [
"func",
"(",
"s",
"*",
"HTTPServer",
")",
"SearchRequest",
"(",
"resp",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"req",
".",
"Method",
"==",
"\"",
"\"",
"... | // SearchRequest accepts a prefix and context and returns a list of matching
// IDs for that context. | [
"SearchRequest",
"accepts",
"a",
"prefix",
"and",
"context",
"and",
"returns",
"a",
"list",
"of",
"matching",
"IDs",
"for",
"that",
"context",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/search_endpoint.go#L11-L16 |
132,770 | hashicorp/nomad | plugins/shared/structs/plugin_reattach_config.go | ReattachConfigToGoPlugin | func ReattachConfigToGoPlugin(rc *ReattachConfig) (*plugin.ReattachConfig, error) {
if rc == nil {
return nil, fmt.Errorf("nil ReattachConfig cannot be converted")
}
plug := &plugin.ReattachConfig{
Protocol: plugin.Protocol(rc.Protocol),
Pid: rc.Pid,
}
switch rc.Network {
case "tcp", "tcp4", "tcp6":
... | go | func ReattachConfigToGoPlugin(rc *ReattachConfig) (*plugin.ReattachConfig, error) {
if rc == nil {
return nil, fmt.Errorf("nil ReattachConfig cannot be converted")
}
plug := &plugin.ReattachConfig{
Protocol: plugin.Protocol(rc.Protocol),
Pid: rc.Pid,
}
switch rc.Network {
case "tcp", "tcp4", "tcp6":
... | [
"func",
"ReattachConfigToGoPlugin",
"(",
"rc",
"*",
"ReattachConfig",
")",
"(",
"*",
"plugin",
".",
"ReattachConfig",
",",
"error",
")",
"{",
"if",
"rc",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"... | // ReattachConfigToGoPlugin converts a ReattachConfig wrapper struct into a go
// plugin ReattachConfig struct | [
"ReattachConfigToGoPlugin",
"converts",
"a",
"ReattachConfig",
"wrapper",
"struct",
"into",
"a",
"go",
"plugin",
"ReattachConfig",
"struct"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/plugin_reattach_config.go#L21-L55 |
132,771 | hashicorp/nomad | plugins/shared/structs/plugin_reattach_config.go | ReattachConfigFromGoPlugin | func ReattachConfigFromGoPlugin(plug *plugin.ReattachConfig) *ReattachConfig {
if plug == nil {
return nil
}
rc := &ReattachConfig{
Protocol: string(plug.Protocol),
Network: plug.Addr.Network(),
Addr: plug.Addr.String(),
Pid: plug.Pid,
}
return rc
} | go | func ReattachConfigFromGoPlugin(plug *plugin.ReattachConfig) *ReattachConfig {
if plug == nil {
return nil
}
rc := &ReattachConfig{
Protocol: string(plug.Protocol),
Network: plug.Addr.Network(),
Addr: plug.Addr.String(),
Pid: plug.Pid,
}
return rc
} | [
"func",
"ReattachConfigFromGoPlugin",
"(",
"plug",
"*",
"plugin",
".",
"ReattachConfig",
")",
"*",
"ReattachConfig",
"{",
"if",
"plug",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"rc",
":=",
"&",
"ReattachConfig",
"{",
"Protocol",
":",
"string",
... | // ReattachConfigFromGoPlugin converts a go plugin ReattachConfig into a
// ReattachConfig wrapper struct | [
"ReattachConfigFromGoPlugin",
"converts",
"a",
"go",
"plugin",
"ReattachConfig",
"into",
"a",
"ReattachConfig",
"wrapper",
"struct"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/shared/structs/plugin_reattach_config.go#L59-L72 |
132,772 | hashicorp/nomad | nomad/heartbeat.go | newNodeHeartbeater | func newNodeHeartbeater(s *Server) *nodeHeartbeater {
return &nodeHeartbeater{
Server: s,
logger: s.logger.Named("heartbeat"),
}
} | go | func newNodeHeartbeater(s *Server) *nodeHeartbeater {
return &nodeHeartbeater{
Server: s,
logger: s.logger.Named("heartbeat"),
}
} | [
"func",
"newNodeHeartbeater",
"(",
"s",
"*",
"Server",
")",
"*",
"nodeHeartbeater",
"{",
"return",
"&",
"nodeHeartbeater",
"{",
"Server",
":",
"s",
",",
"logger",
":",
"s",
".",
"logger",
".",
"Named",
"(",
"\"",
"\"",
")",
",",
"}",
"\n",
"}"
] | // newNodeHeartbeater returns a new node heartbeater used to detect and act on
// failed node heartbeats. | [
"newNodeHeartbeater",
"returns",
"a",
"new",
"node",
"heartbeater",
"used",
"to",
"detect",
"and",
"act",
"on",
"failed",
"node",
"heartbeats",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L46-L51 |
132,773 | hashicorp/nomad | nomad/heartbeat.go | initializeHeartbeatTimers | func (h *nodeHeartbeater) initializeHeartbeatTimers() error {
// Scan all nodes and reset their timer
snap, err := h.fsm.State().Snapshot()
if err != nil {
return err
}
// Get an iterator over nodes
ws := memdb.NewWatchSet()
iter, err := snap.Nodes(ws)
if err != nil {
return err
}
h.heartbeatTimersLock.... | go | func (h *nodeHeartbeater) initializeHeartbeatTimers() error {
// Scan all nodes and reset their timer
snap, err := h.fsm.State().Snapshot()
if err != nil {
return err
}
// Get an iterator over nodes
ws := memdb.NewWatchSet()
iter, err := snap.Nodes(ws)
if err != nil {
return err
}
h.heartbeatTimersLock.... | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"initializeHeartbeatTimers",
"(",
")",
"error",
"{",
"// Scan all nodes and reset their timer",
"snap",
",",
"err",
":=",
"h",
".",
"fsm",
".",
"State",
"(",
")",
".",
"Snapshot",
"(",
")",
"\n",
"if",
"err",
... | // initializeHeartbeatTimers is used when a leader is newly elected to create
// a new map to track heartbeat expiration and to reset all the timers from
// the previously known set of timers. | [
"initializeHeartbeatTimers",
"is",
"used",
"when",
"a",
"leader",
"is",
"newly",
"elected",
"to",
"create",
"a",
"new",
"map",
"to",
"track",
"heartbeat",
"expiration",
"and",
"to",
"reset",
"all",
"the",
"timers",
"from",
"the",
"previously",
"known",
"set",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L56-L86 |
132,774 | hashicorp/nomad | nomad/heartbeat.go | resetHeartbeatTimer | func (h *nodeHeartbeater) resetHeartbeatTimer(id string) (time.Duration, error) {
h.heartbeatTimersLock.Lock()
defer h.heartbeatTimersLock.Unlock()
// Do not create a timer for the node since we are not the leader. This
// check avoids the race in which leadership is lost but a timer is created
// on this server ... | go | func (h *nodeHeartbeater) resetHeartbeatTimer(id string) (time.Duration, error) {
h.heartbeatTimersLock.Lock()
defer h.heartbeatTimersLock.Unlock()
// Do not create a timer for the node since we are not the leader. This
// check avoids the race in which leadership is lost but a timer is created
// on this server ... | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"resetHeartbeatTimer",
"(",
"id",
"string",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"h",
".",
"heartbeatTimersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"heartbeatTimersLock",
... | // resetHeartbeatTimer is used to reset the TTL of a heartbeat.
// This can be used for new heartbeats and existing ones. | [
"resetHeartbeatTimer",
"is",
"used",
"to",
"reset",
"the",
"TTL",
"of",
"a",
"heartbeat",
".",
"This",
"can",
"be",
"used",
"for",
"new",
"heartbeats",
"and",
"existing",
"ones",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L90-L110 |
132,775 | hashicorp/nomad | nomad/heartbeat.go | resetHeartbeatTimerLocked | func (h *nodeHeartbeater) resetHeartbeatTimerLocked(id string, ttl time.Duration) {
// Ensure a timer map exists
if h.heartbeatTimers == nil {
h.heartbeatTimers = make(map[string]*time.Timer)
}
// Renew the heartbeat timer if it exists
if timer, ok := h.heartbeatTimers[id]; ok {
timer.Reset(ttl)
return
}
... | go | func (h *nodeHeartbeater) resetHeartbeatTimerLocked(id string, ttl time.Duration) {
// Ensure a timer map exists
if h.heartbeatTimers == nil {
h.heartbeatTimers = make(map[string]*time.Timer)
}
// Renew the heartbeat timer if it exists
if timer, ok := h.heartbeatTimers[id]; ok {
timer.Reset(ttl)
return
}
... | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"resetHeartbeatTimerLocked",
"(",
"id",
"string",
",",
"ttl",
"time",
".",
"Duration",
")",
"{",
"// Ensure a timer map exists",
"if",
"h",
".",
"heartbeatTimers",
"==",
"nil",
"{",
"h",
".",
"heartbeatTimers",
"=... | // resetHeartbeatTimerLocked is used to reset a heartbeat timer
// assuming the heartbeatTimerLock is already held | [
"resetHeartbeatTimerLocked",
"is",
"used",
"to",
"reset",
"a",
"heartbeat",
"timer",
"assuming",
"the",
"heartbeatTimerLock",
"is",
"already",
"held"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L114-L131 |
132,776 | hashicorp/nomad | nomad/heartbeat.go | invalidateHeartbeat | func (h *nodeHeartbeater) invalidateHeartbeat(id string) {
defer metrics.MeasureSince([]string{"nomad", "heartbeat", "invalidate"}, time.Now())
// Clear the heartbeat timer
h.heartbeatTimersLock.Lock()
if timer, ok := h.heartbeatTimers[id]; ok {
timer.Stop()
delete(h.heartbeatTimers, id)
}
h.heartbeatTimersLo... | go | func (h *nodeHeartbeater) invalidateHeartbeat(id string) {
defer metrics.MeasureSince([]string{"nomad", "heartbeat", "invalidate"}, time.Now())
// Clear the heartbeat timer
h.heartbeatTimersLock.Lock()
if timer, ok := h.heartbeatTimers[id]; ok {
timer.Stop()
delete(h.heartbeatTimers, id)
}
h.heartbeatTimersLo... | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"invalidateHeartbeat",
"(",
"id",
"string",
")",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"time",
".",
"Now",
... | // invalidateHeartbeat is invoked when a heartbeat TTL is reached and we
// need to invalidate the heartbeat. | [
"invalidateHeartbeat",
"is",
"invoked",
"when",
"a",
"heartbeat",
"TTL",
"is",
"reached",
"and",
"we",
"need",
"to",
"invalidate",
"the",
"heartbeat",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L135-L168 |
132,777 | hashicorp/nomad | nomad/heartbeat.go | clearHeartbeatTimer | func (h *nodeHeartbeater) clearHeartbeatTimer(id string) error {
h.heartbeatTimersLock.Lock()
defer h.heartbeatTimersLock.Unlock()
if timer, ok := h.heartbeatTimers[id]; ok {
timer.Stop()
delete(h.heartbeatTimers, id)
}
return nil
} | go | func (h *nodeHeartbeater) clearHeartbeatTimer(id string) error {
h.heartbeatTimersLock.Lock()
defer h.heartbeatTimersLock.Unlock()
if timer, ok := h.heartbeatTimers[id]; ok {
timer.Stop()
delete(h.heartbeatTimers, id)
}
return nil
} | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"clearHeartbeatTimer",
"(",
"id",
"string",
")",
"error",
"{",
"h",
".",
"heartbeatTimersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"heartbeatTimersLock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"... | // clearHeartbeatTimer is used to clear the heartbeat time for
// a single heartbeat. This is used when a heartbeat is destroyed
// explicitly and no longer needed. | [
"clearHeartbeatTimer",
"is",
"used",
"to",
"clear",
"the",
"heartbeat",
"time",
"for",
"a",
"single",
"heartbeat",
".",
"This",
"is",
"used",
"when",
"a",
"heartbeat",
"is",
"destroyed",
"explicitly",
"and",
"no",
"longer",
"needed",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L173-L182 |
132,778 | hashicorp/nomad | nomad/heartbeat.go | clearAllHeartbeatTimers | func (h *nodeHeartbeater) clearAllHeartbeatTimers() error {
h.heartbeatTimersLock.Lock()
defer h.heartbeatTimersLock.Unlock()
for _, t := range h.heartbeatTimers {
t.Stop()
}
h.heartbeatTimers = nil
return nil
} | go | func (h *nodeHeartbeater) clearAllHeartbeatTimers() error {
h.heartbeatTimersLock.Lock()
defer h.heartbeatTimersLock.Unlock()
for _, t := range h.heartbeatTimers {
t.Stop()
}
h.heartbeatTimers = nil
return nil
} | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"clearAllHeartbeatTimers",
"(",
")",
"error",
"{",
"h",
".",
"heartbeatTimersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"heartbeatTimersLock",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"t... | // clearAllHeartbeatTimers is used when a leader is stepping
// down and we no longer need to track any heartbeat timers. | [
"clearAllHeartbeatTimers",
"is",
"used",
"when",
"a",
"leader",
"is",
"stepping",
"down",
"and",
"we",
"no",
"longer",
"need",
"to",
"track",
"any",
"heartbeat",
"timers",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L186-L195 |
132,779 | hashicorp/nomad | nomad/heartbeat.go | heartbeatStats | func (h *nodeHeartbeater) heartbeatStats() {
for {
select {
case <-time.After(5 * time.Second):
h.heartbeatTimersLock.Lock()
num := len(h.heartbeatTimers)
h.heartbeatTimersLock.Unlock()
metrics.SetGauge([]string{"nomad", "heartbeat", "active"}, float32(num))
case <-h.shutdownCh:
return
}
}
} | go | func (h *nodeHeartbeater) heartbeatStats() {
for {
select {
case <-time.After(5 * time.Second):
h.heartbeatTimersLock.Lock()
num := len(h.heartbeatTimers)
h.heartbeatTimersLock.Unlock()
metrics.SetGauge([]string{"nomad", "heartbeat", "active"}, float32(num))
case <-h.shutdownCh:
return
}
}
} | [
"func",
"(",
"h",
"*",
"nodeHeartbeater",
")",
"heartbeatStats",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"time",
".",
"After",
"(",
"5",
"*",
"time",
".",
"Second",
")",
":",
"h",
".",
"heartbeatTimersLock",
".",
"Lock",
"(",
")",
"... | // heartbeatStats is a long running routine used to capture
// the number of active heartbeats being tracked | [
"heartbeatStats",
"is",
"a",
"long",
"running",
"routine",
"used",
"to",
"capture",
"the",
"number",
"of",
"active",
"heartbeats",
"being",
"tracked"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/heartbeat.go#L199-L212 |
132,780 | hashicorp/nomad | api/regions.go | List | func (r *Regions) List() ([]string, error) {
var resp []string
if _, err := r.client.query("/v1/regions", &resp, nil); err != nil {
return nil, err
}
sort.Strings(resp)
return resp, nil
} | go | func (r *Regions) List() ([]string, error) {
var resp []string
if _, err := r.client.query("/v1/regions", &resp, nil); err != nil {
return nil, err
}
sort.Strings(resp)
return resp, nil
} | [
"func",
"(",
"r",
"*",
"Regions",
")",
"List",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"string",
"\n",
"if",
"_",
",",
"err",
":=",
"r",
".",
"client",
".",
"query",
"(",
"\"",
"\"",
",",
"&",
"re... | // List returns a list of all of the regions. | [
"List",
"returns",
"a",
"list",
"of",
"all",
"of",
"the",
"regions",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/regions.go#L16-L23 |
132,781 | hashicorp/nomad | nomad/fsm.go | NewFSM | func NewFSM(config *FSMConfig) (*nomadFSM, error) {
// Create a state store
sconfig := &state.StateStoreConfig{
Logger: config.Logger,
Region: config.Region,
}
state, err := state.NewStateStore(sconfig)
if err != nil {
return nil, err
}
fsm := &nomadFSM{
evalBroker: config.EvalBroker,
periodi... | go | func NewFSM(config *FSMConfig) (*nomadFSM, error) {
// Create a state store
sconfig := &state.StateStoreConfig{
Logger: config.Logger,
Region: config.Region,
}
state, err := state.NewStateStore(sconfig)
if err != nil {
return nil, err
}
fsm := &nomadFSM{
evalBroker: config.EvalBroker,
periodi... | [
"func",
"NewFSM",
"(",
"config",
"*",
"FSMConfig",
")",
"(",
"*",
"nomadFSM",
",",
"error",
")",
"{",
"// Create a state store",
"sconfig",
":=",
"&",
"state",
".",
"StateStoreConfig",
"{",
"Logger",
":",
"config",
".",
"Logger",
",",
"Region",
":",
"confi... | // NewFSMPath is used to construct a new FSM with a blank state | [
"NewFSMPath",
"is",
"used",
"to",
"construct",
"a",
"new",
"FSM",
"with",
"a",
"blank",
"state"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L124-L154 |
132,782 | hashicorp/nomad | nomad/fsm.go | handleJobDeregister | func (n *nomadFSM) handleJobDeregister(index uint64, jobID, namespace string, purge bool, tx state.Txn) error {
// If it is periodic remove it from the dispatcher
if err := n.periodicDispatcher.Remove(namespace, jobID); err != nil {
n.logger.Error("periodicDispatcher.Remove failed", "error", err)
return err
}
... | go | func (n *nomadFSM) handleJobDeregister(index uint64, jobID, namespace string, purge bool, tx state.Txn) error {
// If it is periodic remove it from the dispatcher
if err := n.periodicDispatcher.Remove(namespace, jobID); err != nil {
n.logger.Error("periodicDispatcher.Remove failed", "error", err)
return err
}
... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"handleJobDeregister",
"(",
"index",
"uint64",
",",
"jobID",
",",
"namespace",
"string",
",",
"purge",
"bool",
",",
"tx",
"state",
".",
"Txn",
")",
"error",
"{",
"// If it is periodic remove it from the dispatcher",
"if",
... | // handleJobDeregister is used to deregister a job. | [
"handleJobDeregister",
"is",
"used",
"to",
"deregister",
"a",
"job",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L551-L591 |
132,783 | hashicorp/nomad | nomad/fsm.go | handleUpsertedEvals | func (n *nomadFSM) handleUpsertedEvals(evals []*structs.Evaluation) {
for _, eval := range evals {
n.handleUpsertedEval(eval)
}
} | go | func (n *nomadFSM) handleUpsertedEvals(evals []*structs.Evaluation) {
for _, eval := range evals {
n.handleUpsertedEval(eval)
}
} | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"handleUpsertedEvals",
"(",
"evals",
"[",
"]",
"*",
"structs",
".",
"Evaluation",
")",
"{",
"for",
"_",
",",
"eval",
":=",
"range",
"evals",
"{",
"n",
".",
"handleUpsertedEval",
"(",
"eval",
")",
"\n",
"}",
"\n... | // handleUpsertingEval is a helper for taking action after upserting
// evaluations. | [
"handleUpsertingEval",
"is",
"a",
"helper",
"for",
"taking",
"action",
"after",
"upserting",
"evaluations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L614-L618 |
132,784 | hashicorp/nomad | nomad/fsm.go | handleUpsertedEval | func (n *nomadFSM) handleUpsertedEval(eval *structs.Evaluation) {
if eval == nil {
return
}
if eval.ShouldEnqueue() {
n.evalBroker.Enqueue(eval)
} else if eval.ShouldBlock() {
n.blockedEvals.Block(eval)
} else if eval.Status == structs.EvalStatusComplete &&
len(eval.FailedTGAllocs) == 0 {
// If we have ... | go | func (n *nomadFSM) handleUpsertedEval(eval *structs.Evaluation) {
if eval == nil {
return
}
if eval.ShouldEnqueue() {
n.evalBroker.Enqueue(eval)
} else if eval.ShouldBlock() {
n.blockedEvals.Block(eval)
} else if eval.Status == structs.EvalStatusComplete &&
len(eval.FailedTGAllocs) == 0 {
// If we have ... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"handleUpsertedEval",
"(",
"eval",
"*",
"structs",
".",
"Evaluation",
")",
"{",
"if",
"eval",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"eval",
".",
"ShouldEnqueue",
"(",
")",
"{",
"n",
".",
"evalBro... | // handleUpsertingEval is a helper for taking action after upserting an eval. | [
"handleUpsertingEval",
"is",
"a",
"helper",
"for",
"taking",
"action",
"after",
"upserting",
"an",
"eval",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L621-L636 |
132,785 | hashicorp/nomad | nomad/fsm.go | applyAllocUpdateDesiredTransition | func (n *nomadFSM) applyAllocUpdateDesiredTransition(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "alloc_update_desired_transition"}, time.Now())
var req structs.AllocUpdateDesiredTransitionRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("fa... | go | func (n *nomadFSM) applyAllocUpdateDesiredTransition(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "alloc_update_desired_transition"}, time.Now())
var req structs.AllocUpdateDesiredTransitionRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("fa... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyAllocUpdateDesiredTransition",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
... | // applyAllocUpdateDesiredTransition is used to update the desired transitions
// of a set of allocations. | [
"applyAllocUpdateDesiredTransition",
"is",
"used",
"to",
"update",
"the",
"desired",
"transitions",
"of",
"a",
"set",
"of",
"allocations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L753-L767 |
132,786 | hashicorp/nomad | nomad/fsm.go | applyReconcileSummaries | func (n *nomadFSM) applyReconcileSummaries(buf []byte, index uint64) interface{} {
if err := n.state.ReconcileJobSummaries(index); err != nil {
return err
}
return n.reconcileQueuedAllocations(index)
} | go | func (n *nomadFSM) applyReconcileSummaries(buf []byte, index uint64) interface{} {
if err := n.state.ReconcileJobSummaries(index); err != nil {
return err
}
return n.reconcileQueuedAllocations(index)
} | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyReconcileSummaries",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"if",
"err",
":=",
"n",
".",
"state",
".",
"ReconcileJobSummaries",
"(",
"index",
")",
";",
"err",... | // applyReconcileSummaries reconciles summaries for all the jobs | [
"applyReconcileSummaries",
"reconciles",
"summaries",
"for",
"all",
"the",
"jobs"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L770-L775 |
132,787 | hashicorp/nomad | nomad/fsm.go | applyUpsertNodeEvent | func (n *nomadFSM) applyUpsertNodeEvent(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "upsert_node_events"}, time.Now())
var req structs.EmitNodeEventsRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode EmitNodeEventsRequest: %v... | go | func (n *nomadFSM) applyUpsertNodeEvent(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "upsert_node_events"}, time.Now())
var req structs.EmitNodeEventsRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode EmitNodeEventsRequest: %v... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyUpsertNodeEvent",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",... | // applyUpsertNodeEvent tracks the given node events. | [
"applyUpsertNodeEvent",
"tracks",
"the",
"given",
"node",
"events",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L778-L791 |
132,788 | hashicorp/nomad | nomad/fsm.go | applyUpsertVaultAccessor | func (n *nomadFSM) applyUpsertVaultAccessor(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "upsert_vault_accessor"}, time.Now())
var req structs.VaultAccessorsRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err)... | go | func (n *nomadFSM) applyUpsertVaultAccessor(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "upsert_vault_accessor"}, time.Now())
var req structs.VaultAccessorsRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err)... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyUpsertVaultAccessor",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"... | // applyUpsertVaultAccessor stores the Vault accessors for a given allocation
// and task | [
"applyUpsertVaultAccessor",
"stores",
"the",
"Vault",
"accessors",
"for",
"a",
"given",
"allocation",
"and",
"task"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L795-L808 |
132,789 | hashicorp/nomad | nomad/fsm.go | applyPlanResults | func (n *nomadFSM) applyPlanResults(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_plan_results"}, time.Now())
var req structs.ApplyPlanResultsRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}
if... | go | func (n *nomadFSM) applyPlanResults(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_plan_results"}, time.Now())
var req structs.ApplyPlanResultsRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}
if... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyPlanResults",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"... | // applyPlanApply applies the results of a plan application | [
"applyPlanApply",
"applies",
"the",
"results",
"of",
"a",
"plan",
"application"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L827-L842 |
132,790 | hashicorp/nomad | nomad/fsm.go | applyDeploymentPromotion | func (n *nomadFSM) applyDeploymentPromotion(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_deployment_promotion"}, time.Now())
var req structs.ApplyDeploymentPromoteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode reque... | go | func (n *nomadFSM) applyDeploymentPromotion(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_deployment_promotion"}, time.Now())
var req structs.ApplyDeploymentPromoteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode reque... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyDeploymentPromotion",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"... | // applyDeploymentPromotion is used to promote canaries in a deployment | [
"applyDeploymentPromotion",
"is",
"used",
"to",
"promote",
"canaries",
"in",
"a",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L863-L877 |
132,791 | hashicorp/nomad | nomad/fsm.go | applyDeploymentDelete | func (n *nomadFSM) applyDeploymentDelete(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_deployment_delete"}, time.Now())
var req structs.DeploymentDeleteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err... | go | func (n *nomadFSM) applyDeploymentDelete(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_deployment_delete"}, time.Now())
var req structs.DeploymentDeleteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyDeploymentDelete",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\""... | // applyDeploymentDelete is used to delete a set of deployments | [
"applyDeploymentDelete",
"is",
"used",
"to",
"delete",
"a",
"set",
"of",
"deployments"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L898-L911 |
132,792 | hashicorp/nomad | nomad/fsm.go | applyJobStability | func (n *nomadFSM) applyJobStability(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_job_stability"}, time.Now())
var req structs.JobStabilityRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}
if e... | go | func (n *nomadFSM) applyJobStability(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_job_stability"}, time.Now())
var req structs.JobStabilityRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}
if e... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyJobStability",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
... | // applyJobStability is used to set the stability of a job | [
"applyJobStability",
"is",
"used",
"to",
"set",
"the",
"stability",
"of",
"a",
"job"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L914-L927 |
132,793 | hashicorp/nomad | nomad/fsm.go | applyACLPolicyUpsert | func (n *nomadFSM) applyACLPolicyUpsert(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_policy_upsert"}, time.Now())
var req structs.ACLPolicyUpsertRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))... | go | func (n *nomadFSM) applyACLPolicyUpsert(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_policy_upsert"}, time.Now())
var req structs.ACLPolicyUpsertRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyACLPolicyUpsert",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",... | // applyACLPolicyUpsert is used to upsert a set of policies | [
"applyACLPolicyUpsert",
"is",
"used",
"to",
"upsert",
"a",
"set",
"of",
"policies"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L930-L942 |
132,794 | hashicorp/nomad | nomad/fsm.go | applyACLPolicyDelete | func (n *nomadFSM) applyACLPolicyDelete(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_policy_delete"}, time.Now())
var req structs.ACLPolicyDeleteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))... | go | func (n *nomadFSM) applyACLPolicyDelete(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_policy_delete"}, time.Now())
var req structs.ACLPolicyDeleteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyACLPolicyDelete",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",... | // applyACLPolicyDelete is used to delete a set of policies | [
"applyACLPolicyDelete",
"is",
"used",
"to",
"delete",
"a",
"set",
"of",
"policies"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L945-L957 |
132,795 | hashicorp/nomad | nomad/fsm.go | applyACLTokenUpsert | func (n *nomadFSM) applyACLTokenUpsert(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_token_upsert"}, time.Now())
var req structs.ACLTokenUpsertRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}... | go | func (n *nomadFSM) applyACLTokenUpsert(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_token_upsert"}, time.Now())
var req structs.ACLTokenUpsertRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyACLTokenUpsert",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
... | // applyACLTokenUpsert is used to upsert a set of policies | [
"applyACLTokenUpsert",
"is",
"used",
"to",
"upsert",
"a",
"set",
"of",
"policies"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L960-L972 |
132,796 | hashicorp/nomad | nomad/fsm.go | applyACLTokenDelete | func (n *nomadFSM) applyACLTokenDelete(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_token_delete"}, time.Now())
var req structs.ACLTokenDeleteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}... | go | func (n *nomadFSM) applyACLTokenDelete(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_token_delete"}, time.Now())
var req structs.ACLTokenDeleteRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyACLTokenDelete",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
... | // applyACLTokenDelete is used to delete a set of policies | [
"applyACLTokenDelete",
"is",
"used",
"to",
"delete",
"a",
"set",
"of",
"policies"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L975-L987 |
132,797 | hashicorp/nomad | nomad/fsm.go | applyACLTokenBootstrap | func (n *nomadFSM) applyACLTokenBootstrap(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_token_bootstrap"}, time.Now())
var req structs.ACLTokenBootstrapRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v",... | go | func (n *nomadFSM) applyACLTokenBootstrap(buf []byte, index uint64) interface{} {
defer metrics.MeasureSince([]string{"nomad", "fsm", "apply_acl_token_bootstrap"}, time.Now())
var req structs.ACLTokenBootstrapRequest
if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v",... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"applyACLTokenBootstrap",
"(",
"buf",
"[",
"]",
"byte",
",",
"index",
"uint64",
")",
"interface",
"{",
"}",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"... | // applyACLTokenBootstrap is used to bootstrap an ACL token | [
"applyACLTokenBootstrap",
"is",
"used",
"to",
"bootstrap",
"an",
"ACL",
"token"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L990-L1002 |
132,798 | hashicorp/nomad | nomad/fsm.go | failLeakedDeployments | func (n *nomadFSM) failLeakedDeployments(state *state.StateStore) error {
// Scan for deployments that are referencing a job that no longer exists.
// This could happen if multiple deployments were created for a given job
// and thus the older deployment leaks and then the job is removed.
iter, err := state.Deploym... | go | func (n *nomadFSM) failLeakedDeployments(state *state.StateStore) error {
// Scan for deployments that are referencing a job that no longer exists.
// This could happen if multiple deployments were created for a given job
// and thus the older deployment leaks and then the job is removed.
iter, err := state.Deploym... | [
"func",
"(",
"n",
"*",
"nomadFSM",
")",
"failLeakedDeployments",
"(",
"state",
"*",
"state",
".",
"StateStore",
")",
"error",
"{",
"// Scan for deployments that are referencing a job that no longer exists.",
"// This could happen if multiple deployments were created for a given job... | // failLeakedDeployments is used to fail deployments that do not have a job.
// This state is a broken invariant that should not occur since 0.8.X. | [
"failLeakedDeployments",
"is",
"used",
"to",
"fail",
"deployments",
"that",
"do",
"not",
"have",
"a",
"job",
".",
"This",
"state",
"is",
"a",
"broken",
"invariant",
"that",
"should",
"not",
"occur",
"since",
"0",
".",
"8",
".",
"X",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/fsm.go#L1330-L1379 |
132,799 | hashicorp/nomad | nomad/drainer/watch_nodes.go | TrackedNodes | func (n *NodeDrainer) TrackedNodes() map[string]*structs.Node {
n.l.RLock()
defer n.l.RUnlock()
t := make(map[string]*structs.Node, len(n.nodes))
for n, d := range n.nodes {
t[n] = d.GetNode()
}
return t
} | go | func (n *NodeDrainer) TrackedNodes() map[string]*structs.Node {
n.l.RLock()
defer n.l.RUnlock()
t := make(map[string]*structs.Node, len(n.nodes))
for n, d := range n.nodes {
t[n] = d.GetNode()
}
return t
} | [
"func",
"(",
"n",
"*",
"NodeDrainer",
")",
"TrackedNodes",
"(",
")",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"Node",
"{",
"n",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"l",
".",
"RUnlock",
"(",
")",
"\n\n",
"t",
":=",
... | // TrackedNodes returns the set of tracked nodes | [
"TrackedNodes",
"returns",
"the",
"set",
"of",
"tracked",
"nodes"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L19-L29 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.