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,100 | hashicorp/nomad | nomad/raft_rpc.go | getTLSWrapper | func (l *RaftLayer) getTLSWrapper() tlsutil.Wrapper {
l.tlsWrapLock.RLock()
defer l.tlsWrapLock.RUnlock()
return l.tlsWrap
} | go | func (l *RaftLayer) getTLSWrapper() tlsutil.Wrapper {
l.tlsWrapLock.RLock()
defer l.tlsWrapLock.RUnlock()
return l.tlsWrap
} | [
"func",
"(",
"l",
"*",
"RaftLayer",
")",
"getTLSWrapper",
"(",
")",
"tlsutil",
".",
"Wrapper",
"{",
"l",
".",
"tlsWrapLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"l",
".",
"tlsWrapLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"l",
".",
"tlsWrap"... | // getTLSWrapper is used to retrieve the current TLS wrapper | [
"getTLSWrapper",
"is",
"used",
"to",
"retrieve",
"the",
"current",
"TLS",
"wrapper"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/raft_rpc.go#L84-L88 |
132,101 | hashicorp/nomad | nomad/raft_rpc.go | ReloadTLS | func (l *RaftLayer) ReloadTLS(tlsWrap tlsutil.Wrapper) {
l.tlsWrapLock.Lock()
defer l.tlsWrapLock.Unlock()
l.tlsWrap = tlsWrap
} | go | func (l *RaftLayer) ReloadTLS(tlsWrap tlsutil.Wrapper) {
l.tlsWrapLock.Lock()
defer l.tlsWrapLock.Unlock()
l.tlsWrap = tlsWrap
} | [
"func",
"(",
"l",
"*",
"RaftLayer",
")",
"ReloadTLS",
"(",
"tlsWrap",
"tlsutil",
".",
"Wrapper",
")",
"{",
"l",
".",
"tlsWrapLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"tlsWrapLock",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"tlsWrap",
"... | // ReloadTLS swaps the TLS wrapper. This is useful when upgrading or
// downgrading TLS connections. | [
"ReloadTLS",
"swaps",
"the",
"TLS",
"wrapper",
".",
"This",
"is",
"useful",
"when",
"upgrading",
"or",
"downgrading",
"TLS",
"connections",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/raft_rpc.go#L92-L96 |
132,102 | hashicorp/nomad | drivers/java/driver.go | GetAbsolutePath | func GetAbsolutePath(bin string) (string, error) {
lp, err := exec.LookPath(bin)
if err != nil {
return "", fmt.Errorf("failed to resolve path to %q executable: %v", bin, err)
}
return filepath.EvalSymlinks(lp)
} | go | func GetAbsolutePath(bin string) (string, error) {
lp, err := exec.LookPath(bin)
if err != nil {
return "", fmt.Errorf("failed to resolve path to %q executable: %v", bin, err)
}
return filepath.EvalSymlinks(lp)
} | [
"func",
"GetAbsolutePath",
"(",
"bin",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"lp",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"bin",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"... | // GetAbsolutePath returns the absolute path of the passed binary by resolving
// it in the path and following symlinks. | [
"GetAbsolutePath",
"returns",
"the",
"absolute",
"path",
"of",
"the",
"passed",
"binary",
"by",
"resolving",
"it",
"in",
"the",
"path",
"and",
"following",
"symlinks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/java/driver.go#L559-L566 |
132,103 | hashicorp/nomad | command/agent/http_oss.go | registerEnterpriseHandlers | func (s *HTTPServer) registerEnterpriseHandlers() {
s.mux.HandleFunc("/v1/namespaces", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/namespace", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/namespace/", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/sentinel/policies", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/sentinel/policy/",... | go | func (s *HTTPServer) registerEnterpriseHandlers() {
s.mux.HandleFunc("/v1/namespaces", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/namespace", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/namespace/", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/sentinel/policies", s.wrap(s.entOnly))
s.mux.HandleFunc("/v1/sentinel/policy/",... | [
"func",
"(",
"s",
"*",
"HTTPServer",
")",
"registerEnterpriseHandlers",
"(",
")",
"{",
"s",
".",
"mux",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"s",
".",
"wrap",
"(",
"s",
".",
"entOnly",
")",
")",
"\n",
"s",
".",
"mux",
".",
"HandleFunc",
"(",
... | // registerEnterpriseHandlers is a no-op for the oss release | [
"registerEnterpriseHandlers",
"is",
"a",
"no",
"-",
"op",
"for",
"the",
"oss",
"release"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/http_oss.go#L8-L20 |
132,104 | hashicorp/nomad | command/node_status.go | getRunningAllocs | func getRunningAllocs(client *api.Client, nodeID string) ([]*api.Allocation, error) {
var allocs []*api.Allocation
// Query the node allocations
nodeAllocs, _, err := client.Nodes().Allocations(nodeID, nil)
// Filter list to only running allocations
for _, alloc := range nodeAllocs {
if alloc.ClientStatus == "r... | go | func getRunningAllocs(client *api.Client, nodeID string) ([]*api.Allocation, error) {
var allocs []*api.Allocation
// Query the node allocations
nodeAllocs, _, err := client.Nodes().Allocations(nodeID, nil)
// Filter list to only running allocations
for _, alloc := range nodeAllocs {
if alloc.ClientStatus == "r... | [
"func",
"getRunningAllocs",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"nodeID",
"string",
")",
"(",
"[",
"]",
"*",
"api",
".",
"Allocation",
",",
"error",
")",
"{",
"var",
"allocs",
"[",
"]",
"*",
"api",
".",
"Allocation",
"\n\n",
"// Query the no... | // getRunningAllocs returns a slice of allocation id's running on the node | [
"getRunningAllocs",
"returns",
"a",
"slice",
"of",
"allocation",
"id",
"s",
"running",
"on",
"the",
"node"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/node_status.go#L623-L635 |
132,105 | hashicorp/nomad | command/node_status.go | getAllocatedResources | func getAllocatedResources(client *api.Client, runningAllocs []*api.Allocation, node *api.Node) []string {
// Compute the total
total := computeNodeTotalResources(node)
// Get Resources
var cpu, mem, disk int
for _, alloc := range runningAllocs {
cpu += *alloc.Resources.CPU
mem += *alloc.Resources.MemoryMB
... | go | func getAllocatedResources(client *api.Client, runningAllocs []*api.Allocation, node *api.Node) []string {
// Compute the total
total := computeNodeTotalResources(node)
// Get Resources
var cpu, mem, disk int
for _, alloc := range runningAllocs {
cpu += *alloc.Resources.CPU
mem += *alloc.Resources.MemoryMB
... | [
"func",
"getAllocatedResources",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"runningAllocs",
"[",
"]",
"*",
"api",
".",
"Allocation",
",",
"node",
"*",
"api",
".",
"Node",
")",
"[",
"]",
"string",
"{",
"// Compute the total",
"total",
":=",
"computeNod... | // getAllocatedResources returns the resource usage of the node. | [
"getAllocatedResources",
"returns",
"the",
"resource",
"usage",
"of",
"the",
"node",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/node_status.go#L638-L661 |
132,106 | hashicorp/nomad | command/node_status.go | getActualResources | func getActualResources(client *api.Client, runningAllocs []*api.Allocation, node *api.Node) ([]string, error) {
// Compute the total
total := computeNodeTotalResources(node)
// Get Resources
var cpu float64
var mem uint64
for _, alloc := range runningAllocs {
// Make the call to the client to get the actual u... | go | func getActualResources(client *api.Client, runningAllocs []*api.Allocation, node *api.Node) ([]string, error) {
// Compute the total
total := computeNodeTotalResources(node)
// Get Resources
var cpu float64
var mem uint64
for _, alloc := range runningAllocs {
// Make the call to the client to get the actual u... | [
"func",
"getActualResources",
"(",
"client",
"*",
"api",
".",
"Client",
",",
"runningAllocs",
"[",
"]",
"*",
"api",
".",
"Allocation",
",",
"node",
"*",
"api",
".",
"Node",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"// Compute the total",
"... | // getActualResources returns the actual resource usage of the allocations. | [
"getActualResources",
"returns",
"the",
"actual",
"resource",
"usage",
"of",
"the",
"allocations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/node_status.go#L680-L707 |
132,107 | hashicorp/nomad | command/node_status.go | getHostResources | func getHostResources(hostStats *api.HostStats, node *api.Node) ([]string, error) {
if hostStats == nil {
return nil, fmt.Errorf("actual resource usage not present")
}
var resources []string
// calculate disk usage
storageDevice := node.Attributes["unique.storage.volume"]
var diskUsed, diskSize uint64
var phy... | go | func getHostResources(hostStats *api.HostStats, node *api.Node) ([]string, error) {
if hostStats == nil {
return nil, fmt.Errorf("actual resource usage not present")
}
var resources []string
// calculate disk usage
storageDevice := node.Attributes["unique.storage.volume"]
var diskUsed, diskSize uint64
var phy... | [
"func",
"getHostResources",
"(",
"hostStats",
"*",
"api",
".",
"HostStats",
",",
"node",
"*",
"api",
".",
"Node",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"hostStats",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
... | // getHostResources returns the actual resource usage of the node. | [
"getHostResources",
"returns",
"the",
"actual",
"resource",
"usage",
"of",
"the",
"node",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/node_status.go#L710-L751 |
132,108 | hashicorp/nomad | command/node_status.go | formatNodeStubList | func formatNodeStubList(nodes []*api.NodeListStub, verbose bool) string {
// Return error if no nodes are found
if len(nodes) == 0 {
return ""
}
// Truncate the id unless full length is requested
length := shortId
if verbose {
length = fullId
}
// Format the nodes list that matches the prefix so that the u... | go | func formatNodeStubList(nodes []*api.NodeListStub, verbose bool) string {
// Return error if no nodes are found
if len(nodes) == 0 {
return ""
}
// Truncate the id unless full length is requested
length := shortId
if verbose {
length = fullId
}
// Format the nodes list that matches the prefix so that the u... | [
"func",
"formatNodeStubList",
"(",
"nodes",
"[",
"]",
"*",
"api",
".",
"NodeListStub",
",",
"verbose",
"bool",
")",
"string",
"{",
"// Return error if no nodes are found",
"if",
"len",
"(",
"nodes",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n... | // formatNodeStubList is used to return a table format of a list of node stubs. | [
"formatNodeStubList",
"is",
"used",
"to",
"return",
"a",
"table",
"format",
"of",
"a",
"list",
"of",
"node",
"stubs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/node_status.go#L754-L781 |
132,109 | hashicorp/nomad | api/api.go | ClientConfig | func (c *Config) ClientConfig(region, address string, tlsEnabled bool) *Config {
scheme := "http"
if tlsEnabled {
scheme = "https"
}
defaultConfig := DefaultConfig()
config := &Config{
Address: fmt.Sprintf("%s://%s", scheme, address),
Region: region,
Namespace: c.Namespace,
httpClient: defaultCon... | go | func (c *Config) ClientConfig(region, address string, tlsEnabled bool) *Config {
scheme := "http"
if tlsEnabled {
scheme = "https"
}
defaultConfig := DefaultConfig()
config := &Config{
Address: fmt.Sprintf("%s://%s", scheme, address),
Region: region,
Namespace: c.Namespace,
httpClient: defaultCon... | [
"func",
"(",
"c",
"*",
"Config",
")",
"ClientConfig",
"(",
"region",
",",
"address",
"string",
",",
"tlsEnabled",
"bool",
")",
"*",
"Config",
"{",
"scheme",
":=",
"\"",
"\"",
"\n",
"if",
"tlsEnabled",
"{",
"scheme",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
... | // ClientConfig copies the configuration with a new client address, region, and
// whether the client has TLS enabled. | [
"ClientConfig",
"copies",
"the",
"configuration",
"with",
"a",
"new",
"client",
"address",
"region",
"and",
"whether",
"the",
"client",
"has",
"TLS",
"enabled",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L140-L163 |
132,110 | hashicorp/nomad | api/api.go | DefaultConfig | func DefaultConfig() *Config {
config := &Config{
Address: "http://127.0.0.1:4646",
httpClient: cleanhttp.DefaultClient(),
TLSConfig: &TLSConfig{},
}
transport := config.httpClient.Transport.(*http.Transport)
transport.TLSHandshakeTimeout = 10 * time.Second
transport.TLSClientConfig = &tls.Config{
MinV... | go | func DefaultConfig() *Config {
config := &Config{
Address: "http://127.0.0.1:4646",
httpClient: cleanhttp.DefaultClient(),
TLSConfig: &TLSConfig{},
}
transport := config.httpClient.Transport.(*http.Transport)
transport.TLSHandshakeTimeout = 10 * time.Second
transport.TLSClientConfig = &tls.Config{
MinV... | [
"func",
"DefaultConfig",
"(",
")",
"*",
"Config",
"{",
"config",
":=",
"&",
"Config",
"{",
"Address",
":",
"\"",
"\"",
",",
"httpClient",
":",
"cleanhttp",
".",
"DefaultClient",
"(",
")",
",",
"TLSConfig",
":",
"&",
"TLSConfig",
"{",
"}",
",",
"}",
"... | // DefaultConfig returns a default configuration for the client | [
"DefaultConfig",
"returns",
"a",
"default",
"configuration",
"for",
"the",
"client"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L201-L260 |
132,111 | hashicorp/nomad | api/api.go | SetTimeout | func (c *Config) SetTimeout(t time.Duration) error {
if c == nil {
return fmt.Errorf("nil config")
} else if c.httpClient == nil {
return fmt.Errorf("nil HTTP client")
} else if c.httpClient.Transport == nil {
return fmt.Errorf("nil HTTP client transport")
}
// Apply a timeout.
if t.Nanoseconds() >= 0 {
... | go | func (c *Config) SetTimeout(t time.Duration) error {
if c == nil {
return fmt.Errorf("nil config")
} else if c.httpClient == nil {
return fmt.Errorf("nil HTTP client")
} else if c.httpClient.Transport == nil {
return fmt.Errorf("nil HTTP client transport")
}
// Apply a timeout.
if t.Nanoseconds() >= 0 {
... | [
"func",
"(",
"c",
"*",
"Config",
")",
"SetTimeout",
"(",
"t",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"c",
".",
"httpClient",
"==",
... | // SetTimeout is used to place a timeout for connecting to Nomad. A negative
// duration is ignored, a duration of zero means no timeout, and any other value
// will add a timeout. | [
"SetTimeout",
"is",
"used",
"to",
"place",
"a",
"timeout",
"for",
"connecting",
"to",
"Nomad",
".",
"A",
"negative",
"duration",
"is",
"ignored",
"a",
"duration",
"of",
"zero",
"means",
"no",
"timeout",
"and",
"any",
"other",
"value",
"will",
"add",
"a",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L265-L288 |
132,112 | hashicorp/nomad | api/api.go | ConfigureTLS | func (c *Config) ConfigureTLS() error {
if c.TLSConfig == nil {
return nil
}
if c.httpClient == nil {
return fmt.Errorf("config HTTP Client must be set")
}
var clientCert tls.Certificate
foundClientCert := false
if c.TLSConfig.ClientCert != "" || c.TLSConfig.ClientKey != "" {
if c.TLSConfig.ClientCert != ... | go | func (c *Config) ConfigureTLS() error {
if c.TLSConfig == nil {
return nil
}
if c.httpClient == nil {
return fmt.Errorf("config HTTP Client must be set")
}
var clientCert tls.Certificate
foundClientCert := false
if c.TLSConfig.ClientCert != "" || c.TLSConfig.ClientKey != "" {
if c.TLSConfig.ClientCert != ... | [
"func",
"(",
"c",
"*",
"Config",
")",
"ConfigureTLS",
"(",
")",
"error",
"{",
"if",
"c",
".",
"TLSConfig",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"c",
".",
"httpClient",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\... | // ConfigureTLS applies a set of TLS configurations to the the HTTP client. | [
"ConfigureTLS",
"applies",
"a",
"set",
"of",
"TLS",
"configurations",
"to",
"the",
"the",
"HTTP",
"client",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L291-L333 |
132,113 | hashicorp/nomad | api/api.go | GetNodeClient | func (c *Client) GetNodeClient(nodeID string, q *QueryOptions) (*Client, error) {
return c.getNodeClientImpl(nodeID, -1, q, c.Nodes().Info)
} | go | func (c *Client) GetNodeClient(nodeID string, q *QueryOptions) (*Client, error) {
return c.getNodeClientImpl(nodeID, -1, q, c.Nodes().Info)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetNodeClient",
"(",
"nodeID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"return",
"c",
".",
"getNodeClientImpl",
"(",
"nodeID",
",",
"-",
"1",
",",
"q",
",",
"c... | // GetNodeClient returns a new Client that will dial the specified node. If the
// QueryOptions is set, its region will be used. | [
"GetNodeClient",
"returns",
"a",
"new",
"Client",
"that",
"will",
"dial",
"the",
"specified",
"node",
".",
"If",
"the",
"QueryOptions",
"is",
"set",
"its",
"region",
"will",
"be",
"used",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L383-L385 |
132,114 | hashicorp/nomad | api/api.go | GetNodeClientWithTimeout | func (c *Client) GetNodeClientWithTimeout(
nodeID string, timeout time.Duration, q *QueryOptions) (*Client, error) {
return c.getNodeClientImpl(nodeID, timeout, q, c.Nodes().Info)
} | go | func (c *Client) GetNodeClientWithTimeout(
nodeID string, timeout time.Duration, q *QueryOptions) (*Client, error) {
return c.getNodeClientImpl(nodeID, timeout, q, c.Nodes().Info)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetNodeClientWithTimeout",
"(",
"nodeID",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"return",
"c",
".",
"getNodeClientImpl",
"... | // GetNodeClientWithTimeout returns a new Client that will dial the specified
// node using the specified timeout. If the QueryOptions is set, its region will
// be used. | [
"GetNodeClientWithTimeout",
"returns",
"a",
"new",
"Client",
"that",
"will",
"dial",
"the",
"specified",
"node",
"using",
"the",
"specified",
"timeout",
".",
"If",
"the",
"QueryOptions",
"is",
"set",
"its",
"region",
"will",
"be",
"used",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L390-L393 |
132,115 | hashicorp/nomad | api/api.go | getNodeClientImpl | func (c *Client) getNodeClientImpl(nodeID string, timeout time.Duration, q *QueryOptions, lookup nodeLookup) (*Client, error) {
node, _, err := lookup(nodeID, q)
if err != nil {
return nil, err
}
if node.Status == "down" {
return nil, NodeDownErr
}
if node.HTTPAddr == "" {
return nil, fmt.Errorf("http addr ... | go | func (c *Client) getNodeClientImpl(nodeID string, timeout time.Duration, q *QueryOptions, lookup nodeLookup) (*Client, error) {
node, _, err := lookup(nodeID, q)
if err != nil {
return nil, err
}
if node.Status == "down" {
return nil, NodeDownErr
}
if node.HTTPAddr == "" {
return nil, fmt.Errorf("http addr ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"getNodeClientImpl",
"(",
"nodeID",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"q",
"*",
"QueryOptions",
",",
"lookup",
"nodeLookup",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"node",
",",
"_",
... | // getNodeClientImpl is the implementation of creating a API client for
// contacting a node. It takes a function to lookup the node such that it can be
// mocked during tests. | [
"getNodeClientImpl",
"is",
"the",
"implementation",
"of",
"creating",
"a",
"API",
"client",
"for",
"contacting",
"a",
"node",
".",
"It",
"takes",
"a",
"function",
"to",
"lookup",
"the",
"node",
"such",
"that",
"it",
"can",
"be",
"mocked",
"during",
"tests",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L402-L434 |
132,116 | hashicorp/nomad | api/api.go | durToMsec | func durToMsec(dur time.Duration) string {
return fmt.Sprintf("%dms", dur/time.Millisecond)
} | go | func durToMsec(dur time.Duration) string {
return fmt.Sprintf("%dms", dur/time.Millisecond)
} | [
"func",
"durToMsec",
"(",
"dur",
"time",
".",
"Duration",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"dur",
"/",
"time",
".",
"Millisecond",
")",
"\n",
"}"
] | // durToMsec converts a duration to a millisecond specified string | [
"durToMsec",
"converts",
"a",
"duration",
"to",
"a",
"millisecond",
"specified",
"string"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L485-L487 |
132,117 | hashicorp/nomad | api/api.go | rawQuery | func (c *Client) rawQuery(endpoint string, q *QueryOptions) (io.ReadCloser, error) {
r, err := c.newRequest("GET", endpoint)
if err != nil {
return nil, err
}
r.setQueryOptions(q)
_, resp, err := requireOK(c.doRequest(r))
if err != nil {
return nil, err
}
return resp.Body, nil
} | go | func (c *Client) rawQuery(endpoint string, q *QueryOptions) (io.ReadCloser, error) {
r, err := c.newRequest("GET", endpoint)
if err != nil {
return nil, err
}
r.setQueryOptions(q)
_, resp, err := requireOK(c.doRequest(r))
if err != nil {
return nil, err
}
return resp.Body, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"rawQuery",
"(",
"endpoint",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"c",
".",
"newRequest",
"(",
"\"",
"\"",
",",
"endpoint",
... | // rawQuery makes a GET request to the specified endpoint but returns just the
// response body. | [
"rawQuery",
"makes",
"a",
"GET",
"request",
"to",
"the",
"specified",
"endpoint",
"but",
"returns",
"just",
"the",
"response",
"body",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L644-L656 |
132,118 | hashicorp/nomad | api/api.go | parseQueryMeta | func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
header := resp.Header
// Parse the X-Nomad-Index
index, err := strconv.ParseUint(header.Get("X-Nomad-Index"), 10, 64)
if err != nil {
return fmt.Errorf("Failed to parse X-Nomad-Index: %v", err)
}
q.LastIndex = index
// Parse the X-Nomad-LastConta... | go | func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
header := resp.Header
// Parse the X-Nomad-Index
index, err := strconv.ParseUint(header.Get("X-Nomad-Index"), 10, 64)
if err != nil {
return fmt.Errorf("Failed to parse X-Nomad-Index: %v", err)
}
q.LastIndex = index
// Parse the X-Nomad-LastConta... | [
"func",
"parseQueryMeta",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"q",
"*",
"QueryMeta",
")",
"error",
"{",
"header",
":=",
"resp",
".",
"Header",
"\n\n",
"// Parse the X-Nomad-Index",
"index",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"h... | // parseQueryMeta is used to help parse query meta-data | [
"parseQueryMeta",
"is",
"used",
"to",
"help",
"parse",
"query",
"meta",
"-",
"data"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L761-L786 |
132,119 | hashicorp/nomad | api/api.go | parseWriteMeta | func parseWriteMeta(resp *http.Response, q *WriteMeta) error {
header := resp.Header
// Parse the X-Nomad-Index
index, err := strconv.ParseUint(header.Get("X-Nomad-Index"), 10, 64)
if err != nil {
return fmt.Errorf("Failed to parse X-Nomad-Index: %v", err)
}
q.LastIndex = index
return nil
} | go | func parseWriteMeta(resp *http.Response, q *WriteMeta) error {
header := resp.Header
// Parse the X-Nomad-Index
index, err := strconv.ParseUint(header.Get("X-Nomad-Index"), 10, 64)
if err != nil {
return fmt.Errorf("Failed to parse X-Nomad-Index: %v", err)
}
q.LastIndex = index
return nil
} | [
"func",
"parseWriteMeta",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"q",
"*",
"WriteMeta",
")",
"error",
"{",
"header",
":=",
"resp",
".",
"Header",
"\n\n",
"// Parse the X-Nomad-Index",
"index",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"h... | // parseWriteMeta is used to help parse write meta-data | [
"parseWriteMeta",
"is",
"used",
"to",
"help",
"parse",
"write",
"meta",
"-",
"data"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/api.go#L789-L799 |
132,120 | hashicorp/nomad | client/allocrunner/taskrunner/vault_hook.go | deriveVaultToken | func (h *vaultHook) deriveVaultToken() (token string, exit bool) {
attempts := 0
for {
tokens, err := h.client.DeriveToken(h.alloc, []string{h.taskName})
if err == nil {
return tokens[h.taskName], false
}
// Check if this is a server side error
if structs.IsServerSide(err) {
h.logger.Error("failed to... | go | func (h *vaultHook) deriveVaultToken() (token string, exit bool) {
attempts := 0
for {
tokens, err := h.client.DeriveToken(h.alloc, []string{h.taskName})
if err == nil {
return tokens[h.taskName], false
}
// Check if this is a server side error
if structs.IsServerSide(err) {
h.logger.Error("failed to... | [
"func",
"(",
"h",
"*",
"vaultHook",
")",
"deriveVaultToken",
"(",
")",
"(",
"token",
"string",
",",
"exit",
"bool",
")",
"{",
"attempts",
":=",
"0",
"\n",
"for",
"{",
"tokens",
",",
"err",
":=",
"h",
".",
"client",
".",
"DeriveToken",
"(",
"h",
"."... | // deriveVaultToken derives the Vault token using exponential backoffs. It
// returns the Vault token and whether the manager should exit. | [
"deriveVaultToken",
"derives",
"the",
"Vault",
"token",
"using",
"exponential",
"backoffs",
".",
"It",
"returns",
"the",
"Vault",
"token",
"and",
"whether",
"the",
"manager",
"should",
"exit",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/vault_hook.go#L293-L337 |
132,121 | hashicorp/nomad | client/allocrunner/taskrunner/vault_hook.go | writeToken | func (h *vaultHook) writeToken(token string) error {
if err := ioutil.WriteFile(h.tokenPath, []byte(token), 0666); err != nil {
return fmt.Errorf("failed to write vault token: %v", err)
}
return nil
} | go | func (h *vaultHook) writeToken(token string) error {
if err := ioutil.WriteFile(h.tokenPath, []byte(token), 0666); err != nil {
return fmt.Errorf("failed to write vault token: %v", err)
}
return nil
} | [
"func",
"(",
"h",
"*",
"vaultHook",
")",
"writeToken",
"(",
"token",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"ioutil",
".",
"WriteFile",
"(",
"h",
".",
"tokenPath",
",",
"[",
"]",
"byte",
"(",
"token",
")",
",",
"0666",
")",
";",
"err",
"... | // writeToken writes the given token to disk | [
"writeToken",
"writes",
"the",
"given",
"token",
"to",
"disk"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/vault_hook.go#L340-L346 |
132,122 | hashicorp/nomad | client/allocrunner/taskrunner/vault_hook.go | Wait | func (f *tokenFuture) Wait() <-chan struct{} {
f.m.Lock()
defer f.m.Unlock()
c := make(chan struct{})
if f.set {
close(c)
return c
}
f.waiting = append(f.waiting, c)
return c
} | go | func (f *tokenFuture) Wait() <-chan struct{} {
f.m.Lock()
defer f.m.Unlock()
c := make(chan struct{})
if f.set {
close(c)
return c
}
f.waiting = append(f.waiting, c)
return c
} | [
"func",
"(",
"f",
"*",
"tokenFuture",
")",
"Wait",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"f",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
":=",
"make",
"(",
"chan",
"struct",... | // Wait returns a channel that can be waited on. When this channel unblocks, a
// valid token will be available via the Get method | [
"Wait",
"returns",
"a",
"channel",
"that",
"can",
"be",
"waited",
"on",
".",
"When",
"this",
"channel",
"unblocks",
"a",
"valid",
"token",
"will",
"be",
"available",
"via",
"the",
"Get",
"method"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/vault_hook.go#L364-L376 |
132,123 | hashicorp/nomad | client/allocrunner/taskrunner/vault_hook.go | Set | func (f *tokenFuture) Set(token string) *tokenFuture {
f.m.Lock()
defer f.m.Unlock()
f.set = true
f.token = token
for _, w := range f.waiting {
close(w)
}
f.waiting = nil
return f
} | go | func (f *tokenFuture) Set(token string) *tokenFuture {
f.m.Lock()
defer f.m.Unlock()
f.set = true
f.token = token
for _, w := range f.waiting {
close(w)
}
f.waiting = nil
return f
} | [
"func",
"(",
"f",
"*",
"tokenFuture",
")",
"Set",
"(",
"token",
"string",
")",
"*",
"tokenFuture",
"{",
"f",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"f",
".",
"set",
"=",
"true",
"\n",
"... | // Set sets the token value and unblocks any caller of Wait | [
"Set",
"sets",
"the",
"token",
"value",
"and",
"unblocks",
"any",
"caller",
"of",
"Wait"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/vault_hook.go#L379-L390 |
132,124 | hashicorp/nomad | client/allocrunner/taskrunner/vault_hook.go | Clear | func (f *tokenFuture) Clear() *tokenFuture {
f.m.Lock()
defer f.m.Unlock()
f.token = ""
f.set = false
return f
} | go | func (f *tokenFuture) Clear() *tokenFuture {
f.m.Lock()
defer f.m.Unlock()
f.token = ""
f.set = false
return f
} | [
"func",
"(",
"f",
"*",
"tokenFuture",
")",
"Clear",
"(",
")",
"*",
"tokenFuture",
"{",
"f",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"f",
".",
"token",
"=",
"\"",
"\"",
"\n",
"f",
".",
... | // Clear clears the set vault token. | [
"Clear",
"clears",
"the",
"set",
"vault",
"token",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/vault_hook.go#L393-L400 |
132,125 | hashicorp/nomad | client/allocrunner/taskrunner/vault_hook.go | Get | func (f *tokenFuture) Get() string {
f.m.Lock()
defer f.m.Unlock()
return f.token
} | go | func (f *tokenFuture) Get() string {
f.m.Lock()
defer f.m.Unlock()
return f.token
} | [
"func",
"(",
"f",
"*",
"tokenFuture",
")",
"Get",
"(",
")",
"string",
"{",
"f",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"f",
".",
"token",
"\n",
"}"
] | // Get returns the set Vault token | [
"Get",
"returns",
"the",
"set",
"Vault",
"token"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/vault_hook.go#L403-L407 |
132,126 | hashicorp/nomad | plugins/device/plugin.go | Serve | func Serve(dev DevicePlugin, logger log.Logger) {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
base.PluginTypeBase: &base.PluginBase{Impl: dev},
base.PluginTypeDevice: &PluginDevice{Impl: dev},
},
GRPCServer: plugin.DefaultGRPCServer,
Logger: ... | go | func Serve(dev DevicePlugin, logger log.Logger) {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
base.PluginTypeBase: &base.PluginBase{Impl: dev},
base.PluginTypeDevice: &PluginDevice{Impl: dev},
},
GRPCServer: plugin.DefaultGRPCServer,
Logger: ... | [
"func",
"Serve",
"(",
"dev",
"DevicePlugin",
",",
"logger",
"log",
".",
"Logger",
")",
"{",
"plugin",
".",
"Serve",
"(",
"&",
"plugin",
".",
"ServeConfig",
"{",
"HandshakeConfig",
":",
"base",
".",
"Handshake",
",",
"Plugins",
":",
"map",
"[",
"string",
... | // Serve is used to serve a device plugin | [
"Serve",
"is",
"used",
"to",
"serve",
"a",
"device",
"plugin"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/plugin.go#L41-L51 |
132,127 | hashicorp/nomad | api/fs.go | IsHeartbeat | func (s *StreamFrame) IsHeartbeat() bool {
return len(s.Data) == 0 && s.FileEvent == "" && s.File == "" && s.Offset == 0
} | go | func (s *StreamFrame) IsHeartbeat() bool {
return len(s.Data) == 0 && s.FileEvent == "" && s.File == "" && s.Offset == 0
} | [
"func",
"(",
"s",
"*",
"StreamFrame",
")",
"IsHeartbeat",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"s",
".",
"Data",
")",
"==",
"0",
"&&",
"s",
".",
"FileEvent",
"==",
"\"",
"\"",
"&&",
"s",
".",
"File",
"==",
"\"",
"\"",
"&&",
"s",
".",
... | // IsHeartbeat returns if the frame is a heartbeat frame | [
"IsHeartbeat",
"returns",
"if",
"the",
"frame",
"is",
"a",
"heartbeat",
"frame"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/fs.go#L39-L41 |
132,128 | hashicorp/nomad | api/fs.go | Stat | func (a *AllocFS) Stat(alloc *Allocation, path string, q *QueryOptions) (*AllocFileInfo, *QueryMeta, error) {
if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}
q.Params["path"] = path
var resp AllocFileInfo
qm, err := a.client.query(fmt.Sprintf("/v1/client/fs/sta... | go | func (a *AllocFS) Stat(alloc *Allocation, path string, q *QueryOptions) (*AllocFileInfo, *QueryMeta, error) {
if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}
q.Params["path"] = path
var resp AllocFileInfo
qm, err := a.client.query(fmt.Sprintf("/v1/client/fs/sta... | [
"func",
"(",
"a",
"*",
"AllocFS",
")",
"Stat",
"(",
"alloc",
"*",
"Allocation",
",",
"path",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"AllocFileInfo",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"if",
"q",
"==",
"nil",
"{",
"q",
... | // Stat is used to stat a file at a given path of an allocation directory | [
"Stat",
"is",
"used",
"to",
"stat",
"a",
"file",
"at",
"a",
"given",
"path",
"of",
"an",
"allocation",
"directory"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/fs.go#L73-L89 |
132,129 | hashicorp/nomad | api/fs.go | ReadAt | func (a *AllocFS) ReadAt(alloc *Allocation, path string, offset int64, limit int64, q *QueryOptions) (io.ReadCloser, error) {
nodeClient, err := a.client.GetNodeClientWithTimeout(alloc.NodeID, ClientConnTimeout, q)
if err != nil {
return nil, err
}
if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q... | go | func (a *AllocFS) ReadAt(alloc *Allocation, path string, offset int64, limit int64, q *QueryOptions) (io.ReadCloser, error) {
nodeClient, err := a.client.GetNodeClientWithTimeout(alloc.NodeID, ClientConnTimeout, q)
if err != nil {
return nil, err
}
if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q... | [
"func",
"(",
"a",
"*",
"AllocFS",
")",
"ReadAt",
"(",
"alloc",
"*",
"Allocation",
",",
"path",
"string",
",",
"offset",
"int64",
",",
"limit",
"int64",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"nodeCli... | // ReadAt is used to read bytes at a given offset until limit at the given path
// in an allocation directory. If limit is <= 0, there is no limit. | [
"ReadAt",
"is",
"used",
"to",
"read",
"bytes",
"at",
"a",
"given",
"offset",
"until",
"limit",
"at",
"the",
"given",
"path",
"in",
"an",
"allocation",
"directory",
".",
"If",
"limit",
"is",
"<",
"=",
"0",
"there",
"is",
"no",
"limit",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/fs.go#L93-L126 |
132,130 | hashicorp/nomad | api/fs.go | NewFrameReader | func NewFrameReader(frames <-chan *StreamFrame, errCh <-chan error, cancelCh chan struct{}) *FrameReader {
return &FrameReader{
frames: frames,
errCh: errCh,
cancelCh: cancelCh,
}
} | go | func NewFrameReader(frames <-chan *StreamFrame, errCh <-chan error, cancelCh chan struct{}) *FrameReader {
return &FrameReader{
frames: frames,
errCh: errCh,
cancelCh: cancelCh,
}
} | [
"func",
"NewFrameReader",
"(",
"frames",
"<-",
"chan",
"*",
"StreamFrame",
",",
"errCh",
"<-",
"chan",
"error",
",",
"cancelCh",
"chan",
"struct",
"{",
"}",
")",
"*",
"FrameReader",
"{",
"return",
"&",
"FrameReader",
"{",
"frames",
":",
"frames",
",",
"e... | // NewFrameReader takes a channel of frames and returns a FrameReader which
// implements io.ReadCloser | [
"NewFrameReader",
"takes",
"a",
"channel",
"of",
"frames",
"and",
"returns",
"a",
"FrameReader",
"which",
"implements",
"io",
".",
"ReadCloser"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/fs.go#L362-L368 |
132,131 | hashicorp/nomad | api/fs.go | Read | func (f *FrameReader) Read(p []byte) (n int, err error) {
f.closedLock.Lock()
closed := f.closed
f.closedLock.Unlock()
if closed {
return 0, io.EOF
}
if f.frame == nil {
var unblock <-chan time.Time
if f.unblockTime.Nanoseconds() > 0 {
unblock = time.After(f.unblockTime)
}
select {
case frame, ok... | go | func (f *FrameReader) Read(p []byte) (n int, err error) {
f.closedLock.Lock()
closed := f.closed
f.closedLock.Unlock()
if closed {
return 0, io.EOF
}
if f.frame == nil {
var unblock <-chan time.Time
if f.unblockTime.Nanoseconds() > 0 {
unblock = time.After(f.unblockTime)
}
select {
case frame, ok... | [
"func",
"(",
"f",
"*",
"FrameReader",
")",
"Read",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"f",
".",
"closedLock",
".",
"Lock",
"(",
")",
"\n",
"closed",
":=",
"f",
".",
"closed",
"\n",
"f",
".",
"clos... | // Read reads the data of the incoming frames into the bytes buffer. Returns EOF
// when there are no more frames. | [
"Read",
"reads",
"the",
"data",
"of",
"the",
"incoming",
"frames",
"into",
"the",
"bytes",
"buffer",
".",
"Returns",
"EOF",
"when",
"there",
"are",
"no",
"more",
"frames",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/fs.go#L383-L426 |
132,132 | hashicorp/nomad | api/fs.go | Close | func (f *FrameReader) Close() error {
f.closedLock.Lock()
defer f.closedLock.Unlock()
if f.closed {
return nil
}
close(f.cancelCh)
f.closed = true
return nil
} | go | func (f *FrameReader) Close() error {
f.closedLock.Lock()
defer f.closedLock.Unlock()
if f.closed {
return nil
}
close(f.cancelCh)
f.closed = true
return nil
} | [
"func",
"(",
"f",
"*",
"FrameReader",
")",
"Close",
"(",
")",
"error",
"{",
"f",
".",
"closedLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"closedLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"f",
".",
"closed",
"{",
"return",
"nil",
"\n",... | // Close cancels the stream of frames | [
"Close",
"cancels",
"the",
"stream",
"of",
"frames"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/fs.go#L429-L439 |
132,133 | hashicorp/nomad | command/helpers.go | formatKV | func formatKV(in []string) string {
columnConf := columnize.DefaultConfig()
columnConf.Empty = "<none>"
columnConf.Glue = " = "
return columnize.Format(in, columnConf)
} | go | func formatKV(in []string) string {
columnConf := columnize.DefaultConfig()
columnConf.Empty = "<none>"
columnConf.Glue = " = "
return columnize.Format(in, columnConf)
} | [
"func",
"formatKV",
"(",
"in",
"[",
"]",
"string",
")",
"string",
"{",
"columnConf",
":=",
"columnize",
".",
"DefaultConfig",
"(",
")",
"\n",
"columnConf",
".",
"Empty",
"=",
"\"",
"\"",
"\n",
"columnConf",
".",
"Glue",
"=",
"\"",
"\"",
"\n",
"return",... | // formatKV takes a set of strings and formats them into properly
// aligned k = v pairs using the columnize library. | [
"formatKV",
"takes",
"a",
"set",
"of",
"strings",
"and",
"formats",
"them",
"into",
"properly",
"aligned",
"k",
"=",
"v",
"pairs",
"using",
"the",
"columnize",
"library",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L27-L32 |
132,134 | hashicorp/nomad | command/helpers.go | formatList | func formatList(in []string) string {
columnConf := columnize.DefaultConfig()
columnConf.Empty = "<none>"
return columnize.Format(in, columnConf)
} | go | func formatList(in []string) string {
columnConf := columnize.DefaultConfig()
columnConf.Empty = "<none>"
return columnize.Format(in, columnConf)
} | [
"func",
"formatList",
"(",
"in",
"[",
"]",
"string",
")",
"string",
"{",
"columnConf",
":=",
"columnize",
".",
"DefaultConfig",
"(",
")",
"\n",
"columnConf",
".",
"Empty",
"=",
"\"",
"\"",
"\n",
"return",
"columnize",
".",
"Format",
"(",
"in",
",",
"co... | // formatList takes a set of strings and formats them into properly
// aligned output, replacing any blank fields with a placeholder
// for awk-ability. | [
"formatList",
"takes",
"a",
"set",
"of",
"strings",
"and",
"formats",
"them",
"into",
"properly",
"aligned",
"output",
"replacing",
"any",
"blank",
"fields",
"with",
"a",
"placeholder",
"for",
"awk",
"-",
"ability",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L37-L41 |
132,135 | hashicorp/nomad | command/helpers.go | limit | func limit(s string, length int) string {
if len(s) < length {
return s
}
return s[:length]
} | go | func limit(s string, length int) string {
if len(s) < length {
return s
}
return s[:length]
} | [
"func",
"limit",
"(",
"s",
"string",
",",
"length",
"int",
")",
"string",
"{",
"if",
"len",
"(",
"s",
")",
"<",
"length",
"{",
"return",
"s",
"\n",
"}",
"\n\n",
"return",
"s",
"[",
":",
"length",
"]",
"\n",
"}"
] | // Limits the length of the string. | [
"Limits",
"the",
"length",
"of",
"the",
"string",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L52-L58 |
132,136 | hashicorp/nomad | command/helpers.go | formatUnixNanoTime | func formatUnixNanoTime(nano int64) string {
t := time.Unix(0, nano)
return formatTime(t)
} | go | func formatUnixNanoTime(nano int64) string {
t := time.Unix(0, nano)
return formatTime(t)
} | [
"func",
"formatUnixNanoTime",
"(",
"nano",
"int64",
")",
"string",
"{",
"t",
":=",
"time",
".",
"Unix",
"(",
"0",
",",
"nano",
")",
"\n",
"return",
"formatTime",
"(",
"t",
")",
"\n",
"}"
] | // formatUnixNanoTime is a helper for formatting time for output. | [
"formatUnixNanoTime",
"is",
"a",
"helper",
"for",
"formatting",
"time",
"for",
"output",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L87-L90 |
132,137 | hashicorp/nomad | command/helpers.go | getLocalNodeID | func getLocalNodeID(client *api.Client) (string, error) {
info, err := client.Agent().Self()
if err != nil {
return "", fmt.Errorf("Error querying agent info: %s", err)
}
clientStats, ok := info.Stats["client"]
if !ok {
return "", fmt.Errorf("Nomad not running in client mode")
}
nodeID, ok := clientStats["n... | go | func getLocalNodeID(client *api.Client) (string, error) {
info, err := client.Agent().Self()
if err != nil {
return "", fmt.Errorf("Error querying agent info: %s", err)
}
clientStats, ok := info.Stats["client"]
if !ok {
return "", fmt.Errorf("Nomad not running in client mode")
}
nodeID, ok := clientStats["n... | [
"func",
"getLocalNodeID",
"(",
"client",
"*",
"api",
".",
"Client",
")",
"(",
"string",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"client",
".",
"Agent",
"(",
")",
".",
"Self",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\""... | // getLocalNodeID returns the node ID of the local Nomad Client and an error if
// it couldn't be determined or the Agent is not running in Client mode. | [
"getLocalNodeID",
"returns",
"the",
"node",
"ID",
"of",
"the",
"local",
"Nomad",
"Client",
"and",
"an",
"error",
"if",
"it",
"couldn",
"t",
"be",
"determined",
"or",
"the",
"Agent",
"is",
"not",
"running",
"in",
"Client",
"mode",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L223-L239 |
132,138 | hashicorp/nomad | command/helpers.go | evalFailureStatus | func evalFailureStatus(eval *api.Evaluation) (string, bool) {
if eval == nil {
return "", false
}
hasFailures := len(eval.FailedTGAllocs) != 0
text := strconv.FormatBool(hasFailures)
if eval.Status == "blocked" {
text = "N/A - In Progress"
}
return text, hasFailures
} | go | func evalFailureStatus(eval *api.Evaluation) (string, bool) {
if eval == nil {
return "", false
}
hasFailures := len(eval.FailedTGAllocs) != 0
text := strconv.FormatBool(hasFailures)
if eval.Status == "blocked" {
text = "N/A - In Progress"
}
return text, hasFailures
} | [
"func",
"evalFailureStatus",
"(",
"eval",
"*",
"api",
".",
"Evaluation",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"eval",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n\n",
"hasFailures",
":=",
"len",
"(",
"eval",
".",
... | // evalFailureStatus returns whether the evaluation has failures and a string to
// display when presenting users with whether there are failures for the eval | [
"evalFailureStatus",
"returns",
"whether",
"the",
"evaluation",
"has",
"failures",
"and",
"a",
"string",
"to",
"display",
"when",
"presenting",
"users",
"with",
"whether",
"there",
"are",
"failures",
"for",
"the",
"eval"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L243-L255 |
132,139 | hashicorp/nomad | command/helpers.go | NewLineLimitReader | func NewLineLimitReader(r io.ReadCloser, lines, searchLimit int, timeLimit time.Duration) *LineLimitReader {
return &LineLimitReader{
ReadCloser: r,
searchLimit: searchLimit,
timeLimit: timeLimit,
lines: lines,
buffer: bytes.NewBuffer(make([]byte, 0, searchLimit)),
}
} | go | func NewLineLimitReader(r io.ReadCloser, lines, searchLimit int, timeLimit time.Duration) *LineLimitReader {
return &LineLimitReader{
ReadCloser: r,
searchLimit: searchLimit,
timeLimit: timeLimit,
lines: lines,
buffer: bytes.NewBuffer(make([]byte, 0, searchLimit)),
}
} | [
"func",
"NewLineLimitReader",
"(",
"r",
"io",
".",
"ReadCloser",
",",
"lines",
",",
"searchLimit",
"int",
",",
"timeLimit",
"time",
".",
"Duration",
")",
"*",
"LineLimitReader",
"{",
"return",
"&",
"LineLimitReader",
"{",
"ReadCloser",
":",
"r",
",",
"search... | // NewLineLimitReader takes the ReadCloser to wrap, the number of lines to find
// searching backwards in the first searchLimit bytes. timeLimit can optionally
// be specified by passing a non-zero duration. When set, the search for the
// last n lines is aborted if no data has been read in the duration. This
// can be... | [
"NewLineLimitReader",
"takes",
"the",
"ReadCloser",
"to",
"wrap",
"the",
"number",
"of",
"lines",
"to",
"find",
"searching",
"backwards",
"in",
"the",
"first",
"searchLimit",
"bytes",
".",
"timeLimit",
"can",
"optionally",
"be",
"specified",
"by",
"passing",
"a"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L281-L289 |
132,140 | hashicorp/nomad | command/helpers.go | ApiJob | func (j *JobGetter) ApiJob(jpath string) (*api.Job, error) {
var jobfile io.Reader
switch jpath {
case "-":
if j.testStdin != nil {
jobfile = j.testStdin
} else {
jobfile = os.Stdin
}
default:
if len(jpath) == 0 {
return nil, fmt.Errorf("Error jobfile path has to be specified.")
}
job, err := ... | go | func (j *JobGetter) ApiJob(jpath string) (*api.Job, error) {
var jobfile io.Reader
switch jpath {
case "-":
if j.testStdin != nil {
jobfile = j.testStdin
} else {
jobfile = os.Stdin
}
default:
if len(jpath) == 0 {
return nil, fmt.Errorf("Error jobfile path has to be specified.")
}
job, err := ... | [
"func",
"(",
"j",
"*",
"JobGetter",
")",
"ApiJob",
"(",
"jpath",
"string",
")",
"(",
"*",
"api",
".",
"Job",
",",
"error",
")",
"{",
"var",
"jobfile",
"io",
".",
"Reader",
"\n",
"switch",
"jpath",
"{",
"case",
"\"",
"\"",
":",
"if",
"j",
".",
"... | // StructJob returns the Job struct from jobfile. | [
"StructJob",
"returns",
"the",
"Job",
"struct",
"from",
"jobfile",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L384-L439 |
132,141 | hashicorp/nomad | command/helpers.go | mergeAutocompleteFlags | func mergeAutocompleteFlags(flags ...complete.Flags) complete.Flags {
merged := make(map[string]complete.Predictor, len(flags))
for _, f := range flags {
for k, v := range f {
merged[k] = v
}
}
return merged
} | go | func mergeAutocompleteFlags(flags ...complete.Flags) complete.Flags {
merged := make(map[string]complete.Predictor, len(flags))
for _, f := range flags {
for k, v := range f {
merged[k] = v
}
}
return merged
} | [
"func",
"mergeAutocompleteFlags",
"(",
"flags",
"...",
"complete",
".",
"Flags",
")",
"complete",
".",
"Flags",
"{",
"merged",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"complete",
".",
"Predictor",
",",
"len",
"(",
"flags",
")",
")",
"\n",
"for",
... | // mergeAutocompleteFlags is used to join multiple flag completion sets. | [
"mergeAutocompleteFlags",
"is",
"used",
"to",
"join",
"multiple",
"flag",
"completion",
"sets",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L468-L476 |
132,142 | hashicorp/nomad | command/helpers.go | sanitizeUUIDPrefix | func sanitizeUUIDPrefix(prefix string) string {
hyphens := strings.Count(prefix, "-")
length := len(prefix) - hyphens
remainder := length % 2
return prefix[:len(prefix)-remainder]
} | go | func sanitizeUUIDPrefix(prefix string) string {
hyphens := strings.Count(prefix, "-")
length := len(prefix) - hyphens
remainder := length % 2
return prefix[:len(prefix)-remainder]
} | [
"func",
"sanitizeUUIDPrefix",
"(",
"prefix",
"string",
")",
"string",
"{",
"hyphens",
":=",
"strings",
".",
"Count",
"(",
"prefix",
",",
"\"",
"\"",
")",
"\n",
"length",
":=",
"len",
"(",
"prefix",
")",
"-",
"hyphens",
"\n",
"remainder",
":=",
"length",
... | // sanitizeUUIDPrefix is used to sanitize a UUID prefix. The returned result
// will be a truncated version of the prefix if the prefix would not be
// queryable. | [
"sanitizeUUIDPrefix",
"is",
"used",
"to",
"sanitize",
"a",
"UUID",
"prefix",
".",
"The",
"returned",
"result",
"will",
"be",
"a",
"truncated",
"version",
"of",
"the",
"prefix",
"if",
"the",
"prefix",
"would",
"not",
"be",
"queryable",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/helpers.go#L481-L486 |
132,143 | hashicorp/nomad | command/agent/metrics_endpoint.go | MetricsRequest | func (s *HTTPServer) MetricsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method != "GET" {
return nil, CodedError(405, ErrInvalidMethod)
}
if format := req.URL.Query().Get("format"); format == "prometheus" {
s.prometheusHandler().ServeHTTP(resp, req)
return nil, nil
}
... | go | func (s *HTTPServer) MetricsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
if req.Method != "GET" {
return nil, CodedError(405, ErrInvalidMethod)
}
if format := req.URL.Query().Get("format"); format == "prometheus" {
s.prometheusHandler().ServeHTTP(resp, req)
return nil, nil
}
... | [
"func",
"(",
"s",
"*",
"HTTPServer",
")",
"MetricsRequest",
"(",
"resp",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"req",
".",
"Method",
"!=",
"\"",
"\"",
... | // MetricsRequest returns metrics for the agent. Metrics are JSON by default
// but Prometheus is an optional format. | [
"MetricsRequest",
"returns",
"metrics",
"for",
"the",
"agent",
".",
"Metrics",
"are",
"JSON",
"by",
"default",
"but",
"Prometheus",
"is",
"an",
"optional",
"format",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/metrics_endpoint.go#L19-L30 |
132,144 | hashicorp/nomad | nomad/serf.go | serfEventHandler | func (s *Server) serfEventHandler() {
for {
select {
case e := <-s.eventCh:
switch e.EventType() {
case serf.EventMemberJoin:
s.nodeJoin(e.(serf.MemberEvent))
s.localMemberEvent(e.(serf.MemberEvent))
case serf.EventMemberLeave, serf.EventMemberFailed:
s.nodeFailed(e.(serf.MemberEvent))
s.l... | go | func (s *Server) serfEventHandler() {
for {
select {
case e := <-s.eventCh:
switch e.EventType() {
case serf.EventMemberJoin:
s.nodeJoin(e.(serf.MemberEvent))
s.localMemberEvent(e.(serf.MemberEvent))
case serf.EventMemberLeave, serf.EventMemberFailed:
s.nodeFailed(e.(serf.MemberEvent))
s.l... | [
"func",
"(",
"s",
"*",
"Server",
")",
"serfEventHandler",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"e",
":=",
"<-",
"s",
".",
"eventCh",
":",
"switch",
"e",
".",
"EventType",
"(",
")",
"{",
"case",
"serf",
".",
"EventMemberJoin",
":",
"s",... | // serfEventHandler is used to handle events from the serf cluster | [
"serfEventHandler",
"is",
"used",
"to",
"handle",
"events",
"from",
"the",
"serf",
"cluster"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/serf.go#L28-L50 |
132,145 | hashicorp/nomad | nomad/serf.go | nodeFailed | func (s *Server) nodeFailed(me serf.MemberEvent) {
for _, m := range me.Members {
ok, parts := isNomadServer(m)
if !ok {
continue
}
s.logger.Info("removing server", "server", parts)
// Remove the server if known
s.peerLock.Lock()
existing := s.peers[parts.Region]
n := len(existing)
for i := 0; i ... | go | func (s *Server) nodeFailed(me serf.MemberEvent) {
for _, m := range me.Members {
ok, parts := isNomadServer(m)
if !ok {
continue
}
s.logger.Info("removing server", "server", parts)
// Remove the server if known
s.peerLock.Lock()
existing := s.peers[parts.Region]
n := len(existing)
for i := 0; i ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"nodeFailed",
"(",
"me",
"serf",
".",
"MemberEvent",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"me",
".",
"Members",
"{",
"ok",
",",
"parts",
":=",
"isNomadServer",
"(",
"m",
")",
"\n",
"if",
"!",
"ok",
... | // nodeFailed is used to handle fail events on the serf cluster | [
"nodeFailed",
"is",
"used",
"to",
"handle",
"fail",
"events",
"on",
"the",
"serf",
"cluster"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/serf.go#L230-L264 |
132,146 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | newDeploymentWatcher | func newDeploymentWatcher(parent context.Context, queryLimiter *rate.Limiter,
logger log.Logger, state *state.StateStore, d *structs.Deployment,
j *structs.Job, triggers deploymentTriggers) *deploymentWatcher {
ctx, exitFn := context.WithCancel(parent)
w := &deploymentWatcher{
queryLimiter: queryLimiter,
... | go | func newDeploymentWatcher(parent context.Context, queryLimiter *rate.Limiter,
logger log.Logger, state *state.StateStore, d *structs.Deployment,
j *structs.Job, triggers deploymentTriggers) *deploymentWatcher {
ctx, exitFn := context.WithCancel(parent)
w := &deploymentWatcher{
queryLimiter: queryLimiter,
... | [
"func",
"newDeploymentWatcher",
"(",
"parent",
"context",
".",
"Context",
",",
"queryLimiter",
"*",
"rate",
".",
"Limiter",
",",
"logger",
"log",
".",
"Logger",
",",
"state",
"*",
"state",
".",
"StateStore",
",",
"d",
"*",
"structs",
".",
"Deployment",
","... | // newDeploymentWatcher returns a deployment watcher that is used to watch
// deployments and trigger the scheduler as needed. | [
"newDeploymentWatcher",
"returns",
"a",
"deployment",
"watcher",
"that",
"is",
"used",
"to",
"watch",
"deployments",
"and",
"trigger",
"the",
"scheduler",
"as",
"needed",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L101-L123 |
132,147 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | updateDeployment | func (w *deploymentWatcher) updateDeployment(d *structs.Deployment) {
w.l.Lock()
defer w.l.Unlock()
// Update and trigger
w.d = d
select {
case w.deploymentUpdateCh <- struct{}{}:
default:
}
} | go | func (w *deploymentWatcher) updateDeployment(d *structs.Deployment) {
w.l.Lock()
defer w.l.Unlock()
// Update and trigger
w.d = d
select {
case w.deploymentUpdateCh <- struct{}{}:
default:
}
} | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"updateDeployment",
"(",
"d",
"*",
"structs",
".",
"Deployment",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\n\n",
"// Update and trigger",
... | // updateDeployment is used to update the tracked deployment. | [
"updateDeployment",
"is",
"used",
"to",
"update",
"the",
"tracked",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L126-L136 |
132,148 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | getDeployment | func (w *deploymentWatcher) getDeployment() *structs.Deployment {
w.l.RLock()
defer w.l.RUnlock()
return w.d
} | go | func (w *deploymentWatcher) getDeployment() *structs.Deployment {
w.l.RLock()
defer w.l.RUnlock()
return w.d
} | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"getDeployment",
"(",
")",
"*",
"structs",
".",
"Deployment",
"{",
"w",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"w",
".",
"d",
"\n"... | // getDeployment returns the tracked deployment. | [
"getDeployment",
"returns",
"the",
"tracked",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L139-L143 |
132,149 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | handleRollbackValidity | func (w *deploymentWatcher) handleRollbackValidity(rollbackJob *structs.Job, desc string) (*structs.Job, string) {
// Only rollback if job being changed has a different spec.
// This prevents an infinite revert cycle when a previously stable version of the job fails to start up during a rollback
// If the job we are... | go | func (w *deploymentWatcher) handleRollbackValidity(rollbackJob *structs.Job, desc string) (*structs.Job, string) {
// Only rollback if job being changed has a different spec.
// This prevents an infinite revert cycle when a previously stable version of the job fails to start up during a rollback
// If the job we are... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"handleRollbackValidity",
"(",
"rollbackJob",
"*",
"structs",
".",
"Job",
",",
"desc",
"string",
")",
"(",
"*",
"structs",
".",
"Job",
",",
"string",
")",
"{",
"// Only rollback if job being changed has a different ... | // handleRollbackValidity checks if the job being rolled back to has the same spec as the existing job
// Returns a modified description and job accordingly. | [
"handleRollbackValidity",
"checks",
"if",
"the",
"job",
"being",
"rolled",
"back",
"to",
"has",
"the",
"same",
"spec",
"as",
"the",
"existing",
"job",
"Returns",
"a",
"modified",
"description",
"and",
"job",
"accordingly",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L232-L243 |
132,150 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | handleAllocUpdate | func (w *deploymentWatcher) handleAllocUpdate(allocs []*structs.AllocListStub) (allocUpdateResult, error) {
var res allocUpdateResult
// Get the latest evaluation index
latestEval, err := w.jobEvalStatus()
if err != nil {
if err == context.Canceled || w.ctx.Err() == context.Canceled {
return res, err
}
r... | go | func (w *deploymentWatcher) handleAllocUpdate(allocs []*structs.AllocListStub) (allocUpdateResult, error) {
var res allocUpdateResult
// Get the latest evaluation index
latestEval, err := w.jobEvalStatus()
if err != nil {
if err == context.Canceled || w.ctx.Err() == context.Canceled {
return res, err
}
r... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"handleAllocUpdate",
"(",
"allocs",
"[",
"]",
"*",
"structs",
".",
"AllocListStub",
")",
"(",
"allocUpdateResult",
",",
"error",
")",
"{",
"var",
"res",
"allocUpdateResult",
"\n\n",
"// Get the latest evaluation ind... | // handleAllocUpdate is used to compute the set of actions to take based on the
// updated allocations for the deployment. | [
"handleAllocUpdate",
"is",
"used",
"to",
"compute",
"the",
"set",
"of",
"actions",
"to",
"take",
"based",
"on",
"the",
"updated",
"allocations",
"for",
"the",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L513-L572 |
132,151 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | shouldFail | func (w *deploymentWatcher) shouldFail() (fail, rollback bool, err error) {
snap, err := w.state.Snapshot()
if err != nil {
return false, false, err
}
d, err := snap.DeploymentByID(nil, w.deploymentID)
if err != nil {
return false, false, err
}
if d == nil {
// The deployment wasn't in the state store, po... | go | func (w *deploymentWatcher) shouldFail() (fail, rollback bool, err error) {
snap, err := w.state.Snapshot()
if err != nil {
return false, false, err
}
d, err := snap.DeploymentByID(nil, w.deploymentID)
if err != nil {
return false, false, err
}
if d == nil {
// The deployment wasn't in the state store, po... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"shouldFail",
"(",
")",
"(",
"fail",
",",
"rollback",
"bool",
",",
"err",
"error",
")",
"{",
"snap",
",",
"err",
":=",
"w",
".",
"state",
".",
"Snapshot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // shouldFail returns whether the job should be failed and whether it should
// rolled back to an earlier stable version by examining the allocations in the
// deployment. | [
"shouldFail",
"returns",
"whether",
"the",
"job",
"should",
"be",
"failed",
"and",
"whether",
"it",
"should",
"rolled",
"back",
"to",
"an",
"earlier",
"stable",
"version",
"by",
"examining",
"the",
"allocations",
"in",
"the",
"deployment",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L577-L618 |
132,152 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | getDeploymentProgressCutoff | func (w *deploymentWatcher) getDeploymentProgressCutoff(d *structs.Deployment) time.Time {
var next time.Time
doneTGs := w.doneGroups(d)
for name, state := range d.TaskGroups {
// This task group is done so we don't have to concern ourselves with
// its progress deadline.
if done, ok := doneTGs[name]; ok && do... | go | func (w *deploymentWatcher) getDeploymentProgressCutoff(d *structs.Deployment) time.Time {
var next time.Time
doneTGs := w.doneGroups(d)
for name, state := range d.TaskGroups {
// This task group is done so we don't have to concern ourselves with
// its progress deadline.
if done, ok := doneTGs[name]; ok && do... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"getDeploymentProgressCutoff",
"(",
"d",
"*",
"structs",
".",
"Deployment",
")",
"time",
".",
"Time",
"{",
"var",
"next",
"time",
".",
"Time",
"\n",
"doneTGs",
":=",
"w",
".",
"doneGroups",
"(",
"d",
")",
... | // getDeploymentProgressCutoff returns the progress cutoff for the given
// deployment | [
"getDeploymentProgressCutoff",
"returns",
"the",
"progress",
"cutoff",
"for",
"the",
"given",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L622-L641 |
132,153 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | doneGroups | func (w *deploymentWatcher) doneGroups(d *structs.Deployment) map[string]bool {
if d == nil {
return nil
}
// Collect the allocations by the task group
snap, err := w.state.Snapshot()
if err != nil {
return nil
}
allocs, err := snap.AllocsByDeployment(nil, d.ID)
if err != nil {
return nil
}
// Go thr... | go | func (w *deploymentWatcher) doneGroups(d *structs.Deployment) map[string]bool {
if d == nil {
return nil
}
// Collect the allocations by the task group
snap, err := w.state.Snapshot()
if err != nil {
return nil
}
allocs, err := snap.AllocsByDeployment(nil, d.ID)
if err != nil {
return nil
}
// Go thr... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"doneGroups",
"(",
"d",
"*",
"structs",
".",
"Deployment",
")",
"map",
"[",
"string",
"]",
"bool",
"{",
"if",
"d",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Collect the allocations by the tas... | // doneGroups returns a map of task group to whether the deployment appears to
// be done for the group. A true value doesn't mean no more action will be taken
// in the life time of the deployment because there could always be node
// failures, or rescheduling events. | [
"doneGroups",
"returns",
"a",
"map",
"of",
"task",
"group",
"to",
"whether",
"the",
"deployment",
"appears",
"to",
"be",
"done",
"for",
"the",
"group",
".",
"A",
"true",
"value",
"doesn",
"t",
"mean",
"no",
"more",
"action",
"will",
"be",
"taken",
"in",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L647-L686 |
132,154 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | createBatchedUpdate | func (w *deploymentWatcher) createBatchedUpdate(allowReplacements []string, forIndex uint64) {
w.l.Lock()
defer w.l.Unlock()
// Store the allocations that can be replaced
for _, allocID := range allowReplacements {
if w.outstandingAllowReplacements == nil {
w.outstandingAllowReplacements = make(map[string]*st... | go | func (w *deploymentWatcher) createBatchedUpdate(allowReplacements []string, forIndex uint64) {
w.l.Lock()
defer w.l.Unlock()
// Store the allocations that can be replaced
for _, allocID := range allowReplacements {
if w.outstandingAllowReplacements == nil {
w.outstandingAllowReplacements = make(map[string]*st... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"createBatchedUpdate",
"(",
"allowReplacements",
"[",
"]",
"string",
",",
"forIndex",
"uint64",
")",
"{",
"w",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"l",
".",
"Unlock",
"(",
")",
"\... | // createBatchedUpdate creates an eval for the given index as well as updating
// the given allocations to allow them to reschedule. | [
"createBatchedUpdate",
"creates",
"an",
"eval",
"for",
"the",
"given",
"index",
"as",
"well",
"as",
"updating",
"the",
"given",
"allocations",
"to",
"allow",
"them",
"to",
"reschedule",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L713-L751 |
132,155 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | getEval | func (w *deploymentWatcher) getEval() *structs.Evaluation {
return &structs.Evaluation{
ID: uuid.Generate(),
Namespace: w.j.Namespace,
Priority: w.j.Priority,
Type: w.j.Type,
TriggeredBy: structs.EvalTriggerDeploymentWatcher,
JobID: w.j.ID,
DeploymentID: w.deploymentID,
... | go | func (w *deploymentWatcher) getEval() *structs.Evaluation {
return &structs.Evaluation{
ID: uuid.Generate(),
Namespace: w.j.Namespace,
Priority: w.j.Priority,
Type: w.j.Type,
TriggeredBy: structs.EvalTriggerDeploymentWatcher,
JobID: w.j.ID,
DeploymentID: w.deploymentID,
... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"getEval",
"(",
")",
"*",
"structs",
".",
"Evaluation",
"{",
"return",
"&",
"structs",
".",
"Evaluation",
"{",
"ID",
":",
"uuid",
".",
"Generate",
"(",
")",
",",
"Namespace",
":",
"w",
".",
"j",
".",
... | // getEval returns an evaluation suitable for the deployment | [
"getEval",
"returns",
"an",
"evaluation",
"suitable",
"for",
"the",
"deployment"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L754-L765 |
132,156 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | getDeploymentStatusUpdate | func (w *deploymentWatcher) getDeploymentStatusUpdate(status, desc string) *structs.DeploymentStatusUpdate {
return &structs.DeploymentStatusUpdate{
DeploymentID: w.deploymentID,
Status: status,
StatusDescription: desc,
}
} | go | func (w *deploymentWatcher) getDeploymentStatusUpdate(status, desc string) *structs.DeploymentStatusUpdate {
return &structs.DeploymentStatusUpdate{
DeploymentID: w.deploymentID,
Status: status,
StatusDescription: desc,
}
} | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"getDeploymentStatusUpdate",
"(",
"status",
",",
"desc",
"string",
")",
"*",
"structs",
".",
"DeploymentStatusUpdate",
"{",
"return",
"&",
"structs",
".",
"DeploymentStatusUpdate",
"{",
"DeploymentID",
":",
"w",
"... | // getDeploymentStatusUpdate returns a deployment status update | [
"getDeploymentStatusUpdate",
"returns",
"a",
"deployment",
"status",
"update"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L768-L774 |
132,157 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | getAllocsCh | func (w *deploymentWatcher) getAllocsCh(index uint64) <-chan *allocUpdates {
out := make(chan *allocUpdates, 1)
go func() {
allocs, index, err := w.getAllocs(index)
out <- &allocUpdates{
allocs: allocs,
index: index,
err: err,
}
}()
return out
} | go | func (w *deploymentWatcher) getAllocsCh(index uint64) <-chan *allocUpdates {
out := make(chan *allocUpdates, 1)
go func() {
allocs, index, err := w.getAllocs(index)
out <- &allocUpdates{
allocs: allocs,
index: index,
err: err,
}
}()
return out
} | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"getAllocsCh",
"(",
"index",
"uint64",
")",
"<-",
"chan",
"*",
"allocUpdates",
"{",
"out",
":=",
"make",
"(",
"chan",
"*",
"allocUpdates",
",",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"allocs",
",... | // getAllocsCh retrieves the allocations that are part of the deployment blocking
// at the given index. | [
"getAllocsCh",
"retrieves",
"the",
"allocations",
"that",
"are",
"part",
"of",
"the",
"deployment",
"blocking",
"at",
"the",
"given",
"index",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L784-L796 |
132,158 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | getAllocs | func (w *deploymentWatcher) getAllocs(index uint64) ([]*structs.AllocListStub, uint64, error) {
resp, index, err := w.state.BlockingQuery(w.getAllocsImpl, index, w.ctx)
if err != nil {
return nil, 0, err
}
if err := w.ctx.Err(); err != nil {
return nil, 0, err
}
return resp.([]*structs.AllocListStub), index,... | go | func (w *deploymentWatcher) getAllocs(index uint64) ([]*structs.AllocListStub, uint64, error) {
resp, index, err := w.state.BlockingQuery(w.getAllocsImpl, index, w.ctx)
if err != nil {
return nil, 0, err
}
if err := w.ctx.Err(); err != nil {
return nil, 0, err
}
return resp.([]*structs.AllocListStub), index,... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"getAllocs",
"(",
"index",
"uint64",
")",
"(",
"[",
"]",
"*",
"structs",
".",
"AllocListStub",
",",
"uint64",
",",
"error",
")",
"{",
"resp",
",",
"index",
",",
"err",
":=",
"w",
".",
"state",
".",
"... | // getAllocs retrieves the allocations that are part of the deployment blocking
// at the given index. | [
"getAllocs",
"retrieves",
"the",
"allocations",
"that",
"are",
"part",
"of",
"the",
"deployment",
"blocking",
"at",
"the",
"given",
"index",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L800-L810 |
132,159 | hashicorp/nomad | nomad/deploymentwatcher/deployment_watcher.go | jobEvalStatus | func (w *deploymentWatcher) jobEvalStatus() (latestIndex uint64, err error) {
if err := w.queryLimiter.Wait(w.ctx); err != nil {
return 0, err
}
snap, err := w.state.Snapshot()
if err != nil {
return 0, err
}
evals, err := snap.EvalsByJob(nil, w.j.Namespace, w.j.ID)
if err != nil {
return 0, err
}
// ... | go | func (w *deploymentWatcher) jobEvalStatus() (latestIndex uint64, err error) {
if err := w.queryLimiter.Wait(w.ctx); err != nil {
return 0, err
}
snap, err := w.state.Snapshot()
if err != nil {
return 0, err
}
evals, err := snap.EvalsByJob(nil, w.j.Namespace, w.j.ID)
if err != nil {
return 0, err
}
// ... | [
"func",
"(",
"w",
"*",
"deploymentWatcher",
")",
"jobEvalStatus",
"(",
")",
"(",
"latestIndex",
"uint64",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"w",
".",
"queryLimiter",
".",
"Wait",
"(",
"w",
".",
"ctx",
")",
";",
"err",
"!=",
"nil",
"... | // jobEvalStatus returns the latest eval index for a job. The index is used to
// determine if an allocation update requires an evaluation to be triggered. | [
"jobEvalStatus",
"returns",
"the",
"latest",
"eval",
"index",
"for",
"a",
"job",
".",
"The",
"index",
"is",
"used",
"to",
"determine",
"if",
"an",
"allocation",
"update",
"requires",
"an",
"evaluation",
"to",
"be",
"triggered",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/deployment_watcher.go#L848-L886 |
132,160 | hashicorp/nomad | helper/funcs.go | IsUUID | func IsUUID(str string) bool {
const uuidLen = 36
if len(str) != uuidLen {
return false
}
return validUUID.MatchString(str)
} | go | func IsUUID(str string) bool {
const uuidLen = 36
if len(str) != uuidLen {
return false
}
return validUUID.MatchString(str)
} | [
"func",
"IsUUID",
"(",
"str",
"string",
")",
"bool",
"{",
"const",
"uuidLen",
"=",
"36",
"\n",
"if",
"len",
"(",
"str",
")",
"!=",
"uuidLen",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"validUUID",
".",
"MatchString",
"(",
"str",
")",
"\n",... | // IsUUID returns true if the given string is a valid UUID. | [
"IsUUID",
"returns",
"true",
"if",
"the",
"given",
"string",
"is",
"a",
"valid",
"UUID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L22-L29 |
132,161 | hashicorp/nomad | helper/funcs.go | HashUUID | func HashUUID(input string) (output string, hashed bool) {
if !IsUUID(input) {
return "", false
}
// Hash the input
buf := sha512.Sum512([]byte(input))
output = fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
buf[0:4],
buf[4:6],
buf[6:8],
buf[8:10],
buf[10:16])
return output, true
} | go | func HashUUID(input string) (output string, hashed bool) {
if !IsUUID(input) {
return "", false
}
// Hash the input
buf := sha512.Sum512([]byte(input))
output = fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
buf[0:4],
buf[4:6],
buf[6:8],
buf[8:10],
buf[10:16])
return output, true
} | [
"func",
"HashUUID",
"(",
"input",
"string",
")",
"(",
"output",
"string",
",",
"hashed",
"bool",
")",
"{",
"if",
"!",
"IsUUID",
"(",
"input",
")",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n\n",
"// Hash the input",
"buf",
":=",
"sha512",
... | // HashUUID takes an input UUID and returns a hashed version of the UUID to
// ensure it is well distributed. | [
"HashUUID",
"takes",
"an",
"input",
"UUID",
"and",
"returns",
"a",
"hashed",
"version",
"of",
"the",
"UUID",
"to",
"ensure",
"it",
"is",
"well",
"distributed",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L41-L56 |
132,162 | hashicorp/nomad | helper/funcs.go | SliceStringIsSubset | func SliceStringIsSubset(larger, smaller []string) (bool, []string) {
largerSet := make(map[string]struct{}, len(larger))
for _, l := range larger {
largerSet[l] = struct{}{}
}
subset := true
var offending []string
for _, s := range smaller {
if _, ok := largerSet[s]; !ok {
subset = false
offending = a... | go | func SliceStringIsSubset(larger, smaller []string) (bool, []string) {
largerSet := make(map[string]struct{}, len(larger))
for _, l := range larger {
largerSet[l] = struct{}{}
}
subset := true
var offending []string
for _, s := range smaller {
if _, ok := largerSet[s]; !ok {
subset = false
offending = a... | [
"func",
"SliceStringIsSubset",
"(",
"larger",
",",
"smaller",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"[",
"]",
"string",
")",
"{",
"largerSet",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"larger",
")",
")... | // SliceStringIsSubset returns whether the smaller set of strings is a subset of
// the larger. If the smaller slice is not a subset, the offending elements are
// returned. | [
"SliceStringIsSubset",
"returns",
"whether",
"the",
"smaller",
"set",
"of",
"strings",
"is",
"a",
"subset",
"of",
"the",
"larger",
".",
"If",
"the",
"smaller",
"slice",
"is",
"not",
"a",
"subset",
"the",
"offending",
"elements",
"are",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L151-L167 |
132,163 | hashicorp/nomad | helper/funcs.go | CompareMapStringString | func CompareMapStringString(a, b map[string]string) bool {
if a == nil || b == nil {
return a == nil && b == nil
}
if len(a) != len(b) {
return false
}
for k, v := range a {
v2, ok := b[k]
if !ok {
return false
}
if v != v2 {
return false
}
}
// Already compared all known values in a so on... | go | func CompareMapStringString(a, b map[string]string) bool {
if a == nil || b == nil {
return a == nil && b == nil
}
if len(a) != len(b) {
return false
}
for k, v := range a {
v2, ok := b[k]
if !ok {
return false
}
if v != v2 {
return false
}
}
// Already compared all known values in a so on... | [
"func",
"CompareMapStringString",
"(",
"a",
",",
"b",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"if",
"a",
"==",
"nil",
"||",
"b",
"==",
"nil",
"{",
"return",
"a",
"==",
"nil",
"&&",
"b",
"==",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
... | // CompareMapStringString returns true if the maps are equivalent. A nil and
// empty map are considered not equal. | [
"CompareMapStringString",
"returns",
"true",
"if",
"the",
"maps",
"are",
"equivalent",
".",
"A",
"nil",
"and",
"empty",
"map",
"are",
"considered",
"not",
"equal",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L195-L223 |
132,164 | hashicorp/nomad | helper/funcs.go | CopyMapStringString | func CopyMapStringString(m map[string]string) map[string]string {
l := len(m)
if l == 0 {
return nil
}
c := make(map[string]string, l)
for k, v := range m {
c[k] = v
}
return c
} | go | func CopyMapStringString(m map[string]string) map[string]string {
l := len(m)
if l == 0 {
return nil
}
c := make(map[string]string, l)
for k, v := range m {
c[k] = v
}
return c
} | [
"func",
"CopyMapStringString",
"(",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"l",
":=",
"len",
"(",
"m",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"c",
":=",
"make",
... | // Helpers for copying generic structures. | [
"Helpers",
"for",
"copying",
"generic",
"structures",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L226-L237 |
132,165 | hashicorp/nomad | helper/funcs.go | CopyMapStringSliceString | func CopyMapStringSliceString(m map[string][]string) map[string][]string {
l := len(m)
if l == 0 {
return nil
}
c := make(map[string][]string, l)
for k, v := range m {
c[k] = CopySliceString(v)
}
return c
} | go | func CopyMapStringSliceString(m map[string][]string) map[string][]string {
l := len(m)
if l == 0 {
return nil
}
c := make(map[string][]string, l)
for k, v := range m {
c[k] = CopySliceString(v)
}
return c
} | [
"func",
"CopyMapStringSliceString",
"(",
"m",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"{",
"l",
":=",
"len",
"(",
"m",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
... | // CopyMapStringSliceString copies a map of strings to string slices such as
// http.Header | [
"CopyMapStringSliceString",
"copies",
"a",
"map",
"of",
"strings",
"to",
"string",
"slices",
"such",
"as",
"http",
".",
"Header"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L280-L291 |
132,166 | hashicorp/nomad | helper/funcs.go | CleanEnvVar | func CleanEnvVar(s string, r byte) string {
b := []byte(s)
for i, c := range b {
switch {
case c == '_':
case c == '.':
case c >= 'a' && c <= 'z':
case c >= 'A' && c <= 'Z':
case i > 0 && c >= '0' && c <= '9':
default:
// Replace!
b[i] = r
}
}
return string(b)
} | go | func CleanEnvVar(s string, r byte) string {
b := []byte(s)
for i, c := range b {
switch {
case c == '_':
case c == '.':
case c >= 'a' && c <= 'z':
case c >= 'A' && c <= 'Z':
case i > 0 && c >= '0' && c <= '9':
default:
// Replace!
b[i] = r
}
}
return string(b)
} | [
"func",
"CleanEnvVar",
"(",
"s",
"string",
",",
"r",
"byte",
")",
"string",
"{",
"b",
":=",
"[",
"]",
"byte",
"(",
"s",
")",
"\n",
"for",
"i",
",",
"c",
":=",
"range",
"b",
"{",
"switch",
"{",
"case",
"c",
"==",
"'_'",
":",
"case",
"c",
"==",... | // CleanEnvVar replaces all occurrences of illegal characters in an environment
// variable with the specified byte. | [
"CleanEnvVar",
"replaces",
"all",
"occurrences",
"of",
"illegal",
"characters",
"in",
"an",
"environment",
"variable",
"with",
"the",
"specified",
"byte",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/funcs.go#L321-L336 |
132,167 | hashicorp/nomad | devices/gpu/nvidia/nvml/driver_linux.go | DeviceInfoByIndex | func (n *nvmlDriver) DeviceInfoByIndex(index uint) (*DeviceInfo, error) {
device, err := nvml.NewDevice(index)
if err != nil {
return nil, err
}
deviceMode, err := device.GetDeviceMode()
if err != nil {
return nil, err
}
return &DeviceInfo{
UUID: device.UUID,
Name: device.Mode... | go | func (n *nvmlDriver) DeviceInfoByIndex(index uint) (*DeviceInfo, error) {
device, err := nvml.NewDevice(index)
if err != nil {
return nil, err
}
deviceMode, err := device.GetDeviceMode()
if err != nil {
return nil, err
}
return &DeviceInfo{
UUID: device.UUID,
Name: device.Mode... | [
"func",
"(",
"n",
"*",
"nvmlDriver",
")",
"DeviceInfoByIndex",
"(",
"index",
"uint",
")",
"(",
"*",
"DeviceInfo",
",",
"error",
")",
"{",
"device",
",",
"err",
":=",
"nvml",
".",
"NewDevice",
"(",
"index",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // DeviceInfoByIndex returns DeviceInfo for index GPU in system device list | [
"DeviceInfoByIndex",
"returns",
"DeviceInfo",
"for",
"index",
"GPU",
"in",
"system",
"device",
"list"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/nvml/driver_linux.go#L28-L50 |
132,168 | hashicorp/nomad | api/evaluations.go | List | func (e *Evaluations) List(q *QueryOptions) ([]*Evaluation, *QueryMeta, error) {
var resp []*Evaluation
qm, err := e.client.query("/v1/evaluations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(EvalIndexSort(resp))
return resp, qm, nil
} | go | func (e *Evaluations) List(q *QueryOptions) ([]*Evaluation, *QueryMeta, error) {
var resp []*Evaluation
qm, err := e.client.query("/v1/evaluations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(EvalIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"e",
"*",
"Evaluations",
")",
"List",
"(",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Evaluation",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Evaluation",
"\n",
"qm",
",",
"err",
":=",
"e",... | // List is used to dump all of the evaluations. | [
"List",
"is",
"used",
"to",
"dump",
"all",
"of",
"the",
"evaluations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/evaluations.go#L19-L27 |
132,169 | hashicorp/nomad | api/evaluations.go | Info | func (e *Evaluations) Info(evalID string, q *QueryOptions) (*Evaluation, *QueryMeta, error) {
var resp Evaluation
qm, err := e.client.query("/v1/evaluation/"+evalID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (e *Evaluations) Info(evalID string, q *QueryOptions) (*Evaluation, *QueryMeta, error) {
var resp Evaluation
qm, err := e.client.query("/v1/evaluation/"+evalID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"e",
"*",
"Evaluations",
")",
"Info",
"(",
"evalID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Evaluation",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"Evaluation",
"\n",
"qm",
",",
"err",
":=",
"e",
"... | // Info is used to query a single evaluation by its ID. | [
"Info",
"is",
"used",
"to",
"query",
"a",
"single",
"evaluation",
"by",
"its",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/evaluations.go#L34-L41 |
132,170 | hashicorp/nomad | api/evaluations.go | Allocations | func (e *Evaluations) Allocations(evalID string, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
qm, err := e.client.query("/v1/evaluation/"+evalID+"/allocations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocIndexSort(resp))
return resp, qm, nil
} | go | func (e *Evaluations) Allocations(evalID string, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error) {
var resp []*AllocationListStub
qm, err := e.client.query("/v1/evaluation/"+evalID+"/allocations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"e",
"*",
"Evaluations",
")",
"Allocations",
"(",
"evalID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"AllocationListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"AllocationLis... | // Allocations is used to retrieve a set of allocations given
// an evaluation ID. | [
"Allocations",
"is",
"used",
"to",
"retrieve",
"a",
"set",
"of",
"allocations",
"given",
"an",
"evaluation",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/evaluations.go#L45-L53 |
132,171 | hashicorp/nomad | scheduler/generic_sched_oss.go | selectNextOption | func (s *GenericScheduler) selectNextOption(tg *structs.TaskGroup, selectOptions *SelectOptions) *RankedNode {
return s.stack.Select(tg, selectOptions)
} | go | func (s *GenericScheduler) selectNextOption(tg *structs.TaskGroup, selectOptions *SelectOptions) *RankedNode {
return s.stack.Select(tg, selectOptions)
} | [
"func",
"(",
"s",
"*",
"GenericScheduler",
")",
"selectNextOption",
"(",
"tg",
"*",
"structs",
".",
"TaskGroup",
",",
"selectOptions",
"*",
"SelectOptions",
")",
"*",
"RankedNode",
"{",
"return",
"s",
".",
"stack",
".",
"Select",
"(",
"tg",
",",
"selectOpt... | // selectNextOption calls the stack to get a node for placement | [
"selectNextOption",
"calls",
"the",
"stack",
"to",
"get",
"a",
"node",
"for",
"placement"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched_oss.go#L8-L10 |
132,172 | hashicorp/nomad | scheduler/generic_sched_oss.go | handlePreemptions | func (s *GenericScheduler) handlePreemptions(option *RankedNode, alloc *structs.Allocation, missing placementResult) {
} | go | func (s *GenericScheduler) handlePreemptions(option *RankedNode, alloc *structs.Allocation, missing placementResult) {
} | [
"func",
"(",
"s",
"*",
"GenericScheduler",
")",
"handlePreemptions",
"(",
"option",
"*",
"RankedNode",
",",
"alloc",
"*",
"structs",
".",
"Allocation",
",",
"missing",
"placementResult",
")",
"{",
"}"
] | // handlePreemptions sets relevant preeemption related fields. In OSS this is a no op. | [
"handlePreemptions",
"sets",
"relevant",
"preeemption",
"related",
"fields",
".",
"In",
"OSS",
"this",
"is",
"a",
"no",
"op",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/generic_sched_oss.go#L13-L15 |
132,173 | hashicorp/nomad | client/allocdir/fs_windows.go | linkOrCopy | func linkOrCopy(src, dst string, uid, gid int, perm os.FileMode) error {
return fileCopy(src, dst, uid, gid, perm)
} | go | func linkOrCopy(src, dst string, uid, gid int, perm os.FileMode) error {
return fileCopy(src, dst, uid, gid, perm)
} | [
"func",
"linkOrCopy",
"(",
"src",
",",
"dst",
"string",
",",
"uid",
",",
"gid",
"int",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"return",
"fileCopy",
"(",
"src",
",",
"dst",
",",
"uid",
",",
"gid",
",",
"perm",
")",
"\n",
"}"
] | // linkOrCopy is always copies dst to src on Windows. | [
"linkOrCopy",
"is",
"always",
"copies",
"dst",
"to",
"src",
"on",
"Windows",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_windows.go#L23-L25 |
132,174 | hashicorp/nomad | nomad/deploymentwatcher/batcher.go | NewAllocUpdateBatcher | func NewAllocUpdateBatcher(batchDuration time.Duration, raft DeploymentRaftEndpoints, ctx context.Context) *AllocUpdateBatcher {
b := &AllocUpdateBatcher{
batch: batchDuration,
raft: raft,
ctx: ctx,
workCh: make(chan *updateWrapper, 10),
}
go b.batcher()
return b
} | go | func NewAllocUpdateBatcher(batchDuration time.Duration, raft DeploymentRaftEndpoints, ctx context.Context) *AllocUpdateBatcher {
b := &AllocUpdateBatcher{
batch: batchDuration,
raft: raft,
ctx: ctx,
workCh: make(chan *updateWrapper, 10),
}
go b.batcher()
return b
} | [
"func",
"NewAllocUpdateBatcher",
"(",
"batchDuration",
"time",
".",
"Duration",
",",
"raft",
"DeploymentRaftEndpoints",
",",
"ctx",
"context",
".",
"Context",
")",
"*",
"AllocUpdateBatcher",
"{",
"b",
":=",
"&",
"AllocUpdateBatcher",
"{",
"batch",
":",
"batchDurat... | // NewAllocUpdateBatcher returns an AllocUpdateBatcher that uses the passed raft endpoints to
// create the allocation desired transition updates and new evaluations and
// exits the batcher when the passed exit channel is closed. | [
"NewAllocUpdateBatcher",
"returns",
"an",
"AllocUpdateBatcher",
"that",
"uses",
"the",
"passed",
"raft",
"endpoints",
"to",
"create",
"the",
"allocation",
"desired",
"transition",
"updates",
"and",
"new",
"evaluations",
"and",
"exits",
"the",
"batcher",
"when",
"the... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/batcher.go#L29-L39 |
132,175 | hashicorp/nomad | nomad/deploymentwatcher/batcher.go | CreateUpdate | func (b *AllocUpdateBatcher) CreateUpdate(allocs map[string]*structs.DesiredTransition, eval *structs.Evaluation) *BatchFuture {
wrapper := &updateWrapper{
allocs: allocs,
e: eval,
f: make(chan *BatchFuture, 1),
}
b.workCh <- wrapper
return <-wrapper.f
} | go | func (b *AllocUpdateBatcher) CreateUpdate(allocs map[string]*structs.DesiredTransition, eval *structs.Evaluation) *BatchFuture {
wrapper := &updateWrapper{
allocs: allocs,
e: eval,
f: make(chan *BatchFuture, 1),
}
b.workCh <- wrapper
return <-wrapper.f
} | [
"func",
"(",
"b",
"*",
"AllocUpdateBatcher",
")",
"CreateUpdate",
"(",
"allocs",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"DesiredTransition",
",",
"eval",
"*",
"structs",
".",
"Evaluation",
")",
"*",
"BatchFuture",
"{",
"wrapper",
":=",
"&",
"updat... | // CreateUpdate batches the allocation desired transition update and returns a
// future that tracks the completion of the request. | [
"CreateUpdate",
"batches",
"the",
"allocation",
"desired",
"transition",
"update",
"and",
"returns",
"a",
"future",
"that",
"tracks",
"the",
"completion",
"of",
"the",
"request",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/batcher.go#L43-L52 |
132,176 | hashicorp/nomad | nomad/deploymentwatcher/batcher.go | batcher | func (b *AllocUpdateBatcher) batcher() {
var timerCh <-chan time.Time
allocs := make(map[string]*structs.DesiredTransition)
evals := make(map[string]*structs.Evaluation)
future := NewBatchFuture()
for {
select {
case <-b.ctx.Done():
return
case w := <-b.workCh:
if timerCh == nil {
timerCh = time.Af... | go | func (b *AllocUpdateBatcher) batcher() {
var timerCh <-chan time.Time
allocs := make(map[string]*structs.DesiredTransition)
evals := make(map[string]*structs.Evaluation)
future := NewBatchFuture()
for {
select {
case <-b.ctx.Done():
return
case w := <-b.workCh:
if timerCh == nil {
timerCh = time.Af... | [
"func",
"(",
"b",
"*",
"AllocUpdateBatcher",
")",
"batcher",
"(",
")",
"{",
"var",
"timerCh",
"<-",
"chan",
"time",
".",
"Time",
"\n",
"allocs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"structs",
".",
"DesiredTransition",
")",
"\n",
"evals",... | // batcher is the long lived batcher goroutine | [
"batcher",
"is",
"the",
"long",
"lived",
"batcher",
"goroutine"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/batcher.go#L61-L111 |
132,177 | hashicorp/nomad | nomad/deploymentwatcher/batcher.go | Set | func (f *BatchFuture) Set(index uint64, err error) {
f.index = index
f.err = err
close(f.waitCh)
} | go | func (f *BatchFuture) Set(index uint64, err error) {
f.index = index
f.err = err
close(f.waitCh)
} | [
"func",
"(",
"f",
"*",
"BatchFuture",
")",
"Set",
"(",
"index",
"uint64",
",",
"err",
"error",
")",
"{",
"f",
".",
"index",
"=",
"index",
"\n",
"f",
".",
"err",
"=",
"err",
"\n",
"close",
"(",
"f",
".",
"waitCh",
")",
"\n",
"}"
] | // Set sets the results of the future, unblocking any client. | [
"Set",
"sets",
"the",
"results",
"of",
"the",
"future",
"unblocking",
"any",
"client",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/batcher.go#L129-L133 |
132,178 | hashicorp/nomad | nomad/deploymentwatcher/batcher.go | Results | func (f *BatchFuture) Results() (uint64, error) {
<-f.waitCh
return f.index, f.err
} | go | func (f *BatchFuture) Results() (uint64, error) {
<-f.waitCh
return f.index, f.err
} | [
"func",
"(",
"f",
"*",
"BatchFuture",
")",
"Results",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"<-",
"f",
".",
"waitCh",
"\n",
"return",
"f",
".",
"index",
",",
"f",
".",
"err",
"\n",
"}"
] | // Results returns the creation index and any error. | [
"Results",
"returns",
"the",
"creation",
"index",
"and",
"any",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/deploymentwatcher/batcher.go#L136-L139 |
132,179 | hashicorp/nomad | nomad/alloc_endpoint.go | List | func (a *Alloc) List(args *structs.AllocListRequest, reply *structs.AllocListResponse) error {
if done, err := a.srv.forward("Alloc.List", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "list"}, time.Now())
// Check namespace read-job permissions
if aclObj, err := ... | go | func (a *Alloc) List(args *structs.AllocListRequest, reply *structs.AllocListResponse) error {
if done, err := a.srv.forward("Alloc.List", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "list"}, time.Now())
// Check namespace read-job permissions
if aclObj, err := ... | [
"func",
"(",
"a",
"*",
"Alloc",
")",
"List",
"(",
"args",
"*",
"structs",
".",
"AllocListRequest",
",",
"reply",
"*",
"structs",
".",
"AllocListResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"a",
".",
"srv",
".",
"forward",
"(",
"\"",
... | // List is used to list the allocations in the system | [
"List",
"is",
"used",
"to",
"list",
"the",
"allocations",
"in",
"the",
"system"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/alloc_endpoint.go#L26-L79 |
132,180 | hashicorp/nomad | nomad/alloc_endpoint.go | GetAlloc | func (a *Alloc) GetAlloc(args *structs.AllocSpecificRequest,
reply *structs.SingleAllocResponse) error {
if done, err := a.srv.forward("Alloc.GetAlloc", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "get_alloc"}, time.Now())
// Check namespace read-job permissions... | go | func (a *Alloc) GetAlloc(args *structs.AllocSpecificRequest,
reply *structs.SingleAllocResponse) error {
if done, err := a.srv.forward("Alloc.GetAlloc", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "get_alloc"}, time.Now())
// Check namespace read-job permissions... | [
"func",
"(",
"a",
"*",
"Alloc",
")",
"GetAlloc",
"(",
"args",
"*",
"structs",
".",
"AllocSpecificRequest",
",",
"reply",
"*",
"structs",
".",
"SingleAllocResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"a",
".",
"srv",
".",
"forward",
"("... | // GetAlloc is used to lookup a particular allocation | [
"GetAlloc",
"is",
"used",
"to",
"lookup",
"a",
"particular",
"allocation"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/alloc_endpoint.go#L82-L143 |
132,181 | hashicorp/nomad | nomad/alloc_endpoint.go | GetAllocs | func (a *Alloc) GetAllocs(args *structs.AllocsGetRequest,
reply *structs.AllocsGetResponse) error {
if done, err := a.srv.forward("Alloc.GetAllocs", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "get_allocs"}, time.Now())
allocs := make([]*structs.Allocation, len(... | go | func (a *Alloc) GetAllocs(args *structs.AllocsGetRequest,
reply *structs.AllocsGetResponse) error {
if done, err := a.srv.forward("Alloc.GetAllocs", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "get_allocs"}, time.Now())
allocs := make([]*structs.Allocation, len(... | [
"func",
"(",
"a",
"*",
"Alloc",
")",
"GetAllocs",
"(",
"args",
"*",
"structs",
".",
"AllocsGetRequest",
",",
"reply",
"*",
"structs",
".",
"AllocsGetResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"a",
".",
"srv",
".",
"forward",
"(",
"... | // GetAllocs is used to lookup a set of allocations | [
"GetAllocs",
"is",
"used",
"to",
"lookup",
"a",
"set",
"of",
"allocations"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/alloc_endpoint.go#L146-L208 |
132,182 | hashicorp/nomad | nomad/alloc_endpoint.go | Stop | func (a *Alloc) Stop(args *structs.AllocStopRequest, reply *structs.AllocStopResponse) error {
if done, err := a.srv.forward("Alloc.Stop", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "stop"}, time.Now())
// Check that it is a management token.
if aclObj, err := ... | go | func (a *Alloc) Stop(args *structs.AllocStopRequest, reply *structs.AllocStopResponse) error {
if done, err := a.srv.forward("Alloc.Stop", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "stop"}, time.Now())
// Check that it is a management token.
if aclObj, err := ... | [
"func",
"(",
"a",
"*",
"Alloc",
")",
"Stop",
"(",
"args",
"*",
"structs",
".",
"AllocStopRequest",
",",
"reply",
"*",
"structs",
".",
"AllocStopResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"a",
".",
"srv",
".",
"forward",
"(",
"\"",
... | // Stop is used to stop an allocation and migrate it to another node. | [
"Stop",
"is",
"used",
"to",
"stop",
"an",
"allocation",
"and",
"migrate",
"it",
"to",
"another",
"node",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/alloc_endpoint.go#L211-L265 |
132,183 | hashicorp/nomad | nomad/alloc_endpoint.go | UpdateDesiredTransition | func (a *Alloc) UpdateDesiredTransition(args *structs.AllocUpdateDesiredTransitionRequest, reply *structs.GenericResponse) error {
if done, err := a.srv.forward("Alloc.UpdateDesiredTransition", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "update_desired_transition"... | go | func (a *Alloc) UpdateDesiredTransition(args *structs.AllocUpdateDesiredTransitionRequest, reply *structs.GenericResponse) error {
if done, err := a.srv.forward("Alloc.UpdateDesiredTransition", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "alloc", "update_desired_transition"... | [
"func",
"(",
"a",
"*",
"Alloc",
")",
"UpdateDesiredTransition",
"(",
"args",
"*",
"structs",
".",
"AllocUpdateDesiredTransitionRequest",
",",
"reply",
"*",
"structs",
".",
"GenericResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"a",
".",
"srv",... | // UpdateDesiredTransition is used to update the desired transitions of an
// allocation. | [
"UpdateDesiredTransition",
"is",
"used",
"to",
"update",
"the",
"desired",
"transitions",
"of",
"an",
"allocation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/alloc_endpoint.go#L269-L297 |
132,184 | hashicorp/nomad | scheduler/stack.go | NewSystemStack | func NewSystemStack(ctx Context) *SystemStack {
// Create a new stack
s := &SystemStack{ctx: ctx}
// Create the source iterator. We visit nodes in a linear order because we
// have to evaluate on all nodes.
s.source = NewStaticIterator(ctx, nil)
// Create the quota iterator to determine if placements would resu... | go | func NewSystemStack(ctx Context) *SystemStack {
// Create a new stack
s := &SystemStack{ctx: ctx}
// Create the source iterator. We visit nodes in a linear order because we
// have to evaluate on all nodes.
s.source = NewStaticIterator(ctx, nil)
// Create the quota iterator to determine if placements would resu... | [
"func",
"NewSystemStack",
"(",
"ctx",
"Context",
")",
"*",
"SystemStack",
"{",
"// Create a new stack",
"s",
":=",
"&",
"SystemStack",
"{",
"ctx",
":",
"ctx",
"}",
"\n\n",
"// Create the source iterator. We visit nodes in a linear order because we",
"// have to evaluate on ... | // NewSystemStack constructs a stack used for selecting service placements | [
"NewSystemStack",
"constructs",
"a",
"stack",
"used",
"for",
"selecting",
"service",
"placements"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/stack.go#L181-L232 |
132,185 | hashicorp/nomad | drivers/shared/executor/plugins.go | PluginConfig | func (c *PluginReattachConfig) PluginConfig() *plugin.ReattachConfig {
var addr net.Addr
switch c.AddrNet {
case "unix", "unixgram", "unixpacket":
addr, _ = net.ResolveUnixAddr(c.AddrNet, c.AddrName)
case "tcp", "tcp4", "tcp6":
addr, _ = net.ResolveTCPAddr(c.AddrNet, c.AddrName)
}
return &plugin.ReattachConfi... | go | func (c *PluginReattachConfig) PluginConfig() *plugin.ReattachConfig {
var addr net.Addr
switch c.AddrNet {
case "unix", "unixgram", "unixpacket":
addr, _ = net.ResolveUnixAddr(c.AddrNet, c.AddrName)
case "tcp", "tcp4", "tcp6":
addr, _ = net.ResolveTCPAddr(c.AddrNet, c.AddrName)
}
return &plugin.ReattachConfi... | [
"func",
"(",
"c",
"*",
"PluginReattachConfig",
")",
"PluginConfig",
"(",
")",
"*",
"plugin",
".",
"ReattachConfig",
"{",
"var",
"addr",
"net",
".",
"Addr",
"\n",
"switch",
"c",
".",
"AddrNet",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\""... | // PluginConfig returns a config from an ExecutorReattachConfig | [
"PluginConfig",
"returns",
"a",
"config",
"from",
"an",
"ExecutorReattachConfig"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/plugins.go#L48-L57 |
132,186 | hashicorp/nomad | api/nodes.go | List | func (n *Nodes) List(q *QueryOptions) ([]*NodeListStub, *QueryMeta, error) {
var resp NodeIndexSort
qm, err := n.client.query("/v1/nodes", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(resp)
return resp, qm, nil
} | go | func (n *Nodes) List(q *QueryOptions) ([]*NodeListStub, *QueryMeta, error) {
var resp NodeIndexSort
qm, err := n.client.query("/v1/nodes", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(resp)
return resp, qm, nil
} | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"List",
"(",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"NodeListStub",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"NodeIndexSort",
"\n",
"qm",
",",
"err",
":=",
"n",
".",
"client",
... | // List is used to list out all of the nodes | [
"List",
"is",
"used",
"to",
"list",
"out",
"all",
"of",
"the",
"nodes"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L34-L42 |
132,187 | hashicorp/nomad | api/nodes.go | Info | func (n *Nodes) Info(nodeID string, q *QueryOptions) (*Node, *QueryMeta, error) {
var resp Node
qm, err := n.client.query("/v1/node/"+nodeID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (n *Nodes) Info(nodeID string, q *QueryOptions) (*Node, *QueryMeta, error) {
var resp Node
qm, err := n.client.query("/v1/node/"+nodeID, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"Info",
"(",
"nodeID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Node",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"Node",
"\n",
"qm",
",",
"err",
":=",
"n",
".",
"client",
... | // Info is used to query a specific node by its ID. | [
"Info",
"is",
"used",
"to",
"query",
"a",
"specific",
"node",
"by",
"its",
"ID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L49-L56 |
132,188 | hashicorp/nomad | api/nodes.go | UpdateDrain | func (n *Nodes) UpdateDrain(nodeID string, spec *DrainSpec, markEligible bool, q *WriteOptions) (*NodeDrainUpdateResponse, error) {
req := &NodeUpdateDrainRequest{
NodeID: nodeID,
DrainSpec: spec,
MarkEligible: markEligible,
}
var resp NodeDrainUpdateResponse
wm, err := n.client.write("/v1/node/"+no... | go | func (n *Nodes) UpdateDrain(nodeID string, spec *DrainSpec, markEligible bool, q *WriteOptions) (*NodeDrainUpdateResponse, error) {
req := &NodeUpdateDrainRequest{
NodeID: nodeID,
DrainSpec: spec,
MarkEligible: markEligible,
}
var resp NodeDrainUpdateResponse
wm, err := n.client.write("/v1/node/"+no... | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"UpdateDrain",
"(",
"nodeID",
"string",
",",
"spec",
"*",
"DrainSpec",
",",
"markEligible",
"bool",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"NodeDrainUpdateResponse",
",",
"error",
")",
"{",
"req",
":=",
"&",
... | // UpdateDrain is used to update the drain strategy for a given node. If
// markEligible is true and the drain is being removed, the node will be marked
// as having its scheduling being eligible | [
"UpdateDrain",
"is",
"used",
"to",
"update",
"the",
"drain",
"strategy",
"for",
"a",
"given",
"node",
".",
"If",
"markEligible",
"is",
"true",
"and",
"the",
"drain",
"is",
"being",
"removed",
"the",
"node",
"will",
"be",
"marked",
"as",
"having",
"its",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L83-L97 |
132,189 | hashicorp/nomad | api/nodes.go | Messagef | func Messagef(lvl MonitorMsgLevel, msg string, args ...interface{}) *MonitorMessage {
return &MonitorMessage{
Level: lvl,
Message: fmt.Sprintf(msg, args...),
}
} | go | func Messagef(lvl MonitorMsgLevel, msg string, args ...interface{}) *MonitorMessage {
return &MonitorMessage{
Level: lvl,
Message: fmt.Sprintf(msg, args...),
}
} | [
"func",
"Messagef",
"(",
"lvl",
"MonitorMsgLevel",
",",
"msg",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"MonitorMessage",
"{",
"return",
"&",
"MonitorMessage",
"{",
"Level",
":",
"lvl",
",",
"Message",
":",
"fmt",
".",
"Sprintf",
"(... | // Messagef formats a new MonitorMessage. | [
"Messagef",
"formats",
"a",
"new",
"MonitorMessage",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L116-L121 |
132,190 | hashicorp/nomad | api/nodes.go | MonitorDrain | func (n *Nodes) MonitorDrain(ctx context.Context, nodeID string, index uint64, ignoreSys bool) <-chan *MonitorMessage {
outCh := make(chan *MonitorMessage, 8)
nodeCh := make(chan *MonitorMessage, 1)
allocCh := make(chan *MonitorMessage, 8)
// Multiplex node and alloc chans onto outCh. This goroutine closes
// out... | go | func (n *Nodes) MonitorDrain(ctx context.Context, nodeID string, index uint64, ignoreSys bool) <-chan *MonitorMessage {
outCh := make(chan *MonitorMessage, 8)
nodeCh := make(chan *MonitorMessage, 1)
allocCh := make(chan *MonitorMessage, 8)
// Multiplex node and alloc chans onto outCh. This goroutine closes
// out... | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"MonitorDrain",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodeID",
"string",
",",
"index",
"uint64",
",",
"ignoreSys",
"bool",
")",
"<-",
"chan",
"*",
"MonitorMessage",
"{",
"outCh",
":=",
"make",
"(",
"chan",
"*... | // MonitorDrain emits drain related events on the returned string channel. The
// channel will be closed when all allocations on the draining node have
// stopped or the context is canceled. | [
"MonitorDrain",
"emits",
"drain",
"related",
"events",
"on",
"the",
"returned",
"string",
"channel",
".",
"The",
"channel",
"will",
"be",
"closed",
"when",
"all",
"allocations",
"on",
"the",
"draining",
"node",
"have",
"stopped",
"or",
"the",
"context",
"is",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L130-L147 |
132,191 | hashicorp/nomad | api/nodes.go | monitorDrainMultiplex | func (n *Nodes) monitorDrainMultiplex(ctx context.Context, cancel func(),
outCh chan<- *MonitorMessage, nodeCh, allocCh <-chan *MonitorMessage) {
defer cancel()
defer close(outCh)
nodeOk := true
allocOk := true
var msg *MonitorMessage
for {
// If both chans have been closed, close the output chan
if !nodeO... | go | func (n *Nodes) monitorDrainMultiplex(ctx context.Context, cancel func(),
outCh chan<- *MonitorMessage, nodeCh, allocCh <-chan *MonitorMessage) {
defer cancel()
defer close(outCh)
nodeOk := true
allocOk := true
var msg *MonitorMessage
for {
// If both chans have been closed, close the output chan
if !nodeO... | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"monitorDrainMultiplex",
"(",
"ctx",
"context",
".",
"Context",
",",
"cancel",
"func",
"(",
")",
",",
"outCh",
"chan",
"<-",
"*",
"MonitorMessage",
",",
"nodeCh",
",",
"allocCh",
"<-",
"chan",
"*",
"MonitorMessage",
"... | // monitorDrainMultiplex multiplexes node and alloc updates onto the out chan.
// Closes out chan when either the context is canceled, both update chans are
// closed, or an error occurs. | [
"monitorDrainMultiplex",
"multiplexes",
"node",
"and",
"alloc",
"updates",
"onto",
"the",
"out",
"chan",
".",
"Closes",
"out",
"chan",
"when",
"either",
"the",
"context",
"is",
"canceled",
"both",
"update",
"chans",
"are",
"closed",
"or",
"an",
"error",
"occur... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L152-L201 |
132,192 | hashicorp/nomad | api/nodes.go | monitorDrainNode | func (n *Nodes) monitorDrainNode(ctx context.Context, nodeID string,
index uint64, nodeCh chan<- *MonitorMessage) {
defer close(nodeCh)
var lastStrategy *DrainStrategy
q := QueryOptions{
AllowStale: true,
WaitIndex: index,
}
for {
node, meta, err := n.Info(nodeID, &q)
if err != nil {
msg := Messagef... | go | func (n *Nodes) monitorDrainNode(ctx context.Context, nodeID string,
index uint64, nodeCh chan<- *MonitorMessage) {
defer close(nodeCh)
var lastStrategy *DrainStrategy
q := QueryOptions{
AllowStale: true,
WaitIndex: index,
}
for {
node, meta, err := n.Info(nodeID, &q)
if err != nil {
msg := Messagef... | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"monitorDrainNode",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodeID",
"string",
",",
"index",
"uint64",
",",
"nodeCh",
"chan",
"<-",
"*",
"MonitorMessage",
")",
"{",
"defer",
"close",
"(",
"nodeCh",
")",
"\n\n",
... | // monitorDrainNode emits node updates on nodeCh and closes the channel when
// the node has finished draining. | [
"monitorDrainNode",
"emits",
"node",
"updates",
"on",
"nodeCh",
"and",
"closes",
"the",
"channel",
"when",
"the",
"node",
"has",
"finished",
"draining",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L205-L259 |
132,193 | hashicorp/nomad | api/nodes.go | monitorDrainAllocs | func (n *Nodes) monitorDrainAllocs(ctx context.Context, nodeID string, ignoreSys bool, allocCh chan<- *MonitorMessage) {
defer close(allocCh)
q := QueryOptions{AllowStale: true}
initial := make(map[string]*Allocation, 4)
for {
allocs, meta, err := n.Allocations(nodeID, &q)
if err != nil {
msg := Messagef(M... | go | func (n *Nodes) monitorDrainAllocs(ctx context.Context, nodeID string, ignoreSys bool, allocCh chan<- *MonitorMessage) {
defer close(allocCh)
q := QueryOptions{AllowStale: true}
initial := make(map[string]*Allocation, 4)
for {
allocs, meta, err := n.Allocations(nodeID, &q)
if err != nil {
msg := Messagef(M... | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"monitorDrainAllocs",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodeID",
"string",
",",
"ignoreSys",
"bool",
",",
"allocCh",
"chan",
"<-",
"*",
"MonitorMessage",
")",
"{",
"defer",
"close",
"(",
"allocCh",
")",
"\n... | // monitorDrainAllocs emits alloc updates on allocCh and closes the channel
// when the node has finished draining. | [
"monitorDrainAllocs",
"emits",
"alloc",
"updates",
"on",
"allocCh",
"and",
"closes",
"the",
"channel",
"when",
"the",
"node",
"has",
"finished",
"draining",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L263-L346 |
132,194 | hashicorp/nomad | api/nodes.go | ToggleEligibility | func (n *Nodes) ToggleEligibility(nodeID string, eligible bool, q *WriteOptions) (*NodeEligibilityUpdateResponse, error) {
e := NodeSchedulingEligible
if !eligible {
e = NodeSchedulingIneligible
}
req := &NodeUpdateEligibilityRequest{
NodeID: nodeID,
Eligibility: e,
}
var resp NodeEligibilityUpdateRe... | go | func (n *Nodes) ToggleEligibility(nodeID string, eligible bool, q *WriteOptions) (*NodeEligibilityUpdateResponse, error) {
e := NodeSchedulingEligible
if !eligible {
e = NodeSchedulingIneligible
}
req := &NodeUpdateEligibilityRequest{
NodeID: nodeID,
Eligibility: e,
}
var resp NodeEligibilityUpdateRe... | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"ToggleEligibility",
"(",
"nodeID",
"string",
",",
"eligible",
"bool",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"NodeEligibilityUpdateResponse",
",",
"error",
")",
"{",
"e",
":=",
"NodeSchedulingEligible",
"\n",
"if"... | // ToggleEligibility is used to update the scheduling eligibility of the node | [
"ToggleEligibility",
"is",
"used",
"to",
"update",
"the",
"scheduling",
"eligibility",
"of",
"the",
"node"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L364-L382 |
132,195 | hashicorp/nomad | api/nodes.go | Allocations | func (n *Nodes) Allocations(nodeID string, q *QueryOptions) ([]*Allocation, *QueryMeta, error) {
var resp []*Allocation
qm, err := n.client.query("/v1/node/"+nodeID+"/allocations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocationSort(resp))
return resp, qm, nil
} | go | func (n *Nodes) Allocations(nodeID string, q *QueryOptions) ([]*Allocation, *QueryMeta, error) {
var resp []*Allocation
qm, err := n.client.query("/v1/node/"+nodeID+"/allocations", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(AllocationSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"Allocations",
"(",
"nodeID",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Allocation",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Allocation",
"\n",
"qm"... | // Allocations is used to return the allocations associated with a node. | [
"Allocations",
"is",
"used",
"to",
"return",
"the",
"allocations",
"associated",
"with",
"a",
"node",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L385-L393 |
132,196 | hashicorp/nomad | api/nodes.go | ForceEvaluate | func (n *Nodes) ForceEvaluate(nodeID string, q *WriteOptions) (string, *WriteMeta, error) {
var resp nodeEvalResponse
wm, err := n.client.write("/v1/node/"+nodeID+"/evaluate", nil, &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | go | func (n *Nodes) ForceEvaluate(nodeID string, q *WriteOptions) (string, *WriteMeta, error) {
var resp nodeEvalResponse
wm, err := n.client.write("/v1/node/"+nodeID+"/evaluate", nil, &resp, q)
if err != nil {
return "", nil, err
}
return resp.EvalID, wm, nil
} | [
"func",
"(",
"n",
"*",
"Nodes",
")",
"ForceEvaluate",
"(",
"nodeID",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"string",
",",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"var",
"resp",
"nodeEvalResponse",
"\n",
"wm",
",",
"err",
":=",
"n",
"."... | // ForceEvaluate is used to force-evaluate an existing node. | [
"ForceEvaluate",
"is",
"used",
"to",
"force",
"-",
"evaluate",
"an",
"existing",
"node",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L396-L403 |
132,197 | hashicorp/nomad | api/nodes.go | String | func (d *DrainStrategy) String() string {
if d.IgnoreSystemJobs {
return fmt.Sprintf("drain ignoring system jobs and deadline at %s", d.ForceDeadline)
}
return fmt.Sprintf("drain with deadline at %s", d.ForceDeadline)
} | go | func (d *DrainStrategy) String() string {
if d.IgnoreSystemJobs {
return fmt.Sprintf("drain ignoring system jobs and deadline at %s", d.ForceDeadline)
}
return fmt.Sprintf("drain with deadline at %s", d.ForceDeadline)
} | [
"func",
"(",
"d",
"*",
"DrainStrategy",
")",
"String",
"(",
")",
"string",
"{",
"if",
"d",
".",
"IgnoreSystemJobs",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"ForceDeadline",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"... | // String returns a human readable version of the drain strategy. | [
"String",
"returns",
"a",
"human",
"readable",
"version",
"of",
"the",
"drain",
"strategy",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/nodes.go#L549-L554 |
132,198 | hashicorp/nomad | helper/pluginutils/loader/init.go | validateConfig | func validateConfig(config *PluginLoaderConfig) error {
var mErr multierror.Error
if config == nil {
return fmt.Errorf("nil config passed")
} else if config.Logger == nil {
multierror.Append(&mErr, fmt.Errorf("nil logger passed"))
}
// Validate that all plugins have a binary name
for _, c := range config.Con... | go | func validateConfig(config *PluginLoaderConfig) error {
var mErr multierror.Error
if config == nil {
return fmt.Errorf("nil config passed")
} else if config.Logger == nil {
multierror.Append(&mErr, fmt.Errorf("nil logger passed"))
}
// Validate that all plugins have a binary name
for _, c := range config.Con... | [
"func",
"validateConfig",
"(",
"config",
"*",
"PluginLoaderConfig",
")",
"error",
"{",
"var",
"mErr",
"multierror",
".",
"Error",
"\n",
"if",
"config",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"co... | // validateConfig returns whether or not the configuration is valid | [
"validateConfig",
"returns",
"whether",
"or",
"not",
"the",
"configuration",
"is",
"valid"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L21-L49 |
132,199 | hashicorp/nomad | helper/pluginutils/loader/init.go | init | func (l *PluginLoader) init(config *PluginLoaderConfig) error {
// Create a mapping of name to config
configMap := configMap(config.Configs)
// Initialize the internal plugins
internal, err := l.initInternal(config.InternalPlugins, configMap)
if err != nil {
return fmt.Errorf("failed to fingerprint internal plu... | go | func (l *PluginLoader) init(config *PluginLoaderConfig) error {
// Create a mapping of name to config
configMap := configMap(config.Configs)
// Initialize the internal plugins
internal, err := l.initInternal(config.InternalPlugins, configMap)
if err != nil {
return fmt.Errorf("failed to fingerprint internal plu... | [
"func",
"(",
"l",
"*",
"PluginLoader",
")",
"init",
"(",
"config",
"*",
"PluginLoaderConfig",
")",
"error",
"{",
"// Create a mapping of name to config",
"configMap",
":=",
"configMap",
"(",
"config",
".",
"Configs",
")",
"\n\n",
"// Initialize the internal plugins",
... | // init initializes the plugin loader by compiling both internal and external
// plugins and selecting the highest versioned version of any given plugin. | [
"init",
"initializes",
"the",
"plugin",
"loader",
"by",
"compiling",
"both",
"internal",
"and",
"external",
"plugins",
"and",
"selecting",
"the",
"highest",
"versioned",
"version",
"of",
"any",
"given",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L53-L84 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.