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
133,300
hashicorp/nomad
nomad/structs/network.go
Overcommitted
func (idx *NetworkIndex) Overcommitted() bool { for device, used := range idx.UsedBandwidth { avail := idx.AvailBandwidth[device] if used > avail { return true } } return false }
go
func (idx *NetworkIndex) Overcommitted() bool { for device, used := range idx.UsedBandwidth { avail := idx.AvailBandwidth[device] if used > avail { return true } } return false }
[ "func", "(", "idx", "*", "NetworkIndex", ")", "Overcommitted", "(", ")", "bool", "{", "for", "device", ",", "used", ":=", "range", "idx", ".", "UsedBandwidth", "{", "avail", ":=", "idx", ".", "AvailBandwidth", "[", "device", "]", "\n", "if", "used", ">...
// Overcommitted checks if the network is overcommitted
[ "Overcommitted", "checks", "if", "the", "network", "is", "overcommitted" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L60-L68
133,301
hashicorp/nomad
nomad/structs/network.go
SetNode
func (idx *NetworkIndex) SetNode(node *Node) (collide bool) { // COMPAT(0.11): Remove in 0.11 // Grab the network resources, handling both new and old var networks []*NetworkResource if node.NodeResources != nil && len(node.NodeResources.Networks) != 0 { networks = node.NodeResources.Networks } else if node.Res...
go
func (idx *NetworkIndex) SetNode(node *Node) (collide bool) { // COMPAT(0.11): Remove in 0.11 // Grab the network resources, handling both new and old var networks []*NetworkResource if node.NodeResources != nil && len(node.NodeResources.Networks) != 0 { networks = node.NodeResources.Networks } else if node.Res...
[ "func", "(", "idx", "*", "NetworkIndex", ")", "SetNode", "(", "node", "*", "Node", ")", "(", "collide", "bool", ")", "{", "// COMPAT(0.11): Remove in 0.11", "// Grab the network resources, handling both new and old", "var", "networks", "[", "]", "*", "NetworkResource"...
// SetNode is used to setup the available network resources. Returns // true if there is a collision
[ "SetNode", "is", "used", "to", "setup", "the", "available", "network", "resources", ".", "Returns", "true", "if", "there", "is", "a", "collision" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L72-L104
133,302
hashicorp/nomad
nomad/structs/network.go
AddAllocs
func (idx *NetworkIndex) AddAllocs(allocs []*Allocation) (collide bool) { for _, alloc := range allocs { // Do not consider the resource impact of terminal allocations if alloc.TerminalStatus() { continue } if alloc.AllocatedResources != nil { for _, task := range alloc.AllocatedResources.Tasks { if...
go
func (idx *NetworkIndex) AddAllocs(allocs []*Allocation) (collide bool) { for _, alloc := range allocs { // Do not consider the resource impact of terminal allocations if alloc.TerminalStatus() { continue } if alloc.AllocatedResources != nil { for _, task := range alloc.AllocatedResources.Tasks { if...
[ "func", "(", "idx", "*", "NetworkIndex", ")", "AddAllocs", "(", "allocs", "[", "]", "*", "Allocation", ")", "(", "collide", "bool", ")", "{", "for", "_", ",", "alloc", ":=", "range", "allocs", "{", "// Do not consider the resource impact of terminal allocations"...
// AddAllocs is used to add the used network resources. Returns // true if there is a collision
[ "AddAllocs", "is", "used", "to", "add", "the", "used", "network", "resources", ".", "Returns", "true", "if", "there", "is", "a", "collision" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L108-L139
133,303
hashicorp/nomad
nomad/structs/network.go
AddReserved
func (idx *NetworkIndex) AddReserved(n *NetworkResource) (collide bool) { // Add the port usage used := idx.UsedPorts[n.IP] if used == nil { // Try to get a bitmap from the pool, else create raw := bitmapPool.Get() if raw != nil { used = raw.(Bitmap) used.Clear() } else { used, _ = NewBitmap(maxVali...
go
func (idx *NetworkIndex) AddReserved(n *NetworkResource) (collide bool) { // Add the port usage used := idx.UsedPorts[n.IP] if used == nil { // Try to get a bitmap from the pool, else create raw := bitmapPool.Get() if raw != nil { used = raw.(Bitmap) used.Clear() } else { used, _ = NewBitmap(maxVali...
[ "func", "(", "idx", "*", "NetworkIndex", ")", "AddReserved", "(", "n", "*", "NetworkResource", ")", "(", "collide", "bool", ")", "{", "// Add the port usage", "used", ":=", "idx", ".", "UsedPorts", "[", "n", ".", "IP", "]", "\n", "if", "used", "==", "n...
// AddReserved is used to add a reserved network usage, returns true // if there is a port collision
[ "AddReserved", "is", "used", "to", "add", "a", "reserved", "network", "usage", "returns", "true", "if", "there", "is", "a", "port", "collision" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L143-L175
133,304
hashicorp/nomad
nomad/structs/network.go
yieldIP
func (idx *NetworkIndex) yieldIP(cb func(net *NetworkResource, ip net.IP) bool) { inc := func(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]++ if ip[j] > 0 { break } } } for _, n := range idx.AvailNetworks { ip, ipnet, err := net.ParseCIDR(n.CIDR) if err != nil { continue } for i...
go
func (idx *NetworkIndex) yieldIP(cb func(net *NetworkResource, ip net.IP) bool) { inc := func(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]++ if ip[j] > 0 { break } } } for _, n := range idx.AvailNetworks { ip, ipnet, err := net.ParseCIDR(n.CIDR) if err != nil { continue } for i...
[ "func", "(", "idx", "*", "NetworkIndex", ")", "yieldIP", "(", "cb", "func", "(", "net", "*", "NetworkResource", ",", "ip", "net", ".", "IP", ")", "bool", ")", "{", "inc", ":=", "func", "(", "ip", "net", ".", "IP", ")", "{", "for", "j", ":=", "l...
// yieldIP is used to iteratively invoke the callback with // an available IP
[ "yieldIP", "is", "used", "to", "iteratively", "invoke", "the", "callback", "with", "an", "available", "IP" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L222-L243
133,305
hashicorp/nomad
nomad/structs/network.go
AssignNetwork
func (idx *NetworkIndex) AssignNetwork(ask *NetworkResource) (out *NetworkResource, err error) { err = fmt.Errorf("no networks available") idx.yieldIP(func(n *NetworkResource, ip net.IP) (stop bool) { // Convert the IP to a string ipStr := ip.String() // Check if we would exceed the bandwidth cap availBandwi...
go
func (idx *NetworkIndex) AssignNetwork(ask *NetworkResource) (out *NetworkResource, err error) { err = fmt.Errorf("no networks available") idx.yieldIP(func(n *NetworkResource, ip net.IP) (stop bool) { // Convert the IP to a string ipStr := ip.String() // Check if we would exceed the bandwidth cap availBandwi...
[ "func", "(", "idx", "*", "NetworkIndex", ")", "AssignNetwork", "(", "ask", "*", "NetworkResource", ")", "(", "out", "*", "NetworkResource", ",", "err", "error", ")", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "idx", ".", "yiel...
// AssignNetwork is used to assign network resources given an ask. // If the ask cannot be satisfied, returns nil
[ "AssignNetwork", "is", "used", "to", "assign", "network", "resources", "given", "an", "ask", ".", "If", "the", "ask", "cannot", "be", "satisfied", "returns", "nil" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L247-L314
133,306
hashicorp/nomad
nomad/structs/network.go
getDynamicPortsPrecise
func getDynamicPortsPrecise(nodeUsed Bitmap, ask *NetworkResource) ([]int, error) { // Create a copy of the used ports and apply the new reserves var usedSet Bitmap var err error if nodeUsed != nil { usedSet, err = nodeUsed.Copy() if err != nil { return nil, err } } else { usedSet, err = NewBitmap(maxVa...
go
func getDynamicPortsPrecise(nodeUsed Bitmap, ask *NetworkResource) ([]int, error) { // Create a copy of the used ports and apply the new reserves var usedSet Bitmap var err error if nodeUsed != nil { usedSet, err = nodeUsed.Copy() if err != nil { return nil, err } } else { usedSet, err = NewBitmap(maxVa...
[ "func", "getDynamicPortsPrecise", "(", "nodeUsed", "Bitmap", ",", "ask", "*", "NetworkResource", ")", "(", "[", "]", "int", ",", "error", ")", "{", "// Create a copy of the used ports and apply the new reserves", "var", "usedSet", "Bitmap", "\n", "var", "err", "erro...
// getDynamicPortsPrecise takes the nodes used port bitmap which may be nil if // no ports have been allocated yet, the network ask and returns a set of unused // ports to fullfil the ask's DynamicPorts or an error if it failed. An error // means the ask can not be satisfied as the method does a precise search.
[ "getDynamicPortsPrecise", "takes", "the", "nodes", "used", "port", "bitmap", "which", "may", "be", "nil", "if", "no", "ports", "have", "been", "allocated", "yet", "the", "network", "ask", "and", "returns", "a", "set", "of", "unused", "ports", "to", "fullfil"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L320-L356
133,307
hashicorp/nomad
nomad/structs/network.go
getDynamicPortsStochastic
func getDynamicPortsStochastic(nodeUsed Bitmap, ask *NetworkResource) ([]int, error) { var reserved, dynamic []int for _, port := range ask.ReservedPorts { reserved = append(reserved, port.Value) } for i := 0; i < len(ask.DynamicPorts); i++ { attempts := 0 PICK: attempts++ if attempts > maxRandPortAttempt...
go
func getDynamicPortsStochastic(nodeUsed Bitmap, ask *NetworkResource) ([]int, error) { var reserved, dynamic []int for _, port := range ask.ReservedPorts { reserved = append(reserved, port.Value) } for i := 0; i < len(ask.DynamicPorts); i++ { attempts := 0 PICK: attempts++ if attempts > maxRandPortAttempt...
[ "func", "getDynamicPortsStochastic", "(", "nodeUsed", "Bitmap", ",", "ask", "*", "NetworkResource", ")", "(", "[", "]", "int", ",", "error", ")", "{", "var", "reserved", ",", "dynamic", "[", "]", "int", "\n", "for", "_", ",", "port", ":=", "range", "as...
// getDynamicPortsStochastic takes the nodes used port bitmap which may be nil if // no ports have been allocated yet, the network ask and returns a set of unused // ports to fullfil the ask's DynamicPorts or an error if it failed. An error // does not mean the ask can not be satisfied as the method has a fixed amount ...
[ "getDynamicPortsStochastic", "takes", "the", "nodes", "used", "port", "bitmap", "which", "may", "be", "nil", "if", "no", "ports", "have", "been", "allocated", "yet", "the", "network", "ask", "and", "returns", "a", "set", "of", "unused", "ports", "to", "fullf...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L363-L391
133,308
hashicorp/nomad
nomad/structs/network.go
isPortReserved
func isPortReserved(haystack []int, needle int) bool { for _, item := range haystack { if item == needle { return true } } return false }
go
func isPortReserved(haystack []int, needle int) bool { for _, item := range haystack { if item == needle { return true } } return false }
[ "func", "isPortReserved", "(", "haystack", "[", "]", "int", ",", "needle", "int", ")", "bool", "{", "for", "_", ",", "item", ":=", "range", "haystack", "{", "if", "item", "==", "needle", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", ...
// IntContains scans an integer slice for a value
[ "IntContains", "scans", "an", "integer", "slice", "for", "a", "value" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/network.go#L394-L401
133,309
hashicorp/nomad
plugins/device/cmd/example/device.go
NewExampleDevice
func NewExampleDevice(log log.Logger) *FsDevice { return &FsDevice{ logger: log.Named(pluginName), devices: make(map[string]bool), } }
go
func NewExampleDevice(log log.Logger) *FsDevice { return &FsDevice{ logger: log.Named(pluginName), devices: make(map[string]bool), } }
[ "func", "NewExampleDevice", "(", "log", "log", ".", "Logger", ")", "*", "FsDevice", "{", "return", "&", "FsDevice", "{", "logger", ":", "log", ".", "Named", "(", "pluginName", ")", ",", "devices", ":", "make", "(", "map", "[", "string", "]", "bool", ...
// NewExampleDevice returns a new example device plugin.
[ "NewExampleDevice", "returns", "a", "new", "example", "device", "plugin", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/cmd/example/device.go#L93-L98
133,310
hashicorp/nomad
plugins/device/cmd/example/device.go
getDeviceGroup
func getDeviceGroup(devices []*device.Device) *device.DeviceGroup { return &device.DeviceGroup{ Vendor: vendor, Type: deviceType, Name: deviceName, Devices: devices, } }
go
func getDeviceGroup(devices []*device.Device) *device.DeviceGroup { return &device.DeviceGroup{ Vendor: vendor, Type: deviceType, Name: deviceName, Devices: devices, } }
[ "func", "getDeviceGroup", "(", "devices", "[", "]", "*", "device", ".", "Device", ")", "*", "device", ".", "DeviceGroup", "{", "return", "&", "device", ".", "DeviceGroup", "{", "Vendor", ":", "vendor", ",", "Type", ":", "deviceType", ",", "Name", ":", ...
// getDeviceGroup is a helper to build the DeviceGroup given a set of devices.
[ "getDeviceGroup", "is", "a", "helper", "to", "build", "the", "DeviceGroup", "given", "a", "set", "of", "devices", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/cmd/example/device.go#L243-L250
133,311
hashicorp/nomad
plugins/device/cmd/example/device.go
Reserve
func (d *FsDevice) Reserve(deviceIDs []string) (*device.ContainerReservation, error) { if len(deviceIDs) == 0 { return nil, status.New(codes.InvalidArgument, "no device ids given").Err() } deviceDir, err := filepath.Abs(d.deviceDir) if err != nil { return nil, status.Newf(codes.Internal, "failed to load device...
go
func (d *FsDevice) Reserve(deviceIDs []string) (*device.ContainerReservation, error) { if len(deviceIDs) == 0 { return nil, status.New(codes.InvalidArgument, "no device ids given").Err() } deviceDir, err := filepath.Abs(d.deviceDir) if err != nil { return nil, status.Newf(codes.Internal, "failed to load device...
[ "func", "(", "d", "*", "FsDevice", ")", "Reserve", "(", "deviceIDs", "[", "]", "string", ")", "(", "*", "device", ".", "ContainerReservation", ",", "error", ")", "{", "if", "len", "(", "deviceIDs", ")", "==", "0", "{", "return", "nil", ",", "status",...
// Reserve returns information on how to mount the given devices.
[ "Reserve", "returns", "information", "on", "how", "to", "mount", "the", "given", "devices", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/cmd/example/device.go#L253-L280
133,312
hashicorp/nomad
acl/acl.go
maxPrivilege
func maxPrivilege(a, b string) string { switch { case a == PolicyDeny || b == PolicyDeny: return PolicyDeny case a == PolicyWrite || b == PolicyWrite: return PolicyWrite case a == PolicyRead || b == PolicyRead: return PolicyRead default: return "" } }
go
func maxPrivilege(a, b string) string { switch { case a == PolicyDeny || b == PolicyDeny: return PolicyDeny case a == PolicyWrite || b == PolicyWrite: return PolicyWrite case a == PolicyRead || b == PolicyRead: return PolicyRead default: return "" } }
[ "func", "maxPrivilege", "(", "a", ",", "b", "string", ")", "string", "{", "switch", "{", "case", "a", "==", "PolicyDeny", "||", "b", "==", "PolicyDeny", ":", "return", "PolicyDeny", "\n", "case", "a", "==", "PolicyWrite", "||", "b", "==", "PolicyWrite", ...
// maxPrivilege returns the policy which grants the most privilege // This handles the case of Deny always taking maximum precedence.
[ "maxPrivilege", "returns", "the", "policy", "which", "grants", "the", "most", "privilege", "This", "handles", "the", "case", "of", "Deny", "always", "taking", "maximum", "precedence", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L62-L73
133,313
hashicorp/nomad
acl/acl.go
NewACL
func NewACL(management bool, policies []*Policy) (*ACL, error) { // Hot-path management tokens if management { return &ACL{management: true}, nil } // Create the ACL object acl := &ACL{} nsTxn := iradix.New().Txn() wnsTxn := iradix.New().Txn() for _, policy := range policies { NAMESPACES: for _, ns := ra...
go
func NewACL(management bool, policies []*Policy) (*ACL, error) { // Hot-path management tokens if management { return &ACL{management: true}, nil } // Create the ACL object acl := &ACL{} nsTxn := iradix.New().Txn() wnsTxn := iradix.New().Txn() for _, policy := range policies { NAMESPACES: for _, ns := ra...
[ "func", "NewACL", "(", "management", "bool", ",", "policies", "[", "]", "*", "Policy", ")", "(", "*", "ACL", ",", "error", ")", "{", "// Hot-path management tokens", "if", "management", "{", "return", "&", "ACL", "{", "management", ":", "true", "}", ",",...
// NewACL compiles a set of policies into an ACL object
[ "NewACL", "compiles", "a", "set", "of", "policies", "into", "an", "ACL", "object" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L76-L150
133,314
hashicorp/nomad
acl/acl.go
AllowNsOp
func (a *ACL) AllowNsOp(ns string, op string) bool { return a.AllowNamespaceOperation(ns, op) }
go
func (a *ACL) AllowNsOp(ns string, op string) bool { return a.AllowNamespaceOperation(ns, op) }
[ "func", "(", "a", "*", "ACL", ")", "AllowNsOp", "(", "ns", "string", ",", "op", "string", ")", "bool", "{", "return", "a", ".", "AllowNamespaceOperation", "(", "ns", ",", "op", ")", "\n", "}" ]
// AllowNsOp is shorthand for AllowNamespaceOperation
[ "AllowNsOp", "is", "shorthand", "for", "AllowNamespaceOperation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L153-L155
133,315
hashicorp/nomad
acl/acl.go
AllowNamespaceOperation
func (a *ACL) AllowNamespaceOperation(ns string, op string) bool { // Hot path management tokens if a.management { return true } // Check for a matching capability set capabilities, ok := a.matchingCapabilitySet(ns) if !ok { return false } // Check if the capability has been granted return capabilities.C...
go
func (a *ACL) AllowNamespaceOperation(ns string, op string) bool { // Hot path management tokens if a.management { return true } // Check for a matching capability set capabilities, ok := a.matchingCapabilitySet(ns) if !ok { return false } // Check if the capability has been granted return capabilities.C...
[ "func", "(", "a", "*", "ACL", ")", "AllowNamespaceOperation", "(", "ns", "string", ",", "op", "string", ")", "bool", "{", "// Hot path management tokens", "if", "a", ".", "management", "{", "return", "true", "\n", "}", "\n\n", "// Check for a matching capability...
// AllowNamespaceOperation checks if a given operation is allowed for a namespace
[ "AllowNamespaceOperation", "checks", "if", "a", "given", "operation", "is", "allowed", "for", "a", "namespace" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L158-L172
133,316
hashicorp/nomad
acl/acl.go
AllowNamespace
func (a *ACL) AllowNamespace(ns string) bool { // Hot path management tokens if a.management { return true } // Check for a matching capability set capabilities, ok := a.matchingCapabilitySet(ns) if !ok { return false } // Check if the capability has been granted if len(capabilities) == 0 { return fals...
go
func (a *ACL) AllowNamespace(ns string) bool { // Hot path management tokens if a.management { return true } // Check for a matching capability set capabilities, ok := a.matchingCapabilitySet(ns) if !ok { return false } // Check if the capability has been granted if len(capabilities) == 0 { return fals...
[ "func", "(", "a", "*", "ACL", ")", "AllowNamespace", "(", "ns", "string", ")", "bool", "{", "// Hot path management tokens", "if", "a", ".", "management", "{", "return", "true", "\n", "}", "\n\n", "// Check for a matching capability set", "capabilities", ",", "o...
// AllowNamespace checks if any operations are allowed for a namespace
[ "AllowNamespace", "checks", "if", "any", "operations", "are", "allowed", "for", "a", "namespace" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L175-L193
133,317
hashicorp/nomad
acl/acl.go
matchingCapabilitySet
func (a *ACL) matchingCapabilitySet(ns string) (capabilitySet, bool) { // Check for a concrete matching capability set raw, ok := a.namespaces.Get([]byte(ns)) if ok { return raw.(capabilitySet), true } // We didn't find a concrete match, so lets try and evaluate globs. return a.findClosestMatchingGlob(ns) }
go
func (a *ACL) matchingCapabilitySet(ns string) (capabilitySet, bool) { // Check for a concrete matching capability set raw, ok := a.namespaces.Get([]byte(ns)) if ok { return raw.(capabilitySet), true } // We didn't find a concrete match, so lets try and evaluate globs. return a.findClosestMatchingGlob(ns) }
[ "func", "(", "a", "*", "ACL", ")", "matchingCapabilitySet", "(", "ns", "string", ")", "(", "capabilitySet", ",", "bool", ")", "{", "// Check for a concrete matching capability set", "raw", ",", "ok", ":=", "a", ".", "namespaces", ".", "Get", "(", "[", "]", ...
// matchingCapabilitySet looks for a capabilitySet that matches the namespace, // if no concrete definitions are found, then we return the closest matching // glob. // The closest matching glob is the one that has the smallest character // difference between the namespace and the glob.
[ "matchingCapabilitySet", "looks", "for", "a", "capabilitySet", "that", "matches", "the", "namespace", "if", "no", "concrete", "definitions", "are", "found", "then", "we", "return", "the", "closest", "matching", "glob", ".", "The", "closest", "matching", "glob", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L200-L209
133,318
hashicorp/nomad
acl/acl.go
AllowAgentRead
func (a *ACL) AllowAgentRead() bool { switch { case a.management: return true case a.agent == PolicyWrite: return true case a.agent == PolicyRead: return true default: return false } }
go
func (a *ACL) AllowAgentRead() bool { switch { case a.management: return true case a.agent == PolicyWrite: return true case a.agent == PolicyRead: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowAgentRead", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "agent", "==", "PolicyWrite", ":", "return", "true", "\n", "case", "a", ".", "...
// AllowAgentRead checks if read operations are allowed for an agent
[ "AllowAgentRead", "checks", "if", "read", "operations", "are", "allowed", "for", "an", "agent" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L268-L279
133,319
hashicorp/nomad
acl/acl.go
AllowAgentWrite
func (a *ACL) AllowAgentWrite() bool { switch { case a.management: return true case a.agent == PolicyWrite: return true default: return false } }
go
func (a *ACL) AllowAgentWrite() bool { switch { case a.management: return true case a.agent == PolicyWrite: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowAgentWrite", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "agent", "==", "PolicyWrite", ":", "return", "true", "\n", "default", ":", "ret...
// AllowAgentWrite checks if write operations are allowed for an agent
[ "AllowAgentWrite", "checks", "if", "write", "operations", "are", "allowed", "for", "an", "agent" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L282-L291
133,320
hashicorp/nomad
acl/acl.go
AllowNodeRead
func (a *ACL) AllowNodeRead() bool { switch { case a.management: return true case a.node == PolicyWrite: return true case a.node == PolicyRead: return true default: return false } }
go
func (a *ACL) AllowNodeRead() bool { switch { case a.management: return true case a.node == PolicyWrite: return true case a.node == PolicyRead: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowNodeRead", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "node", "==", "PolicyWrite", ":", "return", "true", "\n", "case", "a", ".", "no...
// AllowNodeRead checks if read operations are allowed for a node
[ "AllowNodeRead", "checks", "if", "read", "operations", "are", "allowed", "for", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L294-L305
133,321
hashicorp/nomad
acl/acl.go
AllowNodeWrite
func (a *ACL) AllowNodeWrite() bool { switch { case a.management: return true case a.node == PolicyWrite: return true default: return false } }
go
func (a *ACL) AllowNodeWrite() bool { switch { case a.management: return true case a.node == PolicyWrite: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowNodeWrite", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "node", "==", "PolicyWrite", ":", "return", "true", "\n", "default", ":", "retur...
// AllowNodeWrite checks if write operations are allowed for a node
[ "AllowNodeWrite", "checks", "if", "write", "operations", "are", "allowed", "for", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L308-L317
133,322
hashicorp/nomad
acl/acl.go
AllowOperatorRead
func (a *ACL) AllowOperatorRead() bool { switch { case a.management: return true case a.operator == PolicyWrite: return true case a.operator == PolicyRead: return true default: return false } }
go
func (a *ACL) AllowOperatorRead() bool { switch { case a.management: return true case a.operator == PolicyWrite: return true case a.operator == PolicyRead: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowOperatorRead", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "operator", "==", "PolicyWrite", ":", "return", "true", "\n", "case", "a", "....
// AllowOperatorRead checks if read operations are allowed for a operator
[ "AllowOperatorRead", "checks", "if", "read", "operations", "are", "allowed", "for", "a", "operator" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L320-L331
133,323
hashicorp/nomad
acl/acl.go
AllowOperatorWrite
func (a *ACL) AllowOperatorWrite() bool { switch { case a.management: return true case a.operator == PolicyWrite: return true default: return false } }
go
func (a *ACL) AllowOperatorWrite() bool { switch { case a.management: return true case a.operator == PolicyWrite: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowOperatorWrite", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "operator", "==", "PolicyWrite", ":", "return", "true", "\n", "default", ":", ...
// AllowOperatorWrite checks if write operations are allowed for a operator
[ "AllowOperatorWrite", "checks", "if", "write", "operations", "are", "allowed", "for", "a", "operator" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L334-L343
133,324
hashicorp/nomad
acl/acl.go
AllowQuotaRead
func (a *ACL) AllowQuotaRead() bool { switch { case a.management: return true case a.quota == PolicyWrite: return true case a.quota == PolicyRead: return true default: return false } }
go
func (a *ACL) AllowQuotaRead() bool { switch { case a.management: return true case a.quota == PolicyWrite: return true case a.quota == PolicyRead: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowQuotaRead", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "quota", "==", "PolicyWrite", ":", "return", "true", "\n", "case", "a", ".", "...
// AllowQuotaRead checks if read operations are allowed for all quotas
[ "AllowQuotaRead", "checks", "if", "read", "operations", "are", "allowed", "for", "all", "quotas" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L346-L357
133,325
hashicorp/nomad
acl/acl.go
AllowQuotaWrite
func (a *ACL) AllowQuotaWrite() bool { switch { case a.management: return true case a.quota == PolicyWrite: return true default: return false } }
go
func (a *ACL) AllowQuotaWrite() bool { switch { case a.management: return true case a.quota == PolicyWrite: return true default: return false } }
[ "func", "(", "a", "*", "ACL", ")", "AllowQuotaWrite", "(", ")", "bool", "{", "switch", "{", "case", "a", ".", "management", ":", "return", "true", "\n", "case", "a", ".", "quota", "==", "PolicyWrite", ":", "return", "true", "\n", "default", ":", "ret...
// AllowQuotaWrite checks if write operations are allowed for quotas
[ "AllowQuotaWrite", "checks", "if", "write", "operations", "are", "allowed", "for", "quotas" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/acl.go#L360-L369
133,326
hashicorp/nomad
nomad/timetable.go
Serialize
func (t *TimeTable) Serialize(enc *codec.Encoder) error { t.l.RLock() defer t.l.RUnlock() return enc.Encode(t.table) }
go
func (t *TimeTable) Serialize(enc *codec.Encoder) error { t.l.RLock() defer t.l.RUnlock() return enc.Encode(t.table) }
[ "func", "(", "t", "*", "TimeTable", ")", "Serialize", "(", "enc", "*", "codec", ".", "Encoder", ")", "error", "{", "t", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "l", ".", "RUnlock", "(", ")", "\n", "return", "enc", ".", "Encod...
// Serialize is used to serialize the time table
[ "Serialize", "is", "used", "to", "serialize", "the", "time", "table" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/timetable.go#L44-L48
133,327
hashicorp/nomad
nomad/timetable.go
Deserialize
func (t *TimeTable) Deserialize(dec *codec.Decoder) error { // Decode the table var table []TimeTableEntry if err := dec.Decode(&table); err != nil { return err } // Witness from oldest to newest n := len(table) for i := n - 1; i >= 0; i-- { t.Witness(table[i].Index, table[i].Time) } return nil }
go
func (t *TimeTable) Deserialize(dec *codec.Decoder) error { // Decode the table var table []TimeTableEntry if err := dec.Decode(&table); err != nil { return err } // Witness from oldest to newest n := len(table) for i := n - 1; i >= 0; i-- { t.Witness(table[i].Index, table[i].Time) } return nil }
[ "func", "(", "t", "*", "TimeTable", ")", "Deserialize", "(", "dec", "*", "codec", ".", "Decoder", ")", "error", "{", "// Decode the table", "var", "table", "[", "]", "TimeTableEntry", "\n", "if", "err", ":=", "dec", ".", "Decode", "(", "&", "table", ")...
// Deserialize is used to deserialize the time table // and restore the state
[ "Deserialize", "is", "used", "to", "deserialize", "the", "time", "table", "and", "restore", "the", "state" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/timetable.go#L52-L65
133,328
hashicorp/nomad
nomad/timetable.go
Witness
func (t *TimeTable) Witness(index uint64, when time.Time) { t.l.Lock() defer t.l.Unlock() // Ensure monotonic indexes if t.table[0].Index > index { return } // Skip if we already have a recent enough entry if when.Sub(t.table[0].Time) < t.granularity { return } // Grow the table if we haven't reached th...
go
func (t *TimeTable) Witness(index uint64, when time.Time) { t.l.Lock() defer t.l.Unlock() // Ensure monotonic indexes if t.table[0].Index > index { return } // Skip if we already have a recent enough entry if when.Sub(t.table[0].Time) < t.granularity { return } // Grow the table if we haven't reached th...
[ "func", "(", "t", "*", "TimeTable", ")", "Witness", "(", "index", "uint64", ",", "when", "time", ".", "Time", ")", "{", "t", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "l", ".", "Unlock", "(", ")", "\n\n", "// Ensure monotonic indexe...
// Witness is used to witness a new index and time.
[ "Witness", "is", "used", "to", "witness", "a", "new", "index", "and", "time", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/timetable.go#L68-L91
133,329
hashicorp/nomad
nomad/timetable.go
NearestIndex
func (t *TimeTable) NearestIndex(when time.Time) uint64 { t.l.RLock() defer t.l.RUnlock() n := len(t.table) idx := sort.Search(n, func(i int) bool { return !t.table[i].Time.After(when) }) if idx < n && idx >= 0 { return t.table[idx].Index } return 0 }
go
func (t *TimeTable) NearestIndex(when time.Time) uint64 { t.l.RLock() defer t.l.RUnlock() n := len(t.table) idx := sort.Search(n, func(i int) bool { return !t.table[i].Time.After(when) }) if idx < n && idx >= 0 { return t.table[idx].Index } return 0 }
[ "func", "(", "t", "*", "TimeTable", ")", "NearestIndex", "(", "when", "time", ".", "Time", ")", "uint64", "{", "t", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "l", ".", "RUnlock", "(", ")", "\n\n", "n", ":=", "len", "(", "t", ...
// NearestIndex returns the nearest index older than the given time
[ "NearestIndex", "returns", "the", "nearest", "index", "older", "than", "the", "given", "time" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/timetable.go#L94-L106
133,330
hashicorp/nomad
nomad/timetable.go
NearestTime
func (t *TimeTable) NearestTime(index uint64) time.Time { t.l.RLock() defer t.l.RUnlock() n := len(t.table) idx := sort.Search(n, func(i int) bool { return t.table[i].Index <= index }) if idx < n && idx >= 0 { return t.table[idx].Time } return time.Time{} }
go
func (t *TimeTable) NearestTime(index uint64) time.Time { t.l.RLock() defer t.l.RUnlock() n := len(t.table) idx := sort.Search(n, func(i int) bool { return t.table[i].Index <= index }) if idx < n && idx >= 0 { return t.table[idx].Time } return time.Time{} }
[ "func", "(", "t", "*", "TimeTable", ")", "NearestTime", "(", "index", "uint64", ")", "time", ".", "Time", "{", "t", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "l", ".", "RUnlock", "(", ")", "\n\n", "n", ":=", "len", "(", "t", ...
// NearestTime returns the nearest time older than the given index
[ "NearestTime", "returns", "the", "nearest", "time", "older", "than", "the", "given", "index" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/timetable.go#L109-L121
133,331
hashicorp/nomad
client/allocrunner/taskrunner/lazy_handle.go
NewLazyHandle
func NewLazyHandle(shutdownCtx context.Context, fn retrieveHandleFn, logger log.Logger) *LazyHandle { return &LazyHandle{ retrieveHandle: fn, h: fn(), shutdownCtx: shutdownCtx, logger: logger.Named("lazy_handle"), } }
go
func NewLazyHandle(shutdownCtx context.Context, fn retrieveHandleFn, logger log.Logger) *LazyHandle { return &LazyHandle{ retrieveHandle: fn, h: fn(), shutdownCtx: shutdownCtx, logger: logger.Named("lazy_handle"), } }
[ "func", "NewLazyHandle", "(", "shutdownCtx", "context", ".", "Context", ",", "fn", "retrieveHandleFn", ",", "logger", "log", ".", "Logger", ")", "*", "LazyHandle", "{", "return", "&", "LazyHandle", "{", "retrieveHandle", ":", "fn", ",", "h", ":", "fn", "("...
// NewLazyHandle takes the function to receive the latest handle and a logger // and returns a LazyHandle
[ "NewLazyHandle", "takes", "the", "function", "to", "receive", "the", "latest", "handle", "and", "a", "logger", "and", "returns", "a", "LazyHandle" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/lazy_handle.go#L52-L59
133,332
hashicorp/nomad
client/allocrunner/taskrunner/lazy_handle.go
getHandle
func (l *LazyHandle) getHandle() (*DriverHandle, error) { l.Lock() defer l.Unlock() if l.h != nil { return l.h, nil } return l.refreshHandleLocked() }
go
func (l *LazyHandle) getHandle() (*DriverHandle, error) { l.Lock() defer l.Unlock() if l.h != nil { return l.h, nil } return l.refreshHandleLocked() }
[ "func", "(", "l", "*", "LazyHandle", ")", "getHandle", "(", ")", "(", "*", "DriverHandle", ",", "error", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n\n", "if", "l", ".", "h", "!=", "nil", "{", "return",...
// getHandle returns the current handle or retrieves a new one
[ "getHandle", "returns", "the", "current", "handle", "or", "retrieves", "a", "new", "one" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/lazy_handle.go#L62-L71
133,333
hashicorp/nomad
client/allocrunner/taskrunner/lazy_handle.go
refreshHandle
func (l *LazyHandle) refreshHandle() (*DriverHandle, error) { l.Lock() defer l.Unlock() return l.refreshHandleLocked() }
go
func (l *LazyHandle) refreshHandle() (*DriverHandle, error) { l.Lock() defer l.Unlock() return l.refreshHandleLocked() }
[ "func", "(", "l", "*", "LazyHandle", ")", "refreshHandle", "(", ")", "(", "*", "DriverHandle", ",", "error", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "return", "l", ".", "refreshHandleLocked", "(", ")...
// refreshHandle retrieves a new handle
[ "refreshHandle", "retrieves", "a", "new", "handle" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/lazy_handle.go#L74-L78
133,334
hashicorp/nomad
client/allocrunner/taskrunner/lazy_handle.go
refreshHandleLocked
func (l *LazyHandle) refreshHandleLocked() (*DriverHandle, error) { for i := 0; i < retrieveFailureLimit; i++ { l.h = l.retrieveHandle() if l.h != nil { return l.h, nil } // Calculate the new backoff backoff := (1 << (2 * uint64(i))) * retrieveBackoffBaseline if backoff > retrieveBackoffLimit { back...
go
func (l *LazyHandle) refreshHandleLocked() (*DriverHandle, error) { for i := 0; i < retrieveFailureLimit; i++ { l.h = l.retrieveHandle() if l.h != nil { return l.h, nil } // Calculate the new backoff backoff := (1 << (2 * uint64(i))) * retrieveBackoffBaseline if backoff > retrieveBackoffLimit { back...
[ "func", "(", "l", "*", "LazyHandle", ")", "refreshHandleLocked", "(", ")", "(", "*", "DriverHandle", ",", "error", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "retrieveFailureLimit", ";", "i", "++", "{", "l", ".", "h", "=", "l", ".", "retrieveH...
// refreshHandleLocked retrieves a new handle and should be called with the lock // held. It will retry to give the client time to restart the driver and restore // the handle.
[ "refreshHandleLocked", "retrieves", "a", "new", "handle", "and", "should", "be", "called", "with", "the", "lock", "held", ".", "It", "will", "retry", "to", "give", "the", "client", "time", "to", "restart", "the", "driver", "and", "restore", "the", "handle", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/lazy_handle.go#L83-L106
133,335
hashicorp/nomad
scheduler/system_sched.go
NewSystemScheduler
func NewSystemScheduler(logger log.Logger, state State, planner Planner) Scheduler { return &SystemScheduler{ logger: logger.Named("system_sched"), state: state, planner: planner, } }
go
func NewSystemScheduler(logger log.Logger, state State, planner Planner) Scheduler { return &SystemScheduler{ logger: logger.Named("system_sched"), state: state, planner: planner, } }
[ "func", "NewSystemScheduler", "(", "logger", "log", ".", "Logger", ",", "state", "State", ",", "planner", "Planner", ")", "Scheduler", "{", "return", "&", "SystemScheduler", "{", "logger", ":", "logger", ".", "Named", "(", "\"", "\"", ")", ",", "state", ...
// NewSystemScheduler is a factory function to instantiate a new system // scheduler.
[ "NewSystemScheduler", "is", "a", "factory", "function", "to", "instantiate", "a", "new", "system", "scheduler", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/system_sched.go#L44-L50
133,336
hashicorp/nomad
scheduler/system_sched.go
Process
func (s *SystemScheduler) Process(eval *structs.Evaluation) error { // Store the evaluation s.eval = eval // Update our logger with the eval's information s.logger = s.logger.With("eval_id", eval.ID, "job_id", eval.JobID, "namespace", eval.Namespace) // Verify the evaluation trigger reason is understood switch ...
go
func (s *SystemScheduler) Process(eval *structs.Evaluation) error { // Store the evaluation s.eval = eval // Update our logger with the eval's information s.logger = s.logger.With("eval_id", eval.ID, "job_id", eval.JobID, "namespace", eval.Namespace) // Verify the evaluation trigger reason is understood switch ...
[ "func", "(", "s", "*", "SystemScheduler", ")", "Process", "(", "eval", "*", "structs", ".", "Evaluation", ")", "error", "{", "// Store the evaluation", "s", ".", "eval", "=", "eval", "\n\n", "// Update our logger with the eval's information", "s", ".", "logger", ...
// Process is used to handle a single evaluation.
[ "Process", "is", "used", "to", "handle", "a", "single", "evaluation", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/system_sched.go#L53-L85
133,337
hashicorp/nomad
client/fingerprint/fingerprint.go
BuiltinFingerprints
func BuiltinFingerprints() []string { fingerprints := make([]string, 0, len(hostFingerprinters)) for k := range hostFingerprinters { fingerprints = append(fingerprints, k) } sort.Strings(fingerprints) for k := range envFingerprinters { fingerprints = append(fingerprints, k) } return fingerprints }
go
func BuiltinFingerprints() []string { fingerprints := make([]string, 0, len(hostFingerprinters)) for k := range hostFingerprinters { fingerprints = append(fingerprints, k) } sort.Strings(fingerprints) for k := range envFingerprinters { fingerprints = append(fingerprints, k) } return fingerprints }
[ "func", "BuiltinFingerprints", "(", ")", "[", "]", "string", "{", "fingerprints", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "hostFingerprinters", ")", ")", "\n", "for", "k", ":=", "range", "hostFingerprinters", "{", "fingerprints", ...
// BuiltinFingerprints is a slice containing the key names of all registered // fingerprints available. The order of this slice should be preserved when // fingerprinting.
[ "BuiltinFingerprints", "is", "a", "slice", "containing", "the", "key", "names", "of", "all", "registered", "fingerprints", "available", ".", "The", "order", "of", "this", "slice", "should", "be", "preserved", "when", "fingerprinting", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/fingerprint.go#L56-L66
133,338
hashicorp/nomad
client/fingerprint/fingerprint.go
NewFingerprint
func NewFingerprint(name string, logger log.Logger) (Fingerprint, error) { // Lookup the factory function factory, ok := hostFingerprinters[name] if !ok { factory, ok = envFingerprinters[name] if !ok { return nil, fmt.Errorf("unknown fingerprint '%s'", name) } } // Instantiate the fingerprint f := facto...
go
func NewFingerprint(name string, logger log.Logger) (Fingerprint, error) { // Lookup the factory function factory, ok := hostFingerprinters[name] if !ok { factory, ok = envFingerprinters[name] if !ok { return nil, fmt.Errorf("unknown fingerprint '%s'", name) } } // Instantiate the fingerprint f := facto...
[ "func", "NewFingerprint", "(", "name", "string", ",", "logger", "log", ".", "Logger", ")", "(", "Fingerprint", ",", "error", ")", "{", "// Lookup the factory function", "factory", ",", "ok", ":=", "hostFingerprinters", "[", "name", "]", "\n", "if", "!", "ok"...
// NewFingerprint is used to instantiate and return a new fingerprint // given the name and a logger
[ "NewFingerprint", "is", "used", "to", "instantiate", "and", "return", "a", "new", "fingerprint", "given", "the", "name", "and", "a", "logger" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/fingerprint.go#L70-L83
133,339
hashicorp/nomad
command/alloc_logs.go
followFile
func (l *AllocLogsCommand) followFile(client *api.Client, alloc *api.Allocation, follow bool, task, logType, origin string, offset int64) (io.ReadCloser, error) { cancel := make(chan struct{}) frames, errCh := client.AllocFS().Logs(alloc, follow, task, logType, origin, offset, cancel, nil) select { case err := <-...
go
func (l *AllocLogsCommand) followFile(client *api.Client, alloc *api.Allocation, follow bool, task, logType, origin string, offset int64) (io.ReadCloser, error) { cancel := make(chan struct{}) frames, errCh := client.AllocFS().Logs(alloc, follow, task, logType, origin, offset, cancel, nil) select { case err := <-...
[ "func", "(", "l", "*", "AllocLogsCommand", ")", "followFile", "(", "client", "*", "api", ".", "Client", ",", "alloc", "*", "api", ".", "Allocation", ",", "follow", "bool", ",", "task", ",", "logType", ",", "origin", "string", ",", "offset", "int64", ")...
// followFile outputs the contents of the file to stdout relative to the end of // the file.
[ "followFile", "outputs", "the", "contents", "of", "the", "file", "to", "stdout", "relative", "to", "the", "end", "of", "the", "file", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_logs.go#L269-L296
133,340
hashicorp/nomad
acl/policy.go
IsEmpty
func (p *Policy) IsEmpty() bool { return len(p.Namespaces) == 0 && p.Agent == nil && p.Node == nil && p.Operator == nil && p.Quota == nil }
go
func (p *Policy) IsEmpty() bool { return len(p.Namespaces) == 0 && p.Agent == nil && p.Node == nil && p.Operator == nil && p.Quota == nil }
[ "func", "(", "p", "*", "Policy", ")", "IsEmpty", "(", ")", "bool", "{", "return", "len", "(", "p", ".", "Namespaces", ")", "==", "0", "&&", "p", ".", "Agent", "==", "nil", "&&", "p", ".", "Node", "==", "nil", "&&", "p", ".", "Operator", "==", ...
// IsEmpty checks to make sure that at least one policy has been set and is not // comprised of only a raw policy.
[ "IsEmpty", "checks", "to", "make", "sure", "that", "at", "least", "one", "policy", "has", "been", "set", "and", "is", "not", "comprised", "of", "only", "a", "raw", "policy", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/policy.go#L51-L57
133,341
hashicorp/nomad
acl/policy.go
isNamespaceCapabilityValid
func isNamespaceCapabilityValid(cap string) bool { switch cap { case NamespaceCapabilityDeny, NamespaceCapabilityListJobs, NamespaceCapabilityReadJob, NamespaceCapabilitySubmitJob, NamespaceCapabilityDispatchJob, NamespaceCapabilityReadLogs, NamespaceCapabilityReadFS, NamespaceCapabilityAllocLifecycle: return t...
go
func isNamespaceCapabilityValid(cap string) bool { switch cap { case NamespaceCapabilityDeny, NamespaceCapabilityListJobs, NamespaceCapabilityReadJob, NamespaceCapabilitySubmitJob, NamespaceCapabilityDispatchJob, NamespaceCapabilityReadLogs, NamespaceCapabilityReadFS, NamespaceCapabilityAllocLifecycle: return t...
[ "func", "isNamespaceCapabilityValid", "(", "cap", "string", ")", "bool", "{", "switch", "cap", "{", "case", "NamespaceCapabilityDeny", ",", "NamespaceCapabilityListJobs", ",", "NamespaceCapabilityReadJob", ",", "NamespaceCapabilitySubmitJob", ",", "NamespaceCapabilityDispatch...
// isNamespaceCapabilityValid ensures the given capability is valid for a namespace policy
[ "isNamespaceCapabilityValid", "ensures", "the", "given", "capability", "is", "valid", "for", "a", "namespace", "policy" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/policy.go#L93-L105
133,342
hashicorp/nomad
acl/policy.go
expandNamespacePolicy
func expandNamespacePolicy(policy string) []string { switch policy { case PolicyDeny: return []string{NamespaceCapabilityDeny} case PolicyRead: return []string{ NamespaceCapabilityListJobs, NamespaceCapabilityReadJob, } case PolicyWrite: return []string{ NamespaceCapabilityListJobs, NamespaceCap...
go
func expandNamespacePolicy(policy string) []string { switch policy { case PolicyDeny: return []string{NamespaceCapabilityDeny} case PolicyRead: return []string{ NamespaceCapabilityListJobs, NamespaceCapabilityReadJob, } case PolicyWrite: return []string{ NamespaceCapabilityListJobs, NamespaceCap...
[ "func", "expandNamespacePolicy", "(", "policy", "string", ")", "[", "]", "string", "{", "switch", "policy", "{", "case", "PolicyDeny", ":", "return", "[", "]", "string", "{", "NamespaceCapabilityDeny", "}", "\n", "case", "PolicyRead", ":", "return", "[", "]"...
// expandNamespacePolicy provides the equivalent set of capabilities for // a namespace policy
[ "expandNamespacePolicy", "provides", "the", "equivalent", "set", "of", "capabilities", "for", "a", "namespace", "policy" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/policy.go#L109-L131
133,343
hashicorp/nomad
acl/policy.go
Parse
func Parse(rules string) (*Policy, error) { // Decode the rules p := &Policy{Raw: rules} if rules == "" { // Hot path for empty rules return p, nil } // Attempt to parse if err := hcl.Decode(p, rules); err != nil { return nil, fmt.Errorf("Failed to parse ACL Policy: %v", err) } // At least one valid pol...
go
func Parse(rules string) (*Policy, error) { // Decode the rules p := &Policy{Raw: rules} if rules == "" { // Hot path for empty rules return p, nil } // Attempt to parse if err := hcl.Decode(p, rules); err != nil { return nil, fmt.Errorf("Failed to parse ACL Policy: %v", err) } // At least one valid pol...
[ "func", "Parse", "(", "rules", "string", ")", "(", "*", "Policy", ",", "error", ")", "{", "// Decode the rules", "p", ":=", "&", "Policy", "{", "Raw", ":", "rules", "}", "\n", "if", "rules", "==", "\"", "\"", "{", "// Hot path for empty rules", "return",...
// Parse is used to parse the specified ACL rules into an // intermediary set of policies, before being compiled into // the ACL
[ "Parse", "is", "used", "to", "parse", "the", "specified", "ACL", "rules", "into", "an", "intermediary", "set", "of", "policies", "before", "being", "compiled", "into", "the", "ACL" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/acl/policy.go#L136-L193
133,344
hashicorp/nomad
nomad/drainer_shims.go
convertApplyErrors
func (d drainerShim) convertApplyErrors(applyResp interface{}, index uint64, err error) (uint64, error) { if applyResp != nil { if fsmErr, ok := applyResp.(error); ok && fsmErr != nil { return index, fsmErr } } return index, err }
go
func (d drainerShim) convertApplyErrors(applyResp interface{}, index uint64, err error) (uint64, error) { if applyResp != nil { if fsmErr, ok := applyResp.(error); ok && fsmErr != nil { return index, fsmErr } } return index, err }
[ "func", "(", "d", "drainerShim", ")", "convertApplyErrors", "(", "applyResp", "interface", "{", "}", ",", "index", "uint64", ",", "err", "error", ")", "(", "uint64", ",", "error", ")", "{", "if", "applyResp", "!=", "nil", "{", "if", "fsmErr", ",", "ok"...
// convertApplyErrors parses the results of a raftApply and returns the index at // which it was applied and any error that occurred. Raft Apply returns two // separate errors, Raft library errors and user returned errors from the FSM. // This helper, joins the errors by inspecting the applyResponse for an error.
[ "convertApplyErrors", "parses", "the", "results", "of", "a", "raftApply", "and", "returns", "the", "index", "at", "which", "it", "was", "applied", "and", "any", "error", "that", "occurred", ".", "Raft", "Apply", "returns", "two", "separate", "errors", "Raft", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer_shims.go#L44-L51
133,345
hashicorp/nomad
command/agent/agent.go
NewAgent
func NewAgent(config *Config, logger log.Logger, logOutput io.Writer, inmem *metrics.InmemSink) (*Agent, error) { a := &Agent{ config: config, logOutput: logOutput, shutdownCh: make(chan struct{}), InmemSink: inmem, } // Create the loggers a.logger = logger a.httpLogger = a.logger.ResetNamed("http")...
go
func NewAgent(config *Config, logger log.Logger, logOutput io.Writer, inmem *metrics.InmemSink) (*Agent, error) { a := &Agent{ config: config, logOutput: logOutput, shutdownCh: make(chan struct{}), InmemSink: inmem, } // Create the loggers a.logger = logger a.httpLogger = a.logger.ResetNamed("http")...
[ "func", "NewAgent", "(", "config", "*", "Config", ",", "logger", "log", ".", "Logger", ",", "logOutput", "io", ".", "Writer", ",", "inmem", "*", "metrics", ".", "InmemSink", ")", "(", "*", "Agent", ",", "error", ")", "{", "a", ":=", "&", "Agent", "...
// NewAgent is used to create a new agent with the given configuration
[ "NewAgent", "is", "used", "to", "create", "a", "new", "agent", "with", "the", "given", "configuration" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L90-L124
133,346
hashicorp/nomad
command/agent/agent.go
serverConfig
func (a *Agent) serverConfig() (*nomad.Config, error) { c, err := convertServerConfig(a.config) if err != nil { return nil, err } a.finalizeServerConfig(c) return c, nil }
go
func (a *Agent) serverConfig() (*nomad.Config, error) { c, err := convertServerConfig(a.config) if err != nil { return nil, err } a.finalizeServerConfig(c) return c, nil }
[ "func", "(", "a", "*", "Agent", ")", "serverConfig", "(", ")", "(", "*", "nomad", ".", "Config", ",", "error", ")", "{", "c", ",", "err", ":=", "convertServerConfig", "(", "a", ".", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n...
// serverConfig is used to generate a new server configuration struct // for initializing a nomad server.
[ "serverConfig", "is", "used", "to", "generate", "a", "new", "server", "configuration", "struct", "for", "initializing", "a", "nomad", "server", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L332-L340
133,347
hashicorp/nomad
command/agent/agent.go
finalizeServerConfig
func (a *Agent) finalizeServerConfig(c *nomad.Config) { // Setup the logging c.Logger = a.logger c.LogOutput = a.logOutput // Setup the plugin loaders c.PluginLoader = a.pluginLoader c.PluginSingletonLoader = a.pluginSingletonLoader }
go
func (a *Agent) finalizeServerConfig(c *nomad.Config) { // Setup the logging c.Logger = a.logger c.LogOutput = a.logOutput // Setup the plugin loaders c.PluginLoader = a.pluginLoader c.PluginSingletonLoader = a.pluginSingletonLoader }
[ "func", "(", "a", "*", "Agent", ")", "finalizeServerConfig", "(", "c", "*", "nomad", ".", "Config", ")", "{", "// Setup the logging", "c", ".", "Logger", "=", "a", ".", "logger", "\n", "c", ".", "LogOutput", "=", "a", ".", "logOutput", "\n\n", "// Setu...
// finalizeServerConfig sets configuration fields on the server config that are // not staticly convertable and are from the agent.
[ "finalizeServerConfig", "sets", "configuration", "fields", "on", "the", "server", "config", "that", "are", "not", "staticly", "convertable", "and", "are", "from", "the", "agent", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L344-L352
133,348
hashicorp/nomad
command/agent/agent.go
clientConfig
func (a *Agent) clientConfig() (*clientconfig.Config, error) { c, err := convertClientConfig(a.config) if err != nil { return nil, err } if err := a.finalizeClientConfig(c); err != nil { return nil, err } return c, nil }
go
func (a *Agent) clientConfig() (*clientconfig.Config, error) { c, err := convertClientConfig(a.config) if err != nil { return nil, err } if err := a.finalizeClientConfig(c); err != nil { return nil, err } return c, nil }
[ "func", "(", "a", "*", "Agent", ")", "clientConfig", "(", ")", "(", "*", "clientconfig", ".", "Config", ",", "error", ")", "{", "c", ",", "err", ":=", "convertClientConfig", "(", "a", ".", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// clientConfig is used to generate a new client configuration struct for // initializing a Nomad client.
[ "clientConfig", "is", "used", "to", "generate", "a", "new", "client", "configuration", "struct", "for", "initializing", "a", "Nomad", "client", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L356-L367
133,349
hashicorp/nomad
command/agent/agent.go
finalizeClientConfig
func (a *Agent) finalizeClientConfig(c *clientconfig.Config) error { // Setup the logging c.Logger = a.logger c.LogOutput = a.logOutput // If we are running a server, append both its bind and advertise address so // we are able to at least talk to the local server even if that isn't // configured explicitly. Thi...
go
func (a *Agent) finalizeClientConfig(c *clientconfig.Config) error { // Setup the logging c.Logger = a.logger c.LogOutput = a.logOutput // If we are running a server, append both its bind and advertise address so // we are able to at least talk to the local server even if that isn't // configured explicitly. Thi...
[ "func", "(", "a", "*", "Agent", ")", "finalizeClientConfig", "(", "c", "*", "clientconfig", ".", "Config", ")", "error", "{", "// Setup the logging", "c", ".", "Logger", "=", "a", ".", "logger", "\n", "c", ".", "LogOutput", "=", "a", ".", "logOutput", ...
// finalizeClientConfig sets configuration fields on the client config that are // not staticly convertable and are from the agent.
[ "finalizeClientConfig", "sets", "configuration", "fields", "on", "the", "client", "config", "that", "are", "not", "staticly", "convertable", "and", "are", "from", "the", "agent", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L371-L412
133,350
hashicorp/nomad
command/agent/agent.go
setupServer
func (a *Agent) setupServer() error { if !a.config.Server.Enabled { return nil } // Setup the configuration conf, err := a.serverConfig() if err != nil { return fmt.Errorf("server config setup failed: %s", err) } // Generate a node ID and persist it if it is the first instance, otherwise // read the persi...
go
func (a *Agent) setupServer() error { if !a.config.Server.Enabled { return nil } // Setup the configuration conf, err := a.serverConfig() if err != nil { return fmt.Errorf("server config setup failed: %s", err) } // Generate a node ID and persist it if it is the first instance, otherwise // read the persi...
[ "func", "(", "a", "*", "Agent", ")", "setupServer", "(", ")", "error", "{", "if", "!", "a", ".", "config", ".", "Server", ".", "Enabled", "{", "return", "nil", "\n", "}", "\n\n", "// Setup the configuration", "conf", ",", "err", ":=", "a", ".", "serv...
// setupServer is used to setup the server if enabled
[ "setupServer", "is", "used", "to", "setup", "the", "server", "if", "enabled" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L537-L626
133,351
hashicorp/nomad
command/agent/agent.go
setupKeyrings
func (a *Agent) setupKeyrings(config *nomad.Config) error { file := filepath.Join(a.config.DataDir, serfKeyring) if a.config.Server.EncryptKey == "" { goto LOAD } if _, err := os.Stat(file); err != nil { if err := initKeyring(file, a.config.Server.EncryptKey); err != nil { return err } } LOAD: if _, er...
go
func (a *Agent) setupKeyrings(config *nomad.Config) error { file := filepath.Join(a.config.DataDir, serfKeyring) if a.config.Server.EncryptKey == "" { goto LOAD } if _, err := os.Stat(file); err != nil { if err := initKeyring(file, a.config.Server.EncryptKey); err != nil { return err } } LOAD: if _, er...
[ "func", "(", "a", "*", "Agent", ")", "setupKeyrings", "(", "config", "*", "nomad", ".", "Config", ")", "error", "{", "file", ":=", "filepath", ".", "Join", "(", "a", ".", "config", ".", "DataDir", ",", "serfKeyring", ")", "\n\n", "if", "a", ".", "c...
// setupKeyrings is used to initialize and load keyrings during agent startup
[ "setupKeyrings", "is", "used", "to", "initialize", "and", "load", "keyrings", "during", "agent", "startup" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L688-L709
133,352
hashicorp/nomad
command/agent/agent.go
setupClient
func (a *Agent) setupClient() error { if !a.config.Client.Enabled { return nil } // Setup the configuration conf, err := a.clientConfig() if err != nil { return fmt.Errorf("client setup failed: %v", err) } // Reserve some ports for the plugins if we are on Windows if runtime.GOOS == "windows" { if err :...
go
func (a *Agent) setupClient() error { if !a.config.Client.Enabled { return nil } // Setup the configuration conf, err := a.clientConfig() if err != nil { return fmt.Errorf("client setup failed: %v", err) } // Reserve some ports for the plugins if we are on Windows if runtime.GOOS == "windows" { if err :...
[ "func", "(", "a", "*", "Agent", ")", "setupClient", "(", ")", "error", "{", "if", "!", "a", ".", "config", ".", "Client", ".", "Enabled", "{", "return", "nil", "\n", "}", "\n\n", "// Setup the configuration", "conf", ",", "err", ":=", "a", ".", "clie...
// setupClient is used to setup the client if enabled
[ "setupClient", "is", "used", "to", "setup", "the", "client", "if", "enabled" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L712-L756
133,353
hashicorp/nomad
command/agent/agent.go
agentHTTPCheck
func (a *Agent) agentHTTPCheck(server bool) *structs.ServiceCheck { // Resolve the http check address httpCheckAddr := a.config.normalizedAddrs.HTTP if *a.config.Consul.ChecksUseAdvertise { httpCheckAddr = a.config.AdvertiseAddrs.HTTP } check := structs.ServiceCheck{ Name: a.config.Consul.ClientHTTPCheckN...
go
func (a *Agent) agentHTTPCheck(server bool) *structs.ServiceCheck { // Resolve the http check address httpCheckAddr := a.config.normalizedAddrs.HTTP if *a.config.Consul.ChecksUseAdvertise { httpCheckAddr = a.config.AdvertiseAddrs.HTTP } check := structs.ServiceCheck{ Name: a.config.Consul.ClientHTTPCheckN...
[ "func", "(", "a", "*", "Agent", ")", "agentHTTPCheck", "(", "server", "bool", ")", "*", "structs", ".", "ServiceCheck", "{", "// Resolve the http check address", "httpCheckAddr", ":=", "a", ".", "config", ".", "normalizedAddrs", ".", "HTTP", "\n", "if", "*", ...
// agentHTTPCheck returns a health check for the agent's HTTP API if possible. // If no HTTP health check can be supported nil is returned.
[ "agentHTTPCheck", "returns", "a", "health", "check", "for", "the", "agent", "s", "HTTP", "API", "if", "possible", ".", "If", "no", "HTTP", "health", "check", "can", "be", "supported", "nil", "is", "returned", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L760-L793
133,354
hashicorp/nomad
command/agent/agent.go
reservePortsForClient
func (a *Agent) reservePortsForClient(conf *clientconfig.Config) error { if conf.Node.ReservedResources == nil { conf.Node.ReservedResources = &structs.NodeReservedResources{} } res := conf.Node.ReservedResources.Networks.ReservedHostPorts if res == "" { res = fmt.Sprintf("%d-%d", conf.ClientMinPort, conf.Clie...
go
func (a *Agent) reservePortsForClient(conf *clientconfig.Config) error { if conf.Node.ReservedResources == nil { conf.Node.ReservedResources = &structs.NodeReservedResources{} } res := conf.Node.ReservedResources.Networks.ReservedHostPorts if res == "" { res = fmt.Sprintf("%d-%d", conf.ClientMinPort, conf.Clie...
[ "func", "(", "a", "*", "Agent", ")", "reservePortsForClient", "(", "conf", "*", "clientconfig", ".", "Config", ")", "error", "{", "if", "conf", ".", "Node", ".", "ReservedResources", "==", "nil", "{", "conf", ".", "Node", ".", "ReservedResources", "=", "...
// reservePortsForClient reserves a range of ports for the client to use when // it creates various plugins for log collection, executors, drivers, etc
[ "reservePortsForClient", "reserves", "a", "range", "of", "ports", "for", "the", "client", "to", "use", "when", "it", "creates", "various", "plugins", "for", "log", "collection", "executors", "drivers", "etc" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L797-L810
133,355
hashicorp/nomad
command/agent/agent.go
findLoopbackDevice
func (a *Agent) findLoopbackDevice() (string, string, string, error) { var ifcs []net.Interface var err error ifcs, err = net.Interfaces() if err != nil { return "", "", "", err } for _, ifc := range ifcs { addrs, err := ifc.Addrs() if err != nil { return "", "", "", err } for _, addr := range addrs ...
go
func (a *Agent) findLoopbackDevice() (string, string, string, error) { var ifcs []net.Interface var err error ifcs, err = net.Interfaces() if err != nil { return "", "", "", err } for _, ifc := range ifcs { addrs, err := ifc.Addrs() if err != nil { return "", "", "", err } for _, addr := range addrs ...
[ "func", "(", "a", "*", "Agent", ")", "findLoopbackDevice", "(", ")", "(", "string", ",", "string", ",", "string", ",", "error", ")", "{", "var", "ifcs", "[", "]", "net", ".", "Interface", "\n", "var", "err", "error", "\n", "ifcs", ",", "err", "=", ...
// findLoopbackDevice iterates through all the interfaces on a machine and // returns the ip addr, mask of the loopback device
[ "findLoopbackDevice", "iterates", "through", "all", "the", "interfaces", "on", "a", "machine", "and", "returns", "the", "ip", "addr", "mask", "of", "the", "loopback", "device" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L814-L844
133,356
hashicorp/nomad
command/agent/agent.go
Leave
func (a *Agent) Leave() error { if a.client != nil { if err := a.client.Leave(); err != nil { a.logger.Error("client leave failed", "error", err) } } if a.server != nil { if err := a.server.Leave(); err != nil { a.logger.Error("server leave failed", "error", err) } } return nil }
go
func (a *Agent) Leave() error { if a.client != nil { if err := a.client.Leave(); err != nil { a.logger.Error("client leave failed", "error", err) } } if a.server != nil { if err := a.server.Leave(); err != nil { a.logger.Error("server leave failed", "error", err) } } return nil }
[ "func", "(", "a", "*", "Agent", ")", "Leave", "(", ")", "error", "{", "if", "a", ".", "client", "!=", "nil", "{", "if", "err", ":=", "a", ".", "client", ".", "Leave", "(", ")", ";", "err", "!=", "nil", "{", "a", ".", "logger", ".", "Error", ...
// Leave is used gracefully exit. Clients will inform servers // of their departure so that allocations can be rescheduled.
[ "Leave", "is", "used", "gracefully", "exit", ".", "Clients", "will", "inform", "servers", "of", "their", "departure", "so", "that", "allocations", "can", "be", "rescheduled", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L848-L860
133,357
hashicorp/nomad
command/agent/agent.go
Shutdown
func (a *Agent) Shutdown() error { a.shutdownLock.Lock() defer a.shutdownLock.Unlock() if a.shutdown { return nil } a.logger.Info("requesting shutdown") if a.client != nil { if err := a.client.Shutdown(); err != nil { a.logger.Error("client shutdown failed", "error", err) } } if a.server != nil { i...
go
func (a *Agent) Shutdown() error { a.shutdownLock.Lock() defer a.shutdownLock.Unlock() if a.shutdown { return nil } a.logger.Info("requesting shutdown") if a.client != nil { if err := a.client.Shutdown(); err != nil { a.logger.Error("client shutdown failed", "error", err) } } if a.server != nil { i...
[ "func", "(", "a", "*", "Agent", ")", "Shutdown", "(", ")", "error", "{", "a", ".", "shutdownLock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "shutdownLock", ".", "Unlock", "(", ")", "\n\n", "if", "a", ".", "shutdown", "{", "return", "nil", ...
// Shutdown is used to terminate the agent.
[ "Shutdown", "is", "used", "to", "terminate", "the", "agent", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L863-L891
133,358
hashicorp/nomad
command/agent/agent.go
RPC
func (a *Agent) RPC(method string, args interface{}, reply interface{}) error { if a.server != nil { return a.server.RPC(method, args, reply) } return a.client.RPC(method, args, reply) }
go
func (a *Agent) RPC(method string, args interface{}, reply interface{}) error { if a.server != nil { return a.server.RPC(method, args, reply) } return a.client.RPC(method, args, reply) }
[ "func", "(", "a", "*", "Agent", ")", "RPC", "(", "method", "string", ",", "args", "interface", "{", "}", ",", "reply", "interface", "{", "}", ")", "error", "{", "if", "a", ".", "server", "!=", "nil", "{", "return", "a", ".", "server", ".", "RPC",...
// RPC is used to make an RPC call to the Nomad servers
[ "RPC", "is", "used", "to", "make", "an", "RPC", "call", "to", "the", "Nomad", "servers" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L894-L899
133,359
hashicorp/nomad
command/agent/agent.go
ShouldReload
func (a *Agent) ShouldReload(newConfig *Config) (agent, http bool) { a.configLock.Lock() defer a.configLock.Unlock() isEqual, err := a.config.TLSConfig.CertificateInfoIsEqual(newConfig.TLSConfig) if err != nil { a.logger.Error("parsing TLS certificate", "error", err) return false, false } else if !isEqual { ...
go
func (a *Agent) ShouldReload(newConfig *Config) (agent, http bool) { a.configLock.Lock() defer a.configLock.Unlock() isEqual, err := a.config.TLSConfig.CertificateInfoIsEqual(newConfig.TLSConfig) if err != nil { a.logger.Error("parsing TLS certificate", "error", err) return false, false } else if !isEqual { ...
[ "func", "(", "a", "*", "Agent", ")", "ShouldReload", "(", "newConfig", "*", "Config", ")", "(", "agent", ",", "http", "bool", ")", "{", "a", ".", "configLock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "configLock", ".", "Unlock", "(", ")", ...
// ShouldReload determines if we should reload the configuration and agent // connections. If the TLS Configuration has not changed, we shouldn't reload.
[ "ShouldReload", "determines", "if", "we", "should", "reload", "the", "configuration", "and", "agent", "connections", ".", "If", "the", "TLS", "Configuration", "has", "not", "changed", "we", "shouldn", "t", "reload", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L932-L956
133,360
hashicorp/nomad
command/agent/agent.go
Reload
func (a *Agent) Reload(newConfig *Config) error { a.configLock.Lock() defer a.configLock.Unlock() if newConfig == nil || newConfig.TLSConfig == nil { return fmt.Errorf("cannot reload agent with nil configuration") } // This is just a TLS configuration reload, we don't need to refresh // existing network conne...
go
func (a *Agent) Reload(newConfig *Config) error { a.configLock.Lock() defer a.configLock.Unlock() if newConfig == nil || newConfig.TLSConfig == nil { return fmt.Errorf("cannot reload agent with nil configuration") } // This is just a TLS configuration reload, we don't need to refresh // existing network conne...
[ "func", "(", "a", "*", "Agent", ")", "Reload", "(", "newConfig", "*", "Config", ")", "error", "{", "a", ".", "configLock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "configLock", ".", "Unlock", "(", ")", "\n\n", "if", "newConfig", "==", "nil"...
// Reload handles configuration changes for the agent. Provides a method that // is easier to unit test, as this action is invoked via SIGHUP.
[ "Reload", "handles", "configuration", "changes", "for", "the", "agent", ".", "Provides", "a", "method", "that", "is", "easier", "to", "unit", "test", "as", "this", "action", "is", "invoked", "via", "SIGHUP", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L960-L999
133,361
hashicorp/nomad
command/agent/agent.go
GetConfig
func (a *Agent) GetConfig() *Config { a.configLock.Lock() defer a.configLock.Unlock() return a.config }
go
func (a *Agent) GetConfig() *Config { a.configLock.Lock() defer a.configLock.Unlock() return a.config }
[ "func", "(", "a", "*", "Agent", ")", "GetConfig", "(", ")", "*", "Config", "{", "a", ".", "configLock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "configLock", ".", "Unlock", "(", ")", "\n\n", "return", "a", ".", "config", "\n", "}" ]
// GetConfig creates a locked reference to the agent's config
[ "GetConfig", "creates", "a", "locked", "reference", "to", "the", "agent", "s", "config" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L1002-L1007
133,362
hashicorp/nomad
command/agent/agent.go
setupConsul
func (a *Agent) setupConsul(consulConfig *config.ConsulConfig) error { apiConf, err := consulConfig.ApiConfig() if err != nil { return err } client, err := api.NewClient(apiConf) if err != nil { return err } // Determine version for TLSSkipVerify // Create Consul Catalog client for service discovery. a.c...
go
func (a *Agent) setupConsul(consulConfig *config.ConsulConfig) error { apiConf, err := consulConfig.ApiConfig() if err != nil { return err } client, err := api.NewClient(apiConf) if err != nil { return err } // Determine version for TLSSkipVerify // Create Consul Catalog client for service discovery. a.c...
[ "func", "(", "a", "*", "Agent", ")", "setupConsul", "(", "consulConfig", "*", "config", ".", "ConsulConfig", ")", "error", "{", "apiConf", ",", "err", ":=", "consulConfig", ".", "ApiConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err...
// setupConsul creates the Consul client and starts its main Run loop.
[ "setupConsul", "creates", "the", "Consul", "client", "and", "starts", "its", "main", "Run", "loop", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/agent.go#L1010-L1035
133,363
hashicorp/nomad
helper/pluginutils/loader/filter_unix.go
executable
func executable(path string, f os.FileInfo) bool { return f.Mode().Perm()&0111 != 0 }
go
func executable(path string, f os.FileInfo) bool { return f.Mode().Perm()&0111 != 0 }
[ "func", "executable", "(", "path", "string", ",", "f", "os", ".", "FileInfo", ")", "bool", "{", "return", "f", ".", "Mode", "(", ")", ".", "Perm", "(", ")", "&", "0111", "!=", "0", "\n", "}" ]
// executable Checks to see if the file is executable by anyone.
[ "executable", "Checks", "to", "see", "if", "the", "file", "is", "executable", "by", "anyone", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/filter_unix.go#L8-L10
133,364
hashicorp/nomad
client/fingerprint/memory.go
NewMemoryFingerprint
func NewMemoryFingerprint(logger log.Logger) Fingerprint { f := &MemoryFingerprint{ logger: logger.Named("memory"), } return f }
go
func NewMemoryFingerprint(logger log.Logger) Fingerprint { f := &MemoryFingerprint{ logger: logger.Named("memory"), } return f }
[ "func", "NewMemoryFingerprint", "(", "logger", "log", ".", "Logger", ")", "Fingerprint", "{", "f", ":=", "&", "MemoryFingerprint", "{", "logger", ":", "logger", ".", "Named", "(", "\"", "\"", ")", ",", "}", "\n", "return", "f", "\n", "}" ]
// NewMemoryFingerprint is used to create a Memory fingerprint
[ "NewMemoryFingerprint", "is", "used", "to", "create", "a", "Memory", "fingerprint" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/memory.go#L20-L25
133,365
hashicorp/nomad
command/job_validate.go
validateLocal
func (c *JobValidateCommand) validateLocal(aj *api.Job) (*api.JobValidateResponse, error) { var out api.JobValidateResponse job := agent.ApiJobToStructJob(aj) canonicalizeWarnings := job.Canonicalize() if vErr := job.Validate(); vErr != nil { if merr, ok := vErr.(*multierror.Error); ok { for _, err := range ...
go
func (c *JobValidateCommand) validateLocal(aj *api.Job) (*api.JobValidateResponse, error) { var out api.JobValidateResponse job := agent.ApiJobToStructJob(aj) canonicalizeWarnings := job.Canonicalize() if vErr := job.Validate(); vErr != nil { if merr, ok := vErr.(*multierror.Error); ok { for _, err := range ...
[ "func", "(", "c", "*", "JobValidateCommand", ")", "validateLocal", "(", "aj", "*", "api", ".", "Job", ")", "(", "*", "api", ".", "JobValidateResponse", ",", "error", ")", "{", "var", "out", "api", ".", "JobValidateResponse", "\n\n", "job", ":=", "agent",...
// validateLocal validates without talking to a Nomad agent
[ "validateLocal", "validates", "without", "talking", "to", "a", "Nomad", "agent" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/job_validate.go#L117-L138
133,366
hashicorp/nomad
drivers/docker/driver.go
startContainer
func (d *Driver) startContainer(c *docker.Container) error { // Start a container attempted := 0 START: startErr := client.StartContainer(c.ID, c.HostConfig) if startErr == nil { return nil } d.logger.Debug("failed to start container", "container_id", c.ID, "attempt", attempted+1, "error", startErr) // If it...
go
func (d *Driver) startContainer(c *docker.Container) error { // Start a container attempted := 0 START: startErr := client.StartContainer(c.ID, c.HostConfig) if startErr == nil { return nil } d.logger.Debug("failed to start container", "container_id", c.ID, "attempt", attempted+1, "error", startErr) // If it...
[ "func", "(", "d", "*", "Driver", ")", "startContainer", "(", "c", "*", "docker", ".", "Container", ")", "error", "{", "// Start a container", "attempted", ":=", "0", "\n", "START", ":", "startErr", ":=", "client", ".", "StartContainer", "(", "c", ".", "I...
// startContainer starts the passed container. It attempts to handle any // transient Docker errors.
[ "startContainer", "starts", "the", "passed", "container", ".", "It", "attempts", "to", "handle", "any", "transient", "Docker", "errors", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L466-L488
133,367
hashicorp/nomad
drivers/docker/driver.go
createImage
func (d *Driver) createImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client) (string, error) { image := driverConfig.Image repo, tag := parseDockerImage(image) callerID := fmt.Sprintf("%s-%s", task.ID, task.Name) // We're going to check whether the image is already downloaded. If the ta...
go
func (d *Driver) createImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client) (string, error) { image := driverConfig.Image repo, tag := parseDockerImage(image) callerID := fmt.Sprintf("%s-%s", task.ID, task.Name) // We're going to check whether the image is already downloaded. If the ta...
[ "func", "(", "d", "*", "Driver", ")", "createImage", "(", "task", "*", "drivers", ".", "TaskConfig", ",", "driverConfig", "*", "TaskConfig", ",", "client", "*", "docker", ".", "Client", ")", "(", "string", ",", "error", ")", "{", "image", ":=", "driver...
// createImage creates a docker image either by pulling it from a registry or by // loading it from the file system
[ "createImage", "creates", "a", "docker", "image", "either", "by", "pulling", "it", "from", "a", "registry", "or", "by", "loading", "it", "from", "the", "file", "system" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L492-L518
133,368
hashicorp/nomad
drivers/docker/driver.go
pullImage
func (d *Driver) pullImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client, repo, tag string) (id string, err error) { authOptions, err := d.resolveRegistryAuthentication(driverConfig, repo) if err != nil { if driverConfig.AuthSoftFail { d.logger.Warn("Failed to find docker repo auth", ...
go
func (d *Driver) pullImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client, repo, tag string) (id string, err error) { authOptions, err := d.resolveRegistryAuthentication(driverConfig, repo) if err != nil { if driverConfig.AuthSoftFail { d.logger.Warn("Failed to find docker repo auth", ...
[ "func", "(", "d", "*", "Driver", ")", "pullImage", "(", "task", "*", "drivers", ".", "TaskConfig", ",", "driverConfig", "*", "TaskConfig", ",", "client", "*", "docker", ".", "Client", ",", "repo", ",", "tag", "string", ")", "(", "id", "string", ",", ...
// pullImage creates an image by pulling it from a docker registry
[ "pullImage", "creates", "an", "image", "by", "pulling", "it", "from", "a", "docker", "registry" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L521-L547
133,369
hashicorp/nomad
drivers/docker/driver.go
resolveRegistryAuthentication
func (d *Driver) resolveRegistryAuthentication(driverConfig *TaskConfig, repo string) (*docker.AuthConfiguration, error) { return firstValidAuth(repo, []authBackend{ authFromTaskConfig(driverConfig), authFromDockerConfig(d.config.Auth.Config), authFromHelper(d.config.Auth.Helper), }) }
go
func (d *Driver) resolveRegistryAuthentication(driverConfig *TaskConfig, repo string) (*docker.AuthConfiguration, error) { return firstValidAuth(repo, []authBackend{ authFromTaskConfig(driverConfig), authFromDockerConfig(d.config.Auth.Config), authFromHelper(d.config.Auth.Helper), }) }
[ "func", "(", "d", "*", "Driver", ")", "resolveRegistryAuthentication", "(", "driverConfig", "*", "TaskConfig", ",", "repo", "string", ")", "(", "*", "docker", ".", "AuthConfiguration", ",", "error", ")", "{", "return", "firstValidAuth", "(", "repo", ",", "["...
// resolveRegistryAuthentication attempts to retrieve auth credentials for the // repo, trying all authentication-backends possible.
[ "resolveRegistryAuthentication", "attempts", "to", "retrieve", "auth", "credentials", "for", "the", "repo", "trying", "all", "authentication", "-", "backends", "possible", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L567-L573
133,370
hashicorp/nomad
drivers/docker/driver.go
loadImage
func (d *Driver) loadImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client) (id string, err error) { archive := filepath.Join(task.TaskDir().LocalDir, driverConfig.LoadImage) d.logger.Debug("loading image from disk", "archive", archive) f, err := os.Open(archive) if err != nil { return...
go
func (d *Driver) loadImage(task *drivers.TaskConfig, driverConfig *TaskConfig, client *docker.Client) (id string, err error) { archive := filepath.Join(task.TaskDir().LocalDir, driverConfig.LoadImage) d.logger.Debug("loading image from disk", "archive", archive) f, err := os.Open(archive) if err != nil { return...
[ "func", "(", "d", "*", "Driver", ")", "loadImage", "(", "task", "*", "drivers", ".", "TaskConfig", ",", "driverConfig", "*", "TaskConfig", ",", "client", "*", "docker", ".", "Client", ")", "(", "id", "string", ",", "err", "error", ")", "{", "archive", ...
// loadImage creates an image by loading it from the file system
[ "loadImage", "creates", "an", "image", "by", "loading", "it", "from", "the", "file", "system" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L576-L598
133,371
hashicorp/nomad
drivers/docker/driver.go
validateCommand
func validateCommand(command, argField string) error { trimmed := strings.TrimSpace(command) if len(trimmed) == 0 { return fmt.Errorf("command empty: %q", command) } if len(trimmed) != len(command) { return fmt.Errorf("command contains extra white space: %q", command) } return nil }
go
func validateCommand(command, argField string) error { trimmed := strings.TrimSpace(command) if len(trimmed) == 0 { return fmt.Errorf("command empty: %q", command) } if len(trimmed) != len(command) { return fmt.Errorf("command contains extra white space: %q", command) } return nil }
[ "func", "validateCommand", "(", "command", ",", "argField", "string", ")", "error", "{", "trimmed", ":=", "strings", ".", "TrimSpace", "(", "command", ")", "\n", "if", "len", "(", "trimmed", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"...
// validateCommand validates that the command only has a single value and // returns a user friendly error message telling them to use the passed // argField.
[ "validateCommand", "validates", "that", "the", "command", "only", "has", "a", "single", "value", "and", "returns", "a", "user", "friendly", "error", "message", "telling", "them", "to", "use", "the", "passed", "argField", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L1041-L1052
133,372
hashicorp/nomad
drivers/docker/driver.go
cleanupImage
func (d *Driver) cleanupImage(handle *taskHandle) error { if !d.config.GC.Image { return nil } d.coordinator.RemoveImage(handle.containerImage, handle.task.ID) return nil }
go
func (d *Driver) cleanupImage(handle *taskHandle) error { if !d.config.GC.Image { return nil } d.coordinator.RemoveImage(handle.containerImage, handle.task.ID) return nil }
[ "func", "(", "d", "*", "Driver", ")", "cleanupImage", "(", "handle", "*", "taskHandle", ")", "error", "{", "if", "!", "d", ".", "config", ".", "GC", ".", "Image", "{", "return", "nil", "\n", "}", "\n\n", "d", ".", "coordinator", ".", "RemoveImage", ...
// cleanupImage removes a Docker image. No error is returned if the image // doesn't exist or is still in use. Requires the global client to already be // initialized.
[ "cleanupImage", "removes", "a", "Docker", "image", ".", "No", "error", "is", "returned", "if", "the", "image", "doesn", "t", "exist", "or", "is", "still", "in", "use", ".", "Requires", "the", "global", "client", "to", "already", "be", "initialized", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/driver.go#L1132-L1140
133,373
hashicorp/nomad
client/logmon/logmon.go
IsRunning
func (tl *TaskLogger) IsRunning() bool { if tl.lro != nil && tl.lro.isRunning() { return true } if tl.lre != nil && tl.lre.isRunning() { return true } return false }
go
func (tl *TaskLogger) IsRunning() bool { if tl.lro != nil && tl.lro.isRunning() { return true } if tl.lre != nil && tl.lre.isRunning() { return true } return false }
[ "func", "(", "tl", "*", "TaskLogger", ")", "IsRunning", "(", ")", "bool", "{", "if", "tl", ".", "lro", "!=", "nil", "&&", "tl", ".", "lro", ".", "isRunning", "(", ")", "{", "return", "true", "\n", "}", "\n", "if", "tl", ".", "lre", "!=", "nil",...
// IsRunning will return true as long as one rotator wrapper is still running
[ "IsRunning", "will", "return", "true", "as", "long", "as", "one", "rotator", "wrapper", "is", "still", "running" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logmon.go#L111-L120
133,374
hashicorp/nomad
client/logmon/logmon.go
newLogRotatorWrapper
func newLogRotatorWrapper(path string, logger hclog.Logger, rotator *logging.FileRotator) (*logRotatorWrapper, error) { logger.Info("opening fifo", "path", path) fifoOpenFn, err := fifo.CreateAndRead(path) if err != nil { return nil, fmt.Errorf("failed to create fifo for extracting logs: %v", err) } wrap := &lo...
go
func newLogRotatorWrapper(path string, logger hclog.Logger, rotator *logging.FileRotator) (*logRotatorWrapper, error) { logger.Info("opening fifo", "path", path) fifoOpenFn, err := fifo.CreateAndRead(path) if err != nil { return nil, fmt.Errorf("failed to create fifo for extracting logs: %v", err) } wrap := &lo...
[ "func", "newLogRotatorWrapper", "(", "path", "string", ",", "logger", "hclog", ".", "Logger", ",", "rotator", "*", "logging", ".", "FileRotator", ")", "(", "*", "logRotatorWrapper", ",", "error", ")", "{", "logger", ".", "Info", "(", "\"", "\"", ",", "\"...
// newLogRotatorWrapper takes a rotator and returns a wrapper that has the // processOutWriter to attach to the stdout or stderr of a process.
[ "newLogRotatorWrapper", "takes", "a", "rotator", "and", "returns", "a", "wrapper", "that", "has", "the", "processOutWriter", "to", "attach", "to", "the", "stdout", "or", "stderr", "of", "a", "process", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logmon.go#L200-L216
133,375
hashicorp/nomad
client/logmon/logmon.go
start
func (l *logRotatorWrapper) start(readerOpenFn func() (io.ReadCloser, error)) { go func() { defer close(l.hasFinishedCopied) reader, err := readerOpenFn() if err != nil { close(l.openCompleted) l.logger.Warn("failed to open log fifo", "error", err) return } l.processOutReader = reader close(l.ope...
go
func (l *logRotatorWrapper) start(readerOpenFn func() (io.ReadCloser, error)) { go func() { defer close(l.hasFinishedCopied) reader, err := readerOpenFn() if err != nil { close(l.openCompleted) l.logger.Warn("failed to open log fifo", "error", err) return } l.processOutReader = reader close(l.ope...
[ "func", "(", "l", "*", "logRotatorWrapper", ")", "start", "(", "readerOpenFn", "func", "(", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", ")", "{", "go", "func", "(", ")", "{", "defer", "close", "(", "l", ".", "hasFinishedCopied", ")", "\n\n"...
// start starts a goroutine that copies from the pipe into the rotator. This is // called by the constructor and not the user of the wrapper.
[ "start", "starts", "a", "goroutine", "that", "copies", "from", "the", "pipe", "into", "the", "rotator", ".", "This", "is", "called", "by", "the", "constructor", "and", "not", "the", "user", "of", "the", "wrapper", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logmon.go#L220-L247
133,376
hashicorp/nomad
client/logmon/logmon.go
Close
func (l *logRotatorWrapper) Close() { // Wait up to the close tolerance before we force close select { case <-l.hasFinishedCopied: case <-time.After(processOutputCloseTolerance): } // Closing the read side of a pipe may block on Windows if the process // is being debugged as in: // https://github.com/PowerShel...
go
func (l *logRotatorWrapper) Close() { // Wait up to the close tolerance before we force close select { case <-l.hasFinishedCopied: case <-time.After(processOutputCloseTolerance): } // Closing the read side of a pipe may block on Windows if the process // is being debugged as in: // https://github.com/PowerShel...
[ "func", "(", "l", "*", "logRotatorWrapper", ")", "Close", "(", ")", "{", "// Wait up to the close tolerance before we force close", "select", "{", "case", "<-", "l", ".", "hasFinishedCopied", ":", "case", "<-", "time", ".", "After", "(", "processOutputCloseTolerance...
// Close closes the rotator and the process writer to ensure that the Wait // command exits.
[ "Close", "closes", "the", "rotator", "and", "the", "process", "writer", "to", "ensure", "that", "the", "Wait", "command", "exits", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logmon.go#L251-L288
133,377
hashicorp/nomad
nomad/rpc.go
handleAcceptErr
func (r *rpcHandler) handleAcceptErr(ctx context.Context, err error, loopDelay *time.Duration) { const baseDelay = 5 * time.Millisecond const maxDelayPerm = 5 * time.Second const maxDelayTemp = 1 * time.Second if *loopDelay == 0 { *loopDelay = baseDelay } else { *loopDelay *= 2 } temporaryError := false i...
go
func (r *rpcHandler) handleAcceptErr(ctx context.Context, err error, loopDelay *time.Duration) { const baseDelay = 5 * time.Millisecond const maxDelayPerm = 5 * time.Second const maxDelayTemp = 1 * time.Second if *loopDelay == 0 { *loopDelay = baseDelay } else { *loopDelay *= 2 } temporaryError := false i...
[ "func", "(", "r", "*", "rpcHandler", ")", "handleAcceptErr", "(", "ctx", "context", ".", "Context", ",", "err", "error", ",", "loopDelay", "*", "time", ".", "Duration", ")", "{", "const", "baseDelay", "=", "5", "*", "time", ".", "Millisecond", "\n", "c...
// handleAcceptErr sleeps to avoid spamming the log, // with a maximum delay according to whether or not the error is temporary
[ "handleAcceptErr", "sleeps", "to", "avoid", "spamming", "the", "log", "with", "a", "maximum", "delay", "according", "to", "whether", "or", "not", "the", "error", "is", "temporary" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L116-L144
133,378
hashicorp/nomad
nomad/rpc.go
handleConn
func (r *rpcHandler) handleConn(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) { // Read a single byte buf := make([]byte, 1) if _, err := conn.Read(buf); err != nil { if err != io.EOF { r.logger.Error("failed to read first RPC byte", "error", err) } conn.Close() return } // Enforce TLS if Ena...
go
func (r *rpcHandler) handleConn(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) { // Read a single byte buf := make([]byte, 1) if _, err := conn.Read(buf); err != nil { if err != io.EOF { r.logger.Error("failed to read first RPC byte", "error", err) } conn.Close() return } // Enforce TLS if Ena...
[ "func", "(", "r", "*", "rpcHandler", ")", "handleConn", "(", "ctx", "context", ".", "Context", ",", "conn", "net", ".", "Conn", ",", "rpcCtx", "*", "RPCContext", ")", "{", "// Read a single byte", "buf", ":=", "make", "(", "[", "]", "byte", ",", "1", ...
// handleConn is used to determine if this is a Raft or // Nomad type RPC connection and invoke the correct handler
[ "handleConn", "is", "used", "to", "determine", "if", "this", "is", "a", "Raft", "or", "Nomad", "type", "RPC", "connection", "and", "invoke", "the", "correct", "handler" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L148-L231
133,379
hashicorp/nomad
nomad/rpc.go
handleMultiplex
func (r *rpcHandler) handleMultiplex(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) { defer func() { // Remove any potential mapping between a NodeID to this connection and // close the underlying connection. r.removeNodeConn(rpcCtx) conn.Close() }() conf := yamux.DefaultConfig() conf.LogOutput = ...
go
func (r *rpcHandler) handleMultiplex(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) { defer func() { // Remove any potential mapping between a NodeID to this connection and // close the underlying connection. r.removeNodeConn(rpcCtx) conn.Close() }() conf := yamux.DefaultConfig() conf.LogOutput = ...
[ "func", "(", "r", "*", "rpcHandler", ")", "handleMultiplex", "(", "ctx", "context", ".", "Context", ",", "conn", "net", ".", "Conn", ",", "rpcCtx", "*", "RPCContext", ")", "{", "defer", "func", "(", ")", "{", "// Remove any potential mapping between a NodeID t...
// handleMultiplex is used to multiplex a single incoming connection // using the Yamux multiplexer
[ "handleMultiplex", "is", "used", "to", "multiplex", "a", "single", "incoming", "connection", "using", "the", "Yamux", "multiplexer" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L235-L274
133,380
hashicorp/nomad
nomad/rpc.go
handleNomadConn
func (r *rpcHandler) handleNomadConn(ctx context.Context, conn net.Conn, server *rpc.Server) { defer conn.Close() rpcCodec := pool.NewServerCodec(conn) for { select { case <-ctx.Done(): r.logger.Info("closing server RPC connection") return case <-r.shutdownCh: return default: } if err := server...
go
func (r *rpcHandler) handleNomadConn(ctx context.Context, conn net.Conn, server *rpc.Server) { defer conn.Close() rpcCodec := pool.NewServerCodec(conn) for { select { case <-ctx.Done(): r.logger.Info("closing server RPC connection") return case <-r.shutdownCh: return default: } if err := server...
[ "func", "(", "r", "*", "rpcHandler", ")", "handleNomadConn", "(", "ctx", "context", ".", "Context", ",", "conn", "net", ".", "Conn", ",", "server", "*", "rpc", ".", "Server", ")", "{", "defer", "conn", ".", "Close", "(", ")", "\n", "rpcCodec", ":=", ...
// handleNomadConn is used to service a single Nomad RPC connection
[ "handleNomadConn", "is", "used", "to", "service", "a", "single", "Nomad", "RPC", "connection" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L277-L299
133,381
hashicorp/nomad
nomad/rpc.go
handleStreamingConn
func (r *rpcHandler) handleStreamingConn(conn net.Conn) { defer conn.Close() // Decode the header var header structs.StreamingRpcHeader decoder := codec.NewDecoder(conn, structs.MsgpackHandle) if err := decoder.Decode(&header); err != nil { if err != io.EOF && !strings.Contains(err.Error(), "closed") { r.log...
go
func (r *rpcHandler) handleStreamingConn(conn net.Conn) { defer conn.Close() // Decode the header var header structs.StreamingRpcHeader decoder := codec.NewDecoder(conn, structs.MsgpackHandle) if err := decoder.Decode(&header); err != nil { if err != io.EOF && !strings.Contains(err.Error(), "closed") { r.log...
[ "func", "(", "r", "*", "rpcHandler", ")", "handleStreamingConn", "(", "conn", "net", ".", "Conn", ")", "{", "defer", "conn", ".", "Close", "(", ")", "\n\n", "// Decode the header", "var", "header", "structs", ".", "StreamingRpcHeader", "\n", "decoder", ":=",...
// handleStreamingConn is used to handle a single Streaming Nomad RPC connection.
[ "handleStreamingConn", "is", "used", "to", "handle", "a", "single", "Streaming", "Nomad", "RPC", "connection", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L302-L339
133,382
hashicorp/nomad
nomad/rpc.go
handleMultiplexV2
func (r *rpcHandler) handleMultiplexV2(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) { defer func() { // Remove any potential mapping between a NodeID to this connection and // close the underlying connection. r.removeNodeConn(rpcCtx) conn.Close() }() conf := yamux.DefaultConfig() conf.LogOutput ...
go
func (r *rpcHandler) handleMultiplexV2(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) { defer func() { // Remove any potential mapping between a NodeID to this connection and // close the underlying connection. r.removeNodeConn(rpcCtx) conn.Close() }() conf := yamux.DefaultConfig() conf.LogOutput ...
[ "func", "(", "r", "*", "rpcHandler", ")", "handleMultiplexV2", "(", "ctx", "context", ".", "Context", ",", "conn", "net", ".", "Conn", ",", "rpcCtx", "*", "RPCContext", ")", "{", "defer", "func", "(", ")", "{", "// Remove any potential mapping between a NodeID...
// handleMultiplexV2 is used to multiplex a single incoming connection // using the Yamux multiplexer. Version 2 handling allows a single connection to // switch streams between regulars RPCs and Streaming RPCs.
[ "handleMultiplexV2", "is", "used", "to", "multiplex", "a", "single", "incoming", "connection", "using", "the", "Yamux", "multiplexer", ".", "Version", "2", "handling", "allows", "a", "single", "connection", "to", "switch", "streams", "between", "regulars", "RPCs",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L344-L405
133,383
hashicorp/nomad
nomad/rpc.go
forward
func (r *rpcHandler) forward(method string, info structs.RPCInfo, args interface{}, reply interface{}) (bool, error) { var firstCheck time.Time region := info.RequestRegion() if region == "" { return true, fmt.Errorf("missing target RPC") } // Handle region forwarding if region != r.config.Region { // Mark ...
go
func (r *rpcHandler) forward(method string, info structs.RPCInfo, args interface{}, reply interface{}) (bool, error) { var firstCheck time.Time region := info.RequestRegion() if region == "" { return true, fmt.Errorf("missing target RPC") } // Handle region forwarding if region != r.config.Region { // Mark ...
[ "func", "(", "r", "*", "rpcHandler", ")", "forward", "(", "method", "string", ",", "info", "structs", ".", "RPCInfo", ",", "args", "interface", "{", "}", ",", "reply", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "var", "firstChec...
// forward is used to forward to a remote region or to forward to the local leader // Returns a bool of if forwarding was performed, as well as any error
[ "forward", "is", "used", "to", "forward", "to", "a", "remote", "region", "or", "to", "forward", "to", "the", "local", "leader", "Returns", "a", "bool", "of", "if", "forwarding", "was", "performed", "as", "well", "as", "any", "error" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L409-L462
133,384
hashicorp/nomad
nomad/rpc.go
forwardLeader
func (r *rpcHandler) forwardLeader(server *serverParts, method string, args interface{}, reply interface{}) error { // Handle a missing server if server == nil { return structs.ErrNoLeader } return r.connPool.RPC(r.config.Region, server.Addr, server.MajorVersion, method, args, reply) }
go
func (r *rpcHandler) forwardLeader(server *serverParts, method string, args interface{}, reply interface{}) error { // Handle a missing server if server == nil { return structs.ErrNoLeader } return r.connPool.RPC(r.config.Region, server.Addr, server.MajorVersion, method, args, reply) }
[ "func", "(", "r", "*", "rpcHandler", ")", "forwardLeader", "(", "server", "*", "serverParts", ",", "method", "string", ",", "args", "interface", "{", "}", ",", "reply", "interface", "{", "}", ")", "error", "{", "// Handle a missing server", "if", "server", ...
// forwardLeader is used to forward an RPC call to the leader, or fail if no leader
[ "forwardLeader", "is", "used", "to", "forward", "an", "RPC", "call", "to", "the", "leader", "or", "fail", "if", "no", "leader" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L489-L495
133,385
hashicorp/nomad
nomad/rpc.go
forwardServer
func (r *rpcHandler) forwardServer(server *serverParts, method string, args interface{}, reply interface{}) error { // Handle a missing server if server == nil { return errors.New("must be given a valid server address") } return r.connPool.RPC(r.config.Region, server.Addr, server.MajorVersion, method, args, reply...
go
func (r *rpcHandler) forwardServer(server *serverParts, method string, args interface{}, reply interface{}) error { // Handle a missing server if server == nil { return errors.New("must be given a valid server address") } return r.connPool.RPC(r.config.Region, server.Addr, server.MajorVersion, method, args, reply...
[ "func", "(", "r", "*", "rpcHandler", ")", "forwardServer", "(", "server", "*", "serverParts", ",", "method", "string", ",", "args", "interface", "{", "}", ",", "reply", "interface", "{", "}", ")", "error", "{", "// Handle a missing server", "if", "server", ...
// forwardServer is used to forward an RPC call to a particular server
[ "forwardServer", "is", "used", "to", "forward", "an", "RPC", "call", "to", "a", "particular", "server" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L498-L504
133,386
hashicorp/nomad
nomad/rpc.go
forwardRegion
func (r *rpcHandler) forwardRegion(region, method string, args interface{}, reply interface{}) error { // Bail if we can't find any servers r.peerLock.RLock() servers := r.peers[region] if len(servers) == 0 { r.peerLock.RUnlock() r.logger.Warn("no path found to region", "region", region) return structs.ErrNoR...
go
func (r *rpcHandler) forwardRegion(region, method string, args interface{}, reply interface{}) error { // Bail if we can't find any servers r.peerLock.RLock() servers := r.peers[region] if len(servers) == 0 { r.peerLock.RUnlock() r.logger.Warn("no path found to region", "region", region) return structs.ErrNoR...
[ "func", "(", "r", "*", "rpcHandler", ")", "forwardRegion", "(", "region", ",", "method", "string", ",", "args", "interface", "{", "}", ",", "reply", "interface", "{", "}", ")", "error", "{", "// Bail if we can't find any servers", "r", ".", "peerLock", ".", ...
// forwardRegion is used to forward an RPC call to a remote region, or fail if no servers
[ "forwardRegion", "is", "used", "to", "forward", "an", "RPC", "call", "to", "a", "remote", "region", "or", "fail", "if", "no", "servers" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L507-L525
133,387
hashicorp/nomad
nomad/rpc.go
streamingRpc
func (r *rpcHandler) streamingRpc(server *serverParts, method string) (net.Conn, error) { // Try to dial the server conn, err := net.DialTimeout("tcp", server.Addr.String(), 10*time.Second) if err != nil { return nil, err } // Cast to TCPConn if tcp, ok := conn.(*net.TCPConn); ok { tcp.SetKeepAlive(true) t...
go
func (r *rpcHandler) streamingRpc(server *serverParts, method string) (net.Conn, error) { // Try to dial the server conn, err := net.DialTimeout("tcp", server.Addr.String(), 10*time.Second) if err != nil { return nil, err } // Cast to TCPConn if tcp, ok := conn.(*net.TCPConn); ok { tcp.SetKeepAlive(true) t...
[ "func", "(", "r", "*", "rpcHandler", ")", "streamingRpc", "(", "server", "*", "serverParts", ",", "method", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "// Try to dial the server", "conn", ",", "err", ":=", "net", ".", "DialTimeout", ...
// streamingRpc creates a connection to the given server and conducts the // initial handshake, returning the connection or an error. It is the callers // responsibility to close the connection if there is no returned error.
[ "streamingRpc", "creates", "a", "connection", "to", "the", "given", "server", "and", "conducts", "the", "initial", "handshake", "returning", "the", "connection", "or", "an", "error", ".", "It", "is", "the", "callers", "responsibility", "to", "close", "the", "c...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L530-L548
133,388
hashicorp/nomad
nomad/rpc.go
streamingRpcImpl
func (r *rpcHandler) streamingRpcImpl(conn net.Conn, region, method string) error { // Check if TLS is enabled r.tlsWrapLock.RLock() tlsWrap := r.tlsWrap r.tlsWrapLock.RUnlock() if tlsWrap != nil { // Switch the connection into TLS mode if _, err := conn.Write([]byte{byte(pool.RpcTLS)}); err != nil { conn....
go
func (r *rpcHandler) streamingRpcImpl(conn net.Conn, region, method string) error { // Check if TLS is enabled r.tlsWrapLock.RLock() tlsWrap := r.tlsWrap r.tlsWrapLock.RUnlock() if tlsWrap != nil { // Switch the connection into TLS mode if _, err := conn.Write([]byte{byte(pool.RpcTLS)}); err != nil { conn....
[ "func", "(", "r", "*", "rpcHandler", ")", "streamingRpcImpl", "(", "conn", "net", ".", "Conn", ",", "region", ",", "method", "string", ")", "error", "{", "// Check if TLS is enabled", "r", ".", "tlsWrapLock", ".", "RLock", "(", ")", "\n", "tlsWrap", ":=", ...
// streamingRpcImpl takes a pre-established connection to a server and conducts // the handshake to establish a streaming RPC for the given method. If an error // is returned, the underlying connection has been closed. Otherwise it is // assumed that the connection has been hijacked by the RPC method.
[ "streamingRpcImpl", "takes", "a", "pre", "-", "established", "connection", "to", "a", "server", "and", "conducts", "the", "handshake", "to", "establish", "a", "streaming", "RPC", "for", "the", "given", "method", ".", "If", "an", "error", "is", "returned", "t...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L554-L606
133,389
hashicorp/nomad
nomad/rpc.go
raftApplyFuture
func (s *Server) raftApplyFuture(t structs.MessageType, msg interface{}) (raft.ApplyFuture, error) { buf, err := structs.Encode(t, msg) if err != nil { return nil, fmt.Errorf("Failed to encode request: %v", err) } // Warn if the command is very large if n := len(buf); n > raftWarnSize { s.logger.Warn("attempt...
go
func (s *Server) raftApplyFuture(t structs.MessageType, msg interface{}) (raft.ApplyFuture, error) { buf, err := structs.Encode(t, msg) if err != nil { return nil, fmt.Errorf("Failed to encode request: %v", err) } // Warn if the command is very large if n := len(buf); n > raftWarnSize { s.logger.Warn("attempt...
[ "func", "(", "s", "*", "Server", ")", "raftApplyFuture", "(", "t", "structs", ".", "MessageType", ",", "msg", "interface", "{", "}", ")", "(", "raft", ".", "ApplyFuture", ",", "error", ")", "{", "buf", ",", "err", ":=", "structs", ".", "Encode", "(",...
// raftApplyFuture is used to encode a message, run it through raft, and return the Raft future.
[ "raftApplyFuture", "is", "used", "to", "encode", "a", "message", "run", "it", "through", "raft", "and", "return", "the", "Raft", "future", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L609-L622
133,390
hashicorp/nomad
nomad/rpc.go
blockingRPC
func (r *rpcHandler) blockingRPC(opts *blockingOptions) error { ctx := context.Background() var cancel context.CancelFunc var state *state.StateStore // Fast path non-blocking if opts.queryOpts.MinQueryIndex == 0 { goto RUN_QUERY } // Restrict the max query time, and ensure there is always one if opts.query...
go
func (r *rpcHandler) blockingRPC(opts *blockingOptions) error { ctx := context.Background() var cancel context.CancelFunc var state *state.StateStore // Fast path non-blocking if opts.queryOpts.MinQueryIndex == 0 { goto RUN_QUERY } // Restrict the max query time, and ensure there is always one if opts.query...
[ "func", "(", "r", "*", "rpcHandler", ")", "blockingRPC", "(", "opts", "*", "blockingOptions", ")", "error", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "var", "cancel", "context", ".", "CancelFunc", "\n", "var", "state", "*", "state",...
// blockingRPC is used for queries that need to wait for a // minimum index. This is used to block and wait for changes.
[ "blockingRPC", "is", "used", "for", "queries", "that", "need", "to", "wait", "for", "a", "minimum", "index", ".", "This", "is", "used", "to", "block", "and", "wait", "for", "changes", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/rpc.go#L667-L726
133,391
hashicorp/nomad
nomad/operator_endpoint.go
SchedulerGetConfiguration
func (op *Operator) SchedulerGetConfiguration(args *structs.GenericRequest, reply *structs.SchedulerConfigurationResponse) error { if done, err := op.srv.forward("Operator.SchedulerGetConfiguration", args, args, reply); done { return err } // This action requires operator read access. rule, err := op.srv.Resolve...
go
func (op *Operator) SchedulerGetConfiguration(args *structs.GenericRequest, reply *structs.SchedulerConfigurationResponse) error { if done, err := op.srv.forward("Operator.SchedulerGetConfiguration", args, args, reply); done { return err } // This action requires operator read access. rule, err := op.srv.Resolve...
[ "func", "(", "op", "*", "Operator", ")", "SchedulerGetConfiguration", "(", "args", "*", "structs", ".", "GenericRequest", ",", "reply", "*", "structs", ".", "SchedulerConfigurationResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "op", ".", "srv"...
// SchedulerGetConfiguration is used to retrieve the current Scheduler configuration.
[ "SchedulerGetConfiguration", "is", "used", "to", "retrieve", "the", "current", "Scheduler", "configuration", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/operator_endpoint.go#L330-L357
133,392
hashicorp/nomad
client/logmon/logging/universal_collector.go
NewSyslogCollector
func NewSyslogCollector(logger hclog.Logger) *SyslogCollector { return &SyslogCollector{logger: logger.Named("syslog-server"), syslogChan: make(chan *SyslogMessage, 2048)} }
go
func NewSyslogCollector(logger hclog.Logger) *SyslogCollector { return &SyslogCollector{logger: logger.Named("syslog-server"), syslogChan: make(chan *SyslogMessage, 2048)} }
[ "func", "NewSyslogCollector", "(", "logger", "hclog", ".", "Logger", ")", "*", "SyslogCollector", "{", "return", "&", "SyslogCollector", "{", "logger", ":", "logger", ".", "Named", "(", "\"", "\"", ")", ",", "syslogChan", ":", "make", "(", "chan", "*", "...
// NewSyslogCollector returns an implementation of the SyslogCollector
[ "NewSyslogCollector", "returns", "an", "implementation", "of", "the", "SyslogCollector" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L69-L72
133,393
hashicorp/nomad
client/logmon/logging/universal_collector.go
LaunchCollector
func (s *SyslogCollector) LaunchCollector(ctx *LogCollectorContext) (*SyslogCollectorState, error) { l, err := s.getListener(ctx.PortLowerBound, ctx.PortUpperBound) if err != nil { return nil, err } s.logger.Debug("launching syslog server on addr", "addr", l.Addr().String()) s.ctx = ctx // configuring the task ...
go
func (s *SyslogCollector) LaunchCollector(ctx *LogCollectorContext) (*SyslogCollectorState, error) { l, err := s.getListener(ctx.PortLowerBound, ctx.PortUpperBound) if err != nil { return nil, err } s.logger.Debug("launching syslog server on addr", "addr", l.Addr().String()) s.ctx = ctx // configuring the task ...
[ "func", "(", "s", "*", "SyslogCollector", ")", "LaunchCollector", "(", "ctx", "*", "LogCollectorContext", ")", "(", "*", "SyslogCollectorState", ",", "error", ")", "{", "l", ",", "err", ":=", "s", ".", "getListener", "(", "ctx", ".", "PortLowerBound", ",",...
// LaunchCollector launches a new syslog server and starts writing log lines to // files and rotates them
[ "LaunchCollector", "launches", "a", "new", "syslog", "server", "and", "starts", "writing", "log", "lines", "to", "files", "and", "rotates", "them" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L76-L112
133,394
hashicorp/nomad
client/logmon/logging/universal_collector.go
Exit
func (s *SyslogCollector) Exit() error { s.server.Shutdown() s.lre.Close() s.lro.Close() return nil }
go
func (s *SyslogCollector) Exit() error { s.server.Shutdown() s.lre.Close() s.lro.Close() return nil }
[ "func", "(", "s", "*", "SyslogCollector", ")", "Exit", "(", ")", "error", "{", "s", ".", "server", ".", "Shutdown", "(", ")", "\n", "s", ".", "lre", ".", "Close", "(", ")", "\n", "s", ".", "lro", ".", "Close", "(", ")", "\n", "return", "nil", ...
// Exit kills the syslog server
[ "Exit", "kills", "the", "syslog", "server" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L129-L134
133,395
hashicorp/nomad
client/logmon/logging/universal_collector.go
UpdateLogConfig
func (s *SyslogCollector) UpdateLogConfig(logConfig *structs.LogConfig) error { s.ctx.LogConfig = logConfig if s.lro == nil { return fmt.Errorf("log rotator for stdout doesn't exist") } s.lro.MaxFiles = logConfig.MaxFiles s.lro.FileSize = int64(logConfig.MaxFileSizeMB * 1024 * 1024) if s.lre == nil { return ...
go
func (s *SyslogCollector) UpdateLogConfig(logConfig *structs.LogConfig) error { s.ctx.LogConfig = logConfig if s.lro == nil { return fmt.Errorf("log rotator for stdout doesn't exist") } s.lro.MaxFiles = logConfig.MaxFiles s.lro.FileSize = int64(logConfig.MaxFileSizeMB * 1024 * 1024) if s.lre == nil { return ...
[ "func", "(", "s", "*", "SyslogCollector", ")", "UpdateLogConfig", "(", "logConfig", "*", "structs", ".", "LogConfig", ")", "error", "{", "s", ".", "ctx", ".", "LogConfig", "=", "logConfig", "\n", "if", "s", ".", "lro", "==", "nil", "{", "return", "fmt"...
// UpdateLogConfig updates the log configuration
[ "UpdateLogConfig", "updates", "the", "log", "configuration" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L137-L151
133,396
hashicorp/nomad
client/logmon/logging/universal_collector.go
configureTaskDir
func (s *SyslogCollector) configureTaskDir() error { taskDir, ok := s.ctx.AllocDir.TaskDirs[s.ctx.TaskName] if !ok { return fmt.Errorf("couldn't find task directory for task %v", s.ctx.TaskName) } s.taskDir = taskDir.Dir return nil }
go
func (s *SyslogCollector) configureTaskDir() error { taskDir, ok := s.ctx.AllocDir.TaskDirs[s.ctx.TaskName] if !ok { return fmt.Errorf("couldn't find task directory for task %v", s.ctx.TaskName) } s.taskDir = taskDir.Dir return nil }
[ "func", "(", "s", "*", "SyslogCollector", ")", "configureTaskDir", "(", ")", "error", "{", "taskDir", ",", "ok", ":=", "s", ".", "ctx", ".", "AllocDir", ".", "TaskDirs", "[", "s", ".", "ctx", ".", "TaskName", "]", "\n", "if", "!", "ok", "{", "retur...
// configureTaskDir sets the task dir in the SyslogCollector
[ "configureTaskDir", "sets", "the", "task", "dir", "in", "the", "SyslogCollector" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L154-L161
133,397
hashicorp/nomad
client/logmon/logging/universal_collector.go
getListener
func (s *SyslogCollector) getListener(lowerBound uint, upperBound uint) (net.Listener, error) { if runtime.GOOS == "windows" { return s.listenerTCP(lowerBound, upperBound) } return s.listenerUnix() }
go
func (s *SyslogCollector) getListener(lowerBound uint, upperBound uint) (net.Listener, error) { if runtime.GOOS == "windows" { return s.listenerTCP(lowerBound, upperBound) } return s.listenerUnix() }
[ "func", "(", "s", "*", "SyslogCollector", ")", "getListener", "(", "lowerBound", "uint", ",", "upperBound", "uint", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "return", "s", ".", "li...
// getFreePort returns a free port ready to be listened on between upper and // lower bounds
[ "getFreePort", "returns", "a", "free", "port", "ready", "to", "be", "listened", "on", "between", "upper", "and", "lower", "bounds" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L165-L171
133,398
hashicorp/nomad
client/logmon/logging/universal_collector.go
listenerTCP
func (s *SyslogCollector) listenerTCP(lowerBound uint, upperBound uint) (net.Listener, error) { for i := lowerBound; i <= upperBound; i++ { addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("localhost:%v", i)) if err != nil { return nil, err } l, err := net.ListenTCP("tcp", addr) if err != nil { conti...
go
func (s *SyslogCollector) listenerTCP(lowerBound uint, upperBound uint) (net.Listener, error) { for i := lowerBound; i <= upperBound; i++ { addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("localhost:%v", i)) if err != nil { return nil, err } l, err := net.ListenTCP("tcp", addr) if err != nil { conti...
[ "func", "(", "s", "*", "SyslogCollector", ")", "listenerTCP", "(", "lowerBound", "uint", ",", "upperBound", "uint", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "for", "i", ":=", "lowerBound", ";", "i", "<=", "upperBound", ";", "i", "++", ...
// listenerTCP creates a TCP listener using an unused port between an upper and // lower bound
[ "listenerTCP", "creates", "a", "TCP", "listener", "using", "an", "unused", "port", "between", "an", "upper", "and", "lower", "bound" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L175-L188
133,399
hashicorp/nomad
client/logmon/logging/universal_collector.go
listenerUnix
func (s *SyslogCollector) listenerUnix() (net.Listener, error) { f, err := ioutil.TempFile("", "plugin") if err != nil { return nil, err } path := f.Name() if err := f.Close(); err != nil { return nil, err } if err := os.Remove(path); err != nil { return nil, err } return net.Listen("unix", path) }
go
func (s *SyslogCollector) listenerUnix() (net.Listener, error) { f, err := ioutil.TempFile("", "plugin") if err != nil { return nil, err } path := f.Name() if err := f.Close(); err != nil { return nil, err } if err := os.Remove(path); err != nil { return nil, err } return net.Listen("unix", path) }
[ "func", "(", "s", "*", "SyslogCollector", ")", "listenerUnix", "(", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil",...
// listenerUnix creates a Unix domain socket
[ "listenerUnix", "creates", "a", "Unix", "domain", "socket" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/logmon/logging/universal_collector.go#L191-L206