id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
132,300
hashicorp/nomad
nomad/structs/structs.go
Stub
func (n *Node) Stub() *NodeListStub { addr, _, _ := net.SplitHostPort(n.HTTPAddr) return &NodeListStub{ Address: addr, ID: n.ID, Datacenter: n.Datacenter, Name: n.Name, NodeClass: n.NodeClass, Version: n.Attributes["n...
go
func (n *Node) Stub() *NodeListStub { addr, _, _ := net.SplitHostPort(n.HTTPAddr) return &NodeListStub{ Address: addr, ID: n.ID, Datacenter: n.Datacenter, Name: n.Name, NodeClass: n.NodeClass, Version: n.Attributes["n...
[ "func", "(", "n", "*", "Node", ")", "Stub", "(", ")", "*", "NodeListStub", "{", "addr", ",", "_", ",", "_", ":=", "net", ".", "SplitHostPort", "(", "n", ".", "HTTPAddr", ")", "\n\n", "return", "&", "NodeListStub", "{", "Address", ":", "addr", ",", ...
// Stub returns a summarized version of the node
[ "Stub", "returns", "a", "summarized", "version", "of", "the", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1709-L1728
132,301
hashicorp/nomad
nomad/structs/structs.go
Copy
func (r *Resources) Copy() *Resources { if r == nil { return nil } newR := new(Resources) *newR = *r // Copy the network objects if r.Networks != nil { n := len(r.Networks) newR.Networks = make([]*NetworkResource, n) for i := 0; i < n; i++ { newR.Networks[i] = r.Networks[i].Copy() } } // Copy the...
go
func (r *Resources) Copy() *Resources { if r == nil { return nil } newR := new(Resources) *newR = *r // Copy the network objects if r.Networks != nil { n := len(r.Networks) newR.Networks = make([]*NetworkResource, n) for i := 0; i < n; i++ { newR.Networks[i] = r.Networks[i].Copy() } } // Copy the...
[ "func", "(", "r", "*", "Resources", ")", "Copy", "(", ")", "*", "Resources", "{", "if", "r", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "newR", ":=", "new", "(", "Resources", ")", "\n", "*", "newR", "=", "*", "r", "\n\n", "// Copy the ne...
// Copy returns a deep copy of the resources
[ "Copy", "returns", "a", "deep", "copy", "of", "the", "resources" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1915-L1941
132,302
hashicorp/nomad
nomad/structs/structs.go
MeetsMinResources
func (n *NetworkResource) MeetsMinResources() error { var mErr multierror.Error if n.MBits < 1 { mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum MBits value is 1; got %d", n.MBits)) } return mErr.ErrorOrNil() }
go
func (n *NetworkResource) MeetsMinResources() error { var mErr multierror.Error if n.MBits < 1 { mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum MBits value is 1; got %d", n.MBits)) } return mErr.ErrorOrNil() }
[ "func", "(", "n", "*", "NetworkResource", ")", "MeetsMinResources", "(", ")", "error", "{", "var", "mErr", "multierror", ".", "Error", "\n", "if", "n", ".", "MBits", "<", "1", "{", "mErr", ".", "Errors", "=", "append", "(", "mErr", ".", "Errors", ","...
// MeetsMinResources returns an error if the resources specified are less than // the minimum allowed.
[ "MeetsMinResources", "returns", "an", "error", "if", "the", "resources", "specified", "are", "less", "than", "the", "minimum", "allowed", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2067-L2073
132,303
hashicorp/nomad
nomad/structs/structs.go
Copy
func (n *NetworkResource) Copy() *NetworkResource { if n == nil { return nil } newR := new(NetworkResource) *newR = *n if n.ReservedPorts != nil { newR.ReservedPorts = make([]Port, len(n.ReservedPorts)) copy(newR.ReservedPorts, n.ReservedPorts) } if n.DynamicPorts != nil { newR.DynamicPorts = make([]Port...
go
func (n *NetworkResource) Copy() *NetworkResource { if n == nil { return nil } newR := new(NetworkResource) *newR = *n if n.ReservedPorts != nil { newR.ReservedPorts = make([]Port, len(n.ReservedPorts)) copy(newR.ReservedPorts, n.ReservedPorts) } if n.DynamicPorts != nil { newR.DynamicPorts = make([]Port...
[ "func", "(", "n", "*", "NetworkResource", ")", "Copy", "(", ")", "*", "NetworkResource", "{", "if", "n", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "newR", ":=", "new", "(", "NetworkResource", ")", "\n", "*", "newR", "=", "*", "n", "\n", ...
// Copy returns a deep copy of the network resource
[ "Copy", "returns", "a", "deep", "copy", "of", "the", "network", "resource" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2076-L2091
132,304
hashicorp/nomad
nomad/structs/structs.go
Add
func (n *NetworkResource) Add(delta *NetworkResource) { if len(delta.ReservedPorts) > 0 { n.ReservedPorts = append(n.ReservedPorts, delta.ReservedPorts...) } n.MBits += delta.MBits n.DynamicPorts = append(n.DynamicPorts, delta.DynamicPorts...) }
go
func (n *NetworkResource) Add(delta *NetworkResource) { if len(delta.ReservedPorts) > 0 { n.ReservedPorts = append(n.ReservedPorts, delta.ReservedPorts...) } n.MBits += delta.MBits n.DynamicPorts = append(n.DynamicPorts, delta.DynamicPorts...) }
[ "func", "(", "n", "*", "NetworkResource", ")", "Add", "(", "delta", "*", "NetworkResource", ")", "{", "if", "len", "(", "delta", ".", "ReservedPorts", ")", ">", "0", "{", "n", ".", "ReservedPorts", "=", "append", "(", "n", ".", "ReservedPorts", ",", ...
// Add adds the resources of the delta to this, potentially // returning an error if not possible.
[ "Add", "adds", "the", "resources", "of", "the", "delta", "to", "this", "potentially", "returning", "an", "error", "if", "not", "possible", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2095-L2101
132,305
hashicorp/nomad
nomad/structs/structs.go
PortLabels
func (n *NetworkResource) PortLabels() map[string]int { num := len(n.ReservedPorts) + len(n.DynamicPorts) labelValues := make(map[string]int, num) for _, port := range n.ReservedPorts { labelValues[port.Label] = port.Value } for _, port := range n.DynamicPorts { labelValues[port.Label] = port.Value } return ...
go
func (n *NetworkResource) PortLabels() map[string]int { num := len(n.ReservedPorts) + len(n.DynamicPorts) labelValues := make(map[string]int, num) for _, port := range n.ReservedPorts { labelValues[port.Label] = port.Value } for _, port := range n.DynamicPorts { labelValues[port.Label] = port.Value } return ...
[ "func", "(", "n", "*", "NetworkResource", ")", "PortLabels", "(", ")", "map", "[", "string", "]", "int", "{", "num", ":=", "len", "(", "n", ".", "ReservedPorts", ")", "+", "len", "(", "n", ".", "DynamicPorts", ")", "\n", "labelValues", ":=", "make", ...
// PortLabels returns a map of port labels to their assigned host ports.
[ "PortLabels", "returns", "a", "map", "of", "port", "labels", "to", "their", "assigned", "host", "ports", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2108-L2118
132,306
hashicorp/nomad
nomad/structs/structs.go
Port
func (ns Networks) Port(label string) (string, int) { for _, n := range ns { for _, p := range n.ReservedPorts { if p.Label == label { return n.IP, p.Value } } for _, p := range n.DynamicPorts { if p.Label == label { return n.IP, p.Value } } } return "", 0 }
go
func (ns Networks) Port(label string) (string, int) { for _, n := range ns { for _, p := range n.ReservedPorts { if p.Label == label { return n.IP, p.Value } } for _, p := range n.DynamicPorts { if p.Label == label { return n.IP, p.Value } } } return "", 0 }
[ "func", "(", "ns", "Networks", ")", "Port", "(", "label", "string", ")", "(", "string", ",", "int", ")", "{", "for", "_", ",", "n", ":=", "range", "ns", "{", "for", "_", ",", "p", ":=", "range", "n", ".", "ReservedPorts", "{", "if", "p", ".", ...
// Port assignment and IP for the given label or empty values.
[ "Port", "assignment", "and", "IP", "for", "the", "given", "label", "or", "empty", "values", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2124-L2138
132,307
hashicorp/nomad
nomad/structs/structs.go
Equals
func (n *Networks) Equals(o *Networks) bool { if n == o { return true } if n == nil || o == nil { return false } if len(*n) != len(*o) { return false } SETEQUALS: for _, ne := range *n { for _, oe := range *o { if ne.Equals(oe) { continue SETEQUALS } } return false } return true }
go
func (n *Networks) Equals(o *Networks) bool { if n == o { return true } if n == nil || o == nil { return false } if len(*n) != len(*o) { return false } SETEQUALS: for _, ne := range *n { for _, oe := range *o { if ne.Equals(oe) { continue SETEQUALS } } return false } return true }
[ "func", "(", "n", "*", "Networks", ")", "Equals", "(", "o", "*", "Networks", ")", "bool", "{", "if", "n", "==", "o", "{", "return", "true", "\n", "}", "\n", "if", "n", "==", "nil", "||", "o", "==", "nil", "{", "return", "false", "\n", "}", "\...
// Equals equates Networks as a set
[ "Equals", "equates", "Networks", "as", "a", "set" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2368-L2388
132,308
hashicorp/nomad
nomad/structs/structs.go
DevicesEquals
func DevicesEquals(d1, d2 []*NodeDeviceResource) bool { if len(d1) != len(d2) { return false } idMap := make(map[DeviceIdTuple]*NodeDeviceResource, len(d1)) for _, d := range d1 { idMap[*d.ID()] = d } for _, otherD := range d2 { if d, ok := idMap[*otherD.ID()]; !ok || !d.Equals(otherD) { return false }...
go
func DevicesEquals(d1, d2 []*NodeDeviceResource) bool { if len(d1) != len(d2) { return false } idMap := make(map[DeviceIdTuple]*NodeDeviceResource, len(d1)) for _, d := range d1 { idMap[*d.ID()] = d } for _, otherD := range d2 { if d, ok := idMap[*otherD.ID()]; !ok || !d.Equals(otherD) { return false }...
[ "func", "DevicesEquals", "(", "d1", ",", "d2", "[", "]", "*", "NodeDeviceResource", ")", "bool", "{", "if", "len", "(", "d1", ")", "!=", "len", "(", "d2", ")", "{", "return", "false", "\n", "}", "\n", "idMap", ":=", "make", "(", "map", "[", "Devi...
// DevicesEquals returns true if the two device arrays are set equal
[ "DevicesEquals", "returns", "true", "if", "the", "two", "device", "arrays", "are", "set", "equal" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2391-L2406
132,309
hashicorp/nomad
nomad/structs/structs.go
Matches
func (id *DeviceIdTuple) Matches(other *DeviceIdTuple) bool { if other == nil { return false } if other.Name != "" && other.Name != id.Name { return false } if other.Vendor != "" && other.Vendor != id.Vendor { return false } if other.Type != "" && other.Type != id.Type { return false } return true ...
go
func (id *DeviceIdTuple) Matches(other *DeviceIdTuple) bool { if other == nil { return false } if other.Name != "" && other.Name != id.Name { return false } if other.Vendor != "" && other.Vendor != id.Vendor { return false } if other.Type != "" && other.Type != id.Type { return false } return true ...
[ "func", "(", "id", "*", "DeviceIdTuple", ")", "Matches", "(", "other", "*", "DeviceIdTuple", ")", "bool", "{", "if", "other", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "other", ".", "Name", "!=", "\"", "\"", "&&", "other", ".", ...
// Matches returns if this Device ID is a superset of the passed ID.
[ "Matches", "returns", "if", "this", "Device", "ID", "is", "a", "superset", "of", "the", "passed", "ID", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2520-L2538
132,310
hashicorp/nomad
nomad/structs/structs.go
Equals
func (id *DeviceIdTuple) Equals(o *DeviceIdTuple) bool { if id == nil && o == nil { return true } else if id == nil || o == nil { return false } return o.Vendor == id.Vendor && o.Type == id.Type && o.Name == id.Name }
go
func (id *DeviceIdTuple) Equals(o *DeviceIdTuple) bool { if id == nil && o == nil { return true } else if id == nil || o == nil { return false } return o.Vendor == id.Vendor && o.Type == id.Type && o.Name == id.Name }
[ "func", "(", "id", "*", "DeviceIdTuple", ")", "Equals", "(", "o", "*", "DeviceIdTuple", ")", "bool", "{", "if", "id", "==", "nil", "&&", "o", "==", "nil", "{", "return", "true", "\n", "}", "else", "if", "id", "==", "nil", "||", "o", "==", "nil", ...
// Equals returns if this Device ID is the same as the passed ID.
[ "Equals", "returns", "if", "this", "Device", "ID", "is", "the", "same", "as", "the", "passed", "ID", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2541-L2549
132,311
hashicorp/nomad
nomad/structs/structs.go
Comparable
func (n *NodeReservedResources) Comparable() *ComparableResources { if n == nil { return nil } c := &ComparableResources{ Flattened: AllocatedTaskResources{ Cpu: AllocatedCpuResources{ CpuShares: n.Cpu.CpuShares, }, Memory: AllocatedMemoryResources{ MemoryMB: n.Memory.MemoryMB, }, }, Sha...
go
func (n *NodeReservedResources) Comparable() *ComparableResources { if n == nil { return nil } c := &ComparableResources{ Flattened: AllocatedTaskResources{ Cpu: AllocatedCpuResources{ CpuShares: n.Cpu.CpuShares, }, Memory: AllocatedMemoryResources{ MemoryMB: n.Memory.MemoryMB, }, }, Sha...
[ "func", "(", "n", "*", "NodeReservedResources", ")", "Comparable", "(", ")", "*", "ComparableResources", "{", "if", "n", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "c", ":=", "&", "ComparableResources", "{", "Flattened", ":", "AllocatedTaskResourc...
// Comparable returns a comparable version of the node's reserved resources. The // returned resources doesn't contain any network information. This conversion // can be lossy so care must be taken when using it.
[ "Comparable", "returns", "a", "comparable", "version", "of", "the", "node", "s", "reserved", "resources", ".", "The", "returned", "resources", "doesn", "t", "contain", "any", "network", "information", ".", "This", "conversion", "can", "be", "lossy", "so", "car...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2746-L2765
132,312
hashicorp/nomad
nomad/structs/structs.go
Comparable
func (a *AllocatedResources) Comparable() *ComparableResources { if a == nil { return nil } c := &ComparableResources{ Shared: a.Shared, } for _, r := range a.Tasks { c.Flattened.Add(r) } return c }
go
func (a *AllocatedResources) Comparable() *ComparableResources { if a == nil { return nil } c := &ComparableResources{ Shared: a.Shared, } for _, r := range a.Tasks { c.Flattened.Add(r) } return c }
[ "func", "(", "a", "*", "AllocatedResources", ")", "Comparable", "(", ")", "*", "ComparableResources", "{", "if", "a", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "c", ":=", "&", "ComparableResources", "{", "Shared", ":", "a", ".", "Shared", "...
// Comparable returns a comparable version of the allocations allocated // resources. This conversion can be lossy so care must be taken when using it.
[ "Comparable", "returns", "a", "comparable", "version", "of", "the", "allocations", "allocated", "resources", ".", "This", "conversion", "can", "be", "lossy", "so", "care", "must", "be", "taken", "when", "using", "it", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2824-L2836
132,313
hashicorp/nomad
nomad/structs/structs.go
OldTaskResources
func (a *AllocatedResources) OldTaskResources() map[string]*Resources { m := make(map[string]*Resources, len(a.Tasks)) for name, res := range a.Tasks { m[name] = &Resources{ CPU: int(res.Cpu.CpuShares), MemoryMB: int(res.Memory.MemoryMB), Networks: res.Networks, } } return m }
go
func (a *AllocatedResources) OldTaskResources() map[string]*Resources { m := make(map[string]*Resources, len(a.Tasks)) for name, res := range a.Tasks { m[name] = &Resources{ CPU: int(res.Cpu.CpuShares), MemoryMB: int(res.Memory.MemoryMB), Networks: res.Networks, } } return m }
[ "func", "(", "a", "*", "AllocatedResources", ")", "OldTaskResources", "(", ")", "map", "[", "string", "]", "*", "Resources", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "*", "Resources", ",", "len", "(", "a", ".", "Tasks", ")", ")", "\n...
// OldTaskResources returns the pre-0.9.0 map of task resources
[ "OldTaskResources", "returns", "the", "pre", "-", "0", ".", "9", ".", "0", "map", "of", "task", "resources" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2839-L2850
132,314
hashicorp/nomad
nomad/structs/structs.go
NetIndex
func (a *AllocatedTaskResources) NetIndex(n *NetworkResource) int { return a.Networks.NetIndex(n) }
go
func (a *AllocatedTaskResources) NetIndex(n *NetworkResource) int { return a.Networks.NetIndex(n) }
[ "func", "(", "a", "*", "AllocatedTaskResources", ")", "NetIndex", "(", "n", "*", "NetworkResource", ")", "int", "{", "return", "a", ".", "Networks", ".", "NetIndex", "(", "n", ")", "\n", "}" ]
// NetIndex finds the matching net index using device name
[ "NetIndex", "finds", "the", "matching", "net", "index", "using", "device", "name" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2889-L2891
132,315
hashicorp/nomad
nomad/structs/structs.go
Comparable
func (a *AllocatedTaskResources) Comparable() *ComparableResources { ret := &ComparableResources{ Flattened: AllocatedTaskResources{ Cpu: AllocatedCpuResources{ CpuShares: a.Cpu.CpuShares, }, Memory: AllocatedMemoryResources{ MemoryMB: a.Memory.MemoryMB, }, }, } if len(a.Networks) > 0 { for...
go
func (a *AllocatedTaskResources) Comparable() *ComparableResources { ret := &ComparableResources{ Flattened: AllocatedTaskResources{ Cpu: AllocatedCpuResources{ CpuShares: a.Cpu.CpuShares, }, Memory: AllocatedMemoryResources{ MemoryMB: a.Memory.MemoryMB, }, }, } if len(a.Networks) > 0 { for...
[ "func", "(", "a", "*", "AllocatedTaskResources", ")", "Comparable", "(", ")", "*", "ComparableResources", "{", "ret", ":=", "&", "ComparableResources", "{", "Flattened", ":", "AllocatedTaskResources", "{", "Cpu", ":", "AllocatedCpuResources", "{", "CpuShares", ":"...
// Comparable turns AllocatedTaskResources into ComparableResources // as a helper step in preemption
[ "Comparable", "turns", "AllocatedTaskResources", "into", "ComparableResources", "as", "a", "helper", "step", "in", "preemption" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2924-L2941
132,316
hashicorp/nomad
nomad/structs/structs.go
Subtract
func (a *AllocatedTaskResources) Subtract(delta *AllocatedTaskResources) { if delta == nil { return } a.Cpu.Subtract(&delta.Cpu) a.Memory.Subtract(&delta.Memory) }
go
func (a *AllocatedTaskResources) Subtract(delta *AllocatedTaskResources) { if delta == nil { return } a.Cpu.Subtract(&delta.Cpu) a.Memory.Subtract(&delta.Memory) }
[ "func", "(", "a", "*", "AllocatedTaskResources", ")", "Subtract", "(", "delta", "*", "AllocatedTaskResources", ")", "{", "if", "delta", "==", "nil", "{", "return", "\n", "}", "\n\n", "a", ".", "Cpu", ".", "Subtract", "(", "&", "delta", ".", "Cpu", ")",...
// Subtract only subtracts CPU and Memory resources. Network utilization // is managed separately in NetworkIndex
[ "Subtract", "only", "subtracts", "CPU", "and", "Memory", "resources", ".", "Network", "utilization", "is", "managed", "separately", "in", "NetworkIndex" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L2945-L2952
132,317
hashicorp/nomad
nomad/structs/structs.go
Index
func (a AllocatedDevices) Index(d *AllocatedDeviceResource) int { if d == nil { return -1 } for i, o := range a { if o.ID().Equals(d.ID()) { return i } } return -1 }
go
func (a AllocatedDevices) Index(d *AllocatedDeviceResource) int { if d == nil { return -1 } for i, o := range a { if o.ID().Equals(d.ID()) { return i } } return -1 }
[ "func", "(", "a", "AllocatedDevices", ")", "Index", "(", "d", "*", "AllocatedDeviceResource", ")", "int", "{", "if", "d", "==", "nil", "{", "return", "-", "1", "\n", "}", "\n\n", "for", "i", ",", "o", ":=", "range", "a", "{", "if", "o", ".", "ID"...
// Index finds the matching index using the passed device. If not found, -1 is // returned.
[ "Index", "finds", "the", "matching", "index", "using", "the", "passed", "device", ".", "If", "not", "found", "-", "1", "is", "returned", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3021-L3033
132,318
hashicorp/nomad
nomad/structs/structs.go
Superset
func (c *ComparableResources) Superset(other *ComparableResources) (bool, string) { if c.Flattened.Cpu.CpuShares < other.Flattened.Cpu.CpuShares { return false, "cpu" } if c.Flattened.Memory.MemoryMB < other.Flattened.Memory.MemoryMB { return false, "memory" } if c.Shared.DiskMB < other.Shared.DiskMB { retur...
go
func (c *ComparableResources) Superset(other *ComparableResources) (bool, string) { if c.Flattened.Cpu.CpuShares < other.Flattened.Cpu.CpuShares { return false, "cpu" } if c.Flattened.Memory.MemoryMB < other.Flattened.Memory.MemoryMB { return false, "memory" } if c.Shared.DiskMB < other.Shared.DiskMB { retur...
[ "func", "(", "c", "*", "ComparableResources", ")", "Superset", "(", "other", "*", "ComparableResources", ")", "(", "bool", ",", "string", ")", "{", "if", "c", ".", "Flattened", ".", "Cpu", ".", "CpuShares", "<", "other", ".", "Flattened", ".", "Cpu", "...
// Superset checks if one set of resources is a superset of another. This // ignores network resources, and the NetworkIndex should be used for that.
[ "Superset", "checks", "if", "one", "set", "of", "resources", "is", "a", "superset", "of", "another", ".", "This", "ignores", "network", "resources", "and", "the", "NetworkIndex", "should", "be", "used", "for", "that", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3119-L3130
132,319
hashicorp/nomad
nomad/structs/structs.go
NetIndex
func (c *ComparableResources) NetIndex(n *NetworkResource) int { return c.Flattened.Networks.NetIndex(n) }
go
func (c *ComparableResources) NetIndex(n *NetworkResource) int { return c.Flattened.Networks.NetIndex(n) }
[ "func", "(", "c", "*", "ComparableResources", ")", "NetIndex", "(", "n", "*", "NetworkResource", ")", "int", "{", "return", "c", ".", "Flattened", ".", "Networks", ".", "NetIndex", "(", "n", ")", "\n", "}" ]
// allocated finds the matching net index using device name
[ "allocated", "finds", "the", "matching", "net", "index", "using", "device", "name" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3133-L3135
132,320
hashicorp/nomad
nomad/structs/structs.go
NamespacedID
func (j *Job) NamespacedID() *NamespacedID { return &NamespacedID{ ID: j.ID, Namespace: j.Namespace, } }
go
func (j *Job) NamespacedID() *NamespacedID { return &NamespacedID{ ID: j.ID, Namespace: j.Namespace, } }
[ "func", "(", "j", "*", "Job", ")", "NamespacedID", "(", ")", "*", "NamespacedID", "{", "return", "&", "NamespacedID", "{", "ID", ":", "j", ".", "ID", ",", "Namespace", ":", "j", ".", "Namespace", ",", "}", "\n", "}" ]
// NamespacedID returns the namespaced id useful for logging
[ "NamespacedID", "returns", "the", "namespaced", "id", "useful", "for", "logging" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3287-L3292
132,321
hashicorp/nomad
nomad/structs/structs.go
Canonicalize
func (j *Job) Canonicalize() (warnings error) { if j == nil { return nil } var mErr multierror.Error // Ensure that an empty and nil map are treated the same to avoid scheduling // problems since we use reflect DeepEquals. if len(j.Meta) == 0 { j.Meta = nil } // Ensure the job is in a namespace. if j.Nam...
go
func (j *Job) Canonicalize() (warnings error) { if j == nil { return nil } var mErr multierror.Error // Ensure that an empty and nil map are treated the same to avoid scheduling // problems since we use reflect DeepEquals. if len(j.Meta) == 0 { j.Meta = nil } // Ensure the job is in a namespace. if j.Nam...
[ "func", "(", "j", "*", "Job", ")", "Canonicalize", "(", ")", "(", "warnings", "error", ")", "{", "if", "j", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "var", "mErr", "multierror", ".", "Error", "\n", "// Ensure that an empty and nil map are trea...
// Canonicalize is used to canonicalize fields in the Job. This should be called // when registering a Job. A set of warnings are returned if the job was changed // in anyway that the user should be made aware of.
[ "Canonicalize", "is", "used", "to", "canonicalize", "fields", "in", "the", "Job", ".", "This", "should", "be", "called", "when", "registering", "a", "Job", ".", "A", "set", "of", "warnings", "are", "returned", "if", "the", "job", "was", "changed", "in", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3297-L3327
132,322
hashicorp/nomad
nomad/structs/structs.go
Copy
func (j *Job) Copy() *Job { if j == nil { return nil } nj := new(Job) *nj = *j nj.Datacenters = helper.CopySliceString(nj.Datacenters) nj.Constraints = CopySliceConstraints(nj.Constraints) nj.Affinities = CopySliceAffinities(nj.Affinities) if j.TaskGroups != nil { tgs := make([]*TaskGroup, len(nj.TaskGroup...
go
func (j *Job) Copy() *Job { if j == nil { return nil } nj := new(Job) *nj = *j nj.Datacenters = helper.CopySliceString(nj.Datacenters) nj.Constraints = CopySliceConstraints(nj.Constraints) nj.Affinities = CopySliceAffinities(nj.Affinities) if j.TaskGroups != nil { tgs := make([]*TaskGroup, len(nj.TaskGroup...
[ "func", "(", "j", "*", "Job", ")", "Copy", "(", ")", "*", "Job", "{", "if", "j", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "nj", ":=", "new", "(", "Job", ")", "\n", "*", "nj", "=", "*", "j", "\n", "nj", ".", "Datacenters", "=", ...
// Copy returns a deep copy of the Job. It is expected that callers use recover. // This job can panic if the deep copy failed as it uses reflection.
[ "Copy", "returns", "a", "deep", "copy", "of", "the", "Job", ".", "It", "is", "expected", "that", "callers", "use", "recover", ".", "This", "job", "can", "panic", "if", "the", "deep", "copy", "failed", "as", "it", "uses", "reflection", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3331-L3353
132,323
hashicorp/nomad
nomad/structs/structs.go
LookupTaskGroup
func (j *Job) LookupTaskGroup(name string) *TaskGroup { for _, tg := range j.TaskGroups { if tg.Name == name { return tg } } return nil }
go
func (j *Job) LookupTaskGroup(name string) *TaskGroup { for _, tg := range j.TaskGroups { if tg.Name == name { return tg } } return nil }
[ "func", "(", "j", "*", "Job", ")", "LookupTaskGroup", "(", "name", "string", ")", "*", "TaskGroup", "{", "for", "_", ",", "tg", ":=", "range", "j", ".", "TaskGroups", "{", "if", "tg", ".", "Name", "==", "name", "{", "return", "tg", "\n", "}", "\n...
// LookupTaskGroup finds a task group by name
[ "LookupTaskGroup", "finds", "a", "task", "group", "by", "name" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3490-L3497
132,324
hashicorp/nomad
nomad/structs/structs.go
HasUpdateStrategy
func (j *Job) HasUpdateStrategy() bool { for _, tg := range j.TaskGroups { if tg.Update != nil { return true } } return false }
go
func (j *Job) HasUpdateStrategy() bool { for _, tg := range j.TaskGroups { if tg.Update != nil { return true } } return false }
[ "func", "(", "j", "*", "Job", ")", "HasUpdateStrategy", "(", ")", "bool", "{", "for", "_", ",", "tg", ":=", "range", "j", ".", "TaskGroups", "{", "if", "tg", ".", "Update", "!=", "nil", "{", "return", "true", "\n", "}", "\n", "}", "\n\n", "return...
// HasUpdateStrategy returns if any task group in the job has an update strategy
[ "HasUpdateStrategy", "returns", "if", "any", "task", "group", "in", "the", "job", "has", "an", "update", "strategy" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3541-L3549
132,325
hashicorp/nomad
nomad/structs/structs.go
Stub
func (j *Job) Stub(summary *JobSummary) *JobListStub { return &JobListStub{ ID: j.ID, ParentID: j.ParentID, Name: j.Name, Datacenters: j.Datacenters, Type: j.Type, Priority: j.Priority, Periodic: j.IsPeriodic(), ParameterizedJob:...
go
func (j *Job) Stub(summary *JobSummary) *JobListStub { return &JobListStub{ ID: j.ID, ParentID: j.ParentID, Name: j.Name, Datacenters: j.Datacenters, Type: j.Type, Priority: j.Priority, Periodic: j.IsPeriodic(), ParameterizedJob:...
[ "func", "(", "j", "*", "Job", ")", "Stub", "(", "summary", "*", "JobSummary", ")", "*", "JobListStub", "{", "return", "&", "JobListStub", "{", "ID", ":", "j", ".", "ID", ",", "ParentID", ":", "j", ".", "ParentID", ",", "Name", ":", "j", ".", "Nam...
// Stub is used to return a summary of the job
[ "Stub", "is", "used", "to", "return", "a", "summary", "of", "the", "job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3552-L3571
132,326
hashicorp/nomad
nomad/structs/structs.go
IsPeriodicActive
func (j *Job) IsPeriodicActive() bool { return j.IsPeriodic() && j.Periodic.Enabled && !j.Stopped() && !j.IsParameterized() }
go
func (j *Job) IsPeriodicActive() bool { return j.IsPeriodic() && j.Periodic.Enabled && !j.Stopped() && !j.IsParameterized() }
[ "func", "(", "j", "*", "Job", ")", "IsPeriodicActive", "(", ")", "bool", "{", "return", "j", ".", "IsPeriodic", "(", ")", "&&", "j", ".", "Periodic", ".", "Enabled", "&&", "!", "j", ".", "Stopped", "(", ")", "&&", "!", "j", ".", "IsParameterized", ...
// IsPeriodicActive returns whether the job is an active periodic job that will // create child jobs
[ "IsPeriodicActive", "returns", "whether", "the", "job", "is", "an", "active", "periodic", "job", "that", "will", "create", "child", "jobs" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3580-L3582
132,327
hashicorp/nomad
nomad/structs/structs.go
VaultPolicies
func (j *Job) VaultPolicies() map[string]map[string]*Vault { policies := make(map[string]map[string]*Vault, len(j.TaskGroups)) for _, tg := range j.TaskGroups { tgPolicies := make(map[string]*Vault, len(tg.Tasks)) for _, task := range tg.Tasks { if task.Vault == nil { continue } tgPolicies[task.Na...
go
func (j *Job) VaultPolicies() map[string]map[string]*Vault { policies := make(map[string]map[string]*Vault, len(j.TaskGroups)) for _, tg := range j.TaskGroups { tgPolicies := make(map[string]*Vault, len(tg.Tasks)) for _, task := range tg.Tasks { if task.Vault == nil { continue } tgPolicies[task.Na...
[ "func", "(", "j", "*", "Job", ")", "VaultPolicies", "(", ")", "map", "[", "string", "]", "map", "[", "string", "]", "*", "Vault", "{", "policies", ":=", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "*", "Vault", ",", "len", ...
// VaultPolicies returns the set of Vault policies per task group, per task
[ "VaultPolicies", "returns", "the", "set", "of", "Vault", "policies", "per", "task", "group", "per", "task" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3590-L3610
132,328
hashicorp/nomad
nomad/structs/structs.go
RequiredSignals
func (j *Job) RequiredSignals() map[string]map[string][]string { signals := make(map[string]map[string][]string) for _, tg := range j.TaskGroups { for _, task := range tg.Tasks { // Use this local one as a set taskSignals := make(map[string]struct{}) // Check if the Vault change mode uses signals if t...
go
func (j *Job) RequiredSignals() map[string]map[string][]string { signals := make(map[string]map[string][]string) for _, tg := range j.TaskGroups { for _, task := range tg.Tasks { // Use this local one as a set taskSignals := make(map[string]struct{}) // Check if the Vault change mode uses signals if t...
[ "func", "(", "j", "*", "Job", ")", "RequiredSignals", "(", ")", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "string", "{", "signals", ":=", "make", "(", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "string",...
// RequiredSignals returns a mapping of task groups to tasks to their required // set of signals
[ "RequiredSignals", "returns", "a", "mapping", "of", "task", "groups", "to", "tasks", "to", "their", "required", "set", "of", "signals" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3614-L3664
132,329
hashicorp/nomad
nomad/structs/structs.go
SpecChanged
func (j *Job) SpecChanged(new *Job) bool { if j == nil { return new != nil } // Create a copy of the new job c := new.Copy() // Update the new job so we can do a reflect c.Status = j.Status c.StatusDescription = j.StatusDescription c.Stable = j.Stable c.Version = j.Version c.CreateIndex = j.CreateIndex c...
go
func (j *Job) SpecChanged(new *Job) bool { if j == nil { return new != nil } // Create a copy of the new job c := new.Copy() // Update the new job so we can do a reflect c.Status = j.Status c.StatusDescription = j.StatusDescription c.Stable = j.Stable c.Version = j.Version c.CreateIndex = j.CreateIndex c...
[ "func", "(", "j", "*", "Job", ")", "SpecChanged", "(", "new", "*", "Job", ")", "bool", "{", "if", "j", "==", "nil", "{", "return", "new", "!=", "nil", "\n", "}", "\n\n", "// Create a copy of the new job", "c", ":=", "new", ".", "Copy", "(", ")", "\...
// SpecChanged determines if the functional specification has changed between // two job versions.
[ "SpecChanged", "determines", "if", "the", "functional", "specification", "has", "changed", "between", "two", "job", "versions", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3668-L3688
132,330
hashicorp/nomad
nomad/structs/structs.go
Copy
func (js *JobSummary) Copy() *JobSummary { newJobSummary := new(JobSummary) *newJobSummary = *js newTGSummary := make(map[string]TaskGroupSummary, len(js.Summary)) for k, v := range js.Summary { newTGSummary[k] = v } newJobSummary.Summary = newTGSummary newJobSummary.Children = newJobSummary.Children.Copy() r...
go
func (js *JobSummary) Copy() *JobSummary { newJobSummary := new(JobSummary) *newJobSummary = *js newTGSummary := make(map[string]TaskGroupSummary, len(js.Summary)) for k, v := range js.Summary { newTGSummary[k] = v } newJobSummary.Summary = newTGSummary newJobSummary.Children = newJobSummary.Children.Copy() r...
[ "func", "(", "js", "*", "JobSummary", ")", "Copy", "(", ")", "*", "JobSummary", "{", "newJobSummary", ":=", "new", "(", "JobSummary", ")", "\n", "*", "newJobSummary", "=", "*", "js", "\n", "newTGSummary", ":=", "make", "(", "map", "[", "string", "]", ...
// Copy returns a new copy of JobSummary
[ "Copy", "returns", "a", "new", "copy", "of", "JobSummary" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3735-L3745
132,331
hashicorp/nomad
nomad/structs/structs.go
Copy
func (jc *JobChildrenSummary) Copy() *JobChildrenSummary { if jc == nil { return nil } njc := new(JobChildrenSummary) *njc = *jc return njc }
go
func (jc *JobChildrenSummary) Copy() *JobChildrenSummary { if jc == nil { return nil } njc := new(JobChildrenSummary) *njc = *jc return njc }
[ "func", "(", "jc", "*", "JobChildrenSummary", ")", "Copy", "(", ")", "*", "JobChildrenSummary", "{", "if", "jc", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "njc", ":=", "new", "(", "JobChildrenSummary", ")", "\n", "*", "njc", "=", "*", "jc...
// Copy returns a new copy of a JobChildrenSummary
[ "Copy", "returns", "a", "new", "copy", "of", "a", "JobChildrenSummary" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L3755-L3763
132,332
hashicorp/nomad
nomad/structs/structs.go
GetLocation
func (p *PeriodicConfig) GetLocation() *time.Location { // Jobs pre 0.5.5 will not have this if p.location != nil { return p.location } return time.UTC }
go
func (p *PeriodicConfig) GetLocation() *time.Location { // Jobs pre 0.5.5 will not have this if p.location != nil { return p.location } return time.UTC }
[ "func", "(", "p", "*", "PeriodicConfig", ")", "GetLocation", "(", ")", "*", "time", ".", "Location", "{", "// Jobs pre 0.5.5 will not have this", "if", "p", ".", "location", "!=", "nil", "{", "return", "p", ".", "location", "\n", "}", "\n\n", "return", "ti...
// GetLocation returns the location to use for determining the time zone to run // the periodic job against.
[ "GetLocation", "returns", "the", "location", "to", "use", "for", "determining", "the", "time", "zone", "to", "run", "the", "periodic", "job", "against", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L4040-L4047
132,333
hashicorp/nomad
nomad/structs/structs.go
DispatchedID
func DispatchedID(templateID string, t time.Time) string { u := uuid.Generate()[:8] return fmt.Sprintf("%s%s%d-%s", templateID, DispatchLaunchSuffix, t.Unix(), u) }
go
func DispatchedID(templateID string, t time.Time) string { u := uuid.Generate()[:8] return fmt.Sprintf("%s%s%d-%s", templateID, DispatchLaunchSuffix, t.Unix(), u) }
[ "func", "DispatchedID", "(", "templateID", "string", ",", "t", "time", ".", "Time", ")", "string", "{", "u", ":=", "uuid", ".", "Generate", "(", ")", "[", ":", "8", "]", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "templateID", ","...
// DispatchedID returns an ID appropriate for a job dispatched against a // particular parameterized job
[ "DispatchedID", "returns", "an", "ID", "appropriate", "for", "a", "job", "dispatched", "against", "a", "particular", "parameterized", "job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L4124-L4127
132,334
hashicorp/nomad
nomad/structs/structs.go
Validate
func (r *ReschedulePolicy) Validate() error { if !r.Enabled() { return nil } var mErr multierror.Error // Check for ambiguous/confusing settings if r.Attempts > 0 { if r.Interval <= 0 { multierror.Append(&mErr, fmt.Errorf("Interval must be a non zero value if Attempts > 0")) } if r.Unlimited { multie...
go
func (r *ReschedulePolicy) Validate() error { if !r.Enabled() { return nil } var mErr multierror.Error // Check for ambiguous/confusing settings if r.Attempts > 0 { if r.Interval <= 0 { multierror.Append(&mErr, fmt.Errorf("Interval must be a non zero value if Attempts > 0")) } if r.Unlimited { multie...
[ "func", "(", "r", "*", "ReschedulePolicy", ")", "Validate", "(", ")", "error", "{", "if", "!", "r", ".", "Enabled", "(", ")", "{", "return", "nil", "\n", "}", "\n", "var", "mErr", "multierror", ".", "Error", "\n", "// Check for ambiguous/confusing settings...
// Validate uses different criteria to validate the reschedule policy // Delay must be a minimum of 5 seconds // Delay Ceiling is ignored if Delay Function is "constant" // Number of possible attempts is validated, given the interval, delay and delay function
[ "Validate", "uses", "different", "criteria", "to", "validate", "the", "reschedule", "policy", "Delay", "must", "be", "a", "minimum", "of", "5", "seconds", "Delay", "Ceiling", "is", "ignored", "if", "Delay", "Function", "is", "constant", "Number", "of", "possib...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L4317-L4375
132,335
hashicorp/nomad
nomad/structs/structs.go
Canonicalize
func (tg *TaskGroup) Canonicalize(job *Job) { // Ensure that an empty and nil map are treated the same to avoid scheduling // problems since we use reflect DeepEquals. if len(tg.Meta) == 0 { tg.Meta = nil } // Set the default restart policy. if tg.RestartPolicy == nil { tg.RestartPolicy = NewRestartPolicy(jo...
go
func (tg *TaskGroup) Canonicalize(job *Job) { // Ensure that an empty and nil map are treated the same to avoid scheduling // problems since we use reflect DeepEquals. if len(tg.Meta) == 0 { tg.Meta = nil } // Set the default restart policy. if tg.RestartPolicy == nil { tg.RestartPolicy = NewRestartPolicy(jo...
[ "func", "(", "tg", "*", "TaskGroup", ")", "Canonicalize", "(", "job", "*", "Job", ")", "{", "// Ensure that an empty and nil map are treated the same to avoid scheduling", "// problems since we use reflect DeepEquals.", "if", "len", "(", "tg", ".", "Meta", ")", "==", "0...
// Canonicalize is used to canonicalize fields in the TaskGroup.
[ "Canonicalize", "is", "used", "to", "canonicalize", "fields", "in", "the", "TaskGroup", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L4616-L4645
132,336
hashicorp/nomad
nomad/structs/structs.go
LookupTask
func (tg *TaskGroup) LookupTask(name string) *Task { for _, t := range tg.Tasks { if t.Name == name { return t } } return nil }
go
func (tg *TaskGroup) LookupTask(name string) *Task { for _, t := range tg.Tasks { if t.Name == name { return t } } return nil }
[ "func", "(", "tg", "*", "TaskGroup", ")", "LookupTask", "(", "name", "string", ")", "*", "Task", "{", "for", "_", ",", "t", ":=", "range", "tg", ".", "Tasks", "{", "if", "t", ".", "Name", "==", "name", "{", "return", "t", "\n", "}", "\n", "}", ...
// LookupTask finds a task by name
[ "LookupTask", "finds", "a", "task", "by", "name" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L4821-L4828
132,337
hashicorp/nomad
nomad/structs/structs.go
validate
func (sc *ServiceCheck) validate() error { // Validate Type switch strings.ToLower(sc.Type) { case ServiceCheckGRPC: case ServiceCheckTCP: case ServiceCheckHTTP: if sc.Path == "" { return fmt.Errorf("http type must have a valid http path") } url, err := url.Parse(sc.Path) if err != nil { return fmt.E...
go
func (sc *ServiceCheck) validate() error { // Validate Type switch strings.ToLower(sc.Type) { case ServiceCheckGRPC: case ServiceCheckTCP: case ServiceCheckHTTP: if sc.Path == "" { return fmt.Errorf("http type must have a valid http path") } url, err := url.Parse(sc.Path) if err != nil { return fmt.E...
[ "func", "(", "sc", "*", "ServiceCheck", ")", "validate", "(", ")", "error", "{", "// Validate Type", "switch", "strings", ".", "ToLower", "(", "sc", ".", "Type", ")", "{", "case", "ServiceCheckGRPC", ":", "case", "ServiceCheckTCP", ":", "case", "ServiceCheck...
// validate a Service's ServiceCheck
[ "validate", "a", "Service", "s", "ServiceCheck" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L4942-L5003
132,338
hashicorp/nomad
nomad/structs/structs.go
RequiresPort
func (sc *ServiceCheck) RequiresPort() bool { switch sc.Type { case ServiceCheckGRPC, ServiceCheckHTTP, ServiceCheckTCP: return true default: return false } }
go
func (sc *ServiceCheck) RequiresPort() bool { switch sc.Type { case ServiceCheckGRPC, ServiceCheckHTTP, ServiceCheckTCP: return true default: return false } }
[ "func", "(", "sc", "*", "ServiceCheck", ")", "RequiresPort", "(", ")", "bool", "{", "switch", "sc", ".", "Type", "{", "case", "ServiceCheckGRPC", ",", "ServiceCheckHTTP", ",", "ServiceCheckTCP", ":", "return", "true", "\n", "default", ":", "return", "false",...
// RequiresPort returns whether the service check requires the task has a port.
[ "RequiresPort", "returns", "whether", "the", "service", "check", "requires", "the", "task", "has", "a", "port", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5006-L5013
132,339
hashicorp/nomad
nomad/structs/structs.go
TriggersRestarts
func (sc *ServiceCheck) TriggersRestarts() bool { return sc.CheckRestart != nil && sc.CheckRestart.Limit > 0 }
go
func (sc *ServiceCheck) TriggersRestarts() bool { return sc.CheckRestart != nil && sc.CheckRestart.Limit > 0 }
[ "func", "(", "sc", "*", "ServiceCheck", ")", "TriggersRestarts", "(", ")", "bool", "{", "return", "sc", ".", "CheckRestart", "!=", "nil", "&&", "sc", ".", "CheckRestart", ".", "Limit", ">", "0", "\n", "}" ]
// TriggersRestarts returns true if this check should be watched and trigger a restart // on failure.
[ "TriggersRestarts", "returns", "true", "if", "this", "check", "should", "be", "watched", "and", "trigger", "a", "restart", "on", "failure", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5017-L5019
132,340
hashicorp/nomad
nomad/structs/structs.go
Hash
func (sc *ServiceCheck) Hash(serviceID string) string { h := sha1.New() io.WriteString(h, serviceID) io.WriteString(h, sc.Name) io.WriteString(h, sc.Type) io.WriteString(h, sc.Command) io.WriteString(h, strings.Join(sc.Args, "")) io.WriteString(h, sc.Path) io.WriteString(h, sc.Protocol) io.WriteString(h, sc.Po...
go
func (sc *ServiceCheck) Hash(serviceID string) string { h := sha1.New() io.WriteString(h, serviceID) io.WriteString(h, sc.Name) io.WriteString(h, sc.Type) io.WriteString(h, sc.Command) io.WriteString(h, strings.Join(sc.Args, "")) io.WriteString(h, sc.Path) io.WriteString(h, sc.Protocol) io.WriteString(h, sc.Po...
[ "func", "(", "sc", "*", "ServiceCheck", ")", "Hash", "(", "serviceID", "string", ")", "string", "{", "h", ":=", "sha1", ".", "New", "(", ")", "\n", "io", ".", "WriteString", "(", "h", ",", "serviceID", ")", "\n", "io", ".", "WriteString", "(", "h",...
// Hash all ServiceCheck fields and the check's corresponding service ID to // create an identifier. The identifier is not guaranteed to be unique as if // the PortLabel is blank, the Service's PortLabel will be used after Hash is // called.
[ "Hash", "all", "ServiceCheck", "fields", "and", "the", "check", "s", "corresponding", "service", "ID", "to", "create", "an", "identifier", ".", "The", "identifier", "is", "not", "guaranteed", "to", "be", "unique", "as", "if", "the", "PortLabel", "is", "blank...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5025-L5068
132,341
hashicorp/nomad
nomad/structs/structs.go
Canonicalize
func (s *Service) Canonicalize(job string, taskGroup string, task string) { // Ensure empty lists are treated as null to avoid scheduler issues when // using DeepEquals if len(s.Tags) == 0 { s.Tags = nil } if len(s.CanaryTags) == 0 { s.CanaryTags = nil } if len(s.Checks) == 0 { s.Checks = nil } s.Name =...
go
func (s *Service) Canonicalize(job string, taskGroup string, task string) { // Ensure empty lists are treated as null to avoid scheduler issues when // using DeepEquals if len(s.Tags) == 0 { s.Tags = nil } if len(s.CanaryTags) == 0 { s.CanaryTags = nil } if len(s.Checks) == 0 { s.Checks = nil } s.Name =...
[ "func", "(", "s", "*", "Service", ")", "Canonicalize", "(", "job", "string", ",", "taskGroup", "string", ",", "task", "string", ")", "{", "// Ensure empty lists are treated as null to avoid scheduler issues when", "// using DeepEquals", "if", "len", "(", "s", ".", "...
// Canonicalize interpolates values of Job, Task Group and Task in the Service // Name. This also generates check names, service id and check ids.
[ "Canonicalize", "interpolates", "values", "of", "Job", "Task", "Group", "and", "Task", "in", "the", "Service", "Name", ".", "This", "also", "generates", "check", "names", "service", "id", "and", "check", "ids", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5119-L5143
132,342
hashicorp/nomad
nomad/structs/structs.go
Validate
func (s *Service) Validate() error { var mErr multierror.Error // Ensure the service name is valid per the below RFCs but make an exception // for our interpolation syntax by first stripping any environment variables from the name serviceNameStripped := args.ReplaceEnvWithPlaceHolder(s.Name, "ENV-VAR") if err :...
go
func (s *Service) Validate() error { var mErr multierror.Error // Ensure the service name is valid per the below RFCs but make an exception // for our interpolation syntax by first stripping any environment variables from the name serviceNameStripped := args.ReplaceEnvWithPlaceHolder(s.Name, "ENV-VAR") if err :...
[ "func", "(", "s", "*", "Service", ")", "Validate", "(", ")", "error", "{", "var", "mErr", "multierror", ".", "Error", "\n\n", "// Ensure the service name is valid per the below RFCs but make an exception", "// for our interpolation syntax by first stripping any environment variab...
// Validate checks if the Check definition is valid
[ "Validate", "checks", "if", "the", "Check", "definition", "is", "valid" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5146-L5177
132,343
hashicorp/nomad
nomad/structs/structs.go
ValidateName
func (s *Service) ValidateName(name string) error { // Ensure the service name is valid per RFC-952 §1 // (https://tools.ietf.org/html/rfc952), RFC-1123 §2.1 // (https://tools.ietf.org/html/rfc1123), and RFC-2782 // (https://tools.ietf.org/html/rfc2782). re := regexp.MustCompile(`^(?i:[a-z0-9]|[a-z0-9][a-z0-9\-]{0...
go
func (s *Service) ValidateName(name string) error { // Ensure the service name is valid per RFC-952 §1 // (https://tools.ietf.org/html/rfc952), RFC-1123 §2.1 // (https://tools.ietf.org/html/rfc1123), and RFC-2782 // (https://tools.ietf.org/html/rfc2782). re := regexp.MustCompile(`^(?i:[a-z0-9]|[a-z0-9][a-z0-9\-]{0...
[ "func", "(", "s", "*", "Service", ")", "ValidateName", "(", "name", "string", ")", "error", "{", "// Ensure the service name is valid per RFC-952 §1", "// (https://tools.ietf.org/html/rfc952), RFC-1123 §2.1", "// (https://tools.ietf.org/html/rfc1123), and RFC-2782", "// (https://tool...
// ValidateName checks if the services Name is valid and should be called after // the name has been interpolated
[ "ValidateName", "checks", "if", "the", "services", "Name", "is", "valid", "and", "should", "be", "called", "after", "the", "name", "has", "been", "interpolated" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5181-L5191
132,344
hashicorp/nomad
nomad/structs/structs.go
Hash
func (s *Service) Hash(allocID, taskName string, canary bool) string { h := sha1.New() io.WriteString(h, allocID) io.WriteString(h, taskName) io.WriteString(h, s.Name) io.WriteString(h, s.PortLabel) io.WriteString(h, s.AddressMode) for _, tag := range s.Tags { io.WriteString(h, tag) } for _, tag := range s.C...
go
func (s *Service) Hash(allocID, taskName string, canary bool) string { h := sha1.New() io.WriteString(h, allocID) io.WriteString(h, taskName) io.WriteString(h, s.Name) io.WriteString(h, s.PortLabel) io.WriteString(h, s.AddressMode) for _, tag := range s.Tags { io.WriteString(h, tag) } for _, tag := range s.C...
[ "func", "(", "s", "*", "Service", ")", "Hash", "(", "allocID", ",", "taskName", "string", ",", "canary", "bool", ")", "string", "{", "h", ":=", "sha1", ".", "New", "(", ")", "\n", "io", ".", "WriteString", "(", "h", ",", "allocID", ")", "\n", "io...
// Hash returns a base32 encoded hash of a Service's contents excluding checks // as they're hashed independently.
[ "Hash", "returns", "a", "base32", "encoded", "hash", "of", "a", "Service", "s", "contents", "excluding", "checks", "as", "they", "re", "hashed", "independently", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5195-L5219
132,345
hashicorp/nomad
nomad/structs/structs.go
Validate
func (l *LogConfig) Validate() error { var mErr multierror.Error if l.MaxFiles < 1 { mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum number of files is 1; got %d", l.MaxFiles)) } if l.MaxFileSizeMB < 1 { mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum file size is 1MB; got %d", l.MaxFileSizeMB)) } ...
go
func (l *LogConfig) Validate() error { var mErr multierror.Error if l.MaxFiles < 1 { mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum number of files is 1; got %d", l.MaxFiles)) } if l.MaxFileSizeMB < 1 { mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum file size is 1MB; got %d", l.MaxFileSizeMB)) } ...
[ "func", "(", "l", "*", "LogConfig", ")", "Validate", "(", ")", "error", "{", "var", "mErr", "multierror", ".", "Error", "\n", "if", "l", ".", "MaxFiles", "<", "1", "{", "mErr", ".", "Errors", "=", "append", "(", "mErr", ".", "Errors", ",", "fmt", ...
// Validate returns an error if the log config specified are less than // the minimum allowed.
[ "Validate", "returns", "an", "error", "if", "the", "log", "config", "specified", "are", "less", "than", "the", "minimum", "allowed", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5243-L5252
132,346
hashicorp/nomad
nomad/structs/structs.go
Canonicalize
func (t *Task) Canonicalize(job *Job, tg *TaskGroup) { // Ensure that an empty and nil map are treated the same to avoid scheduling // problems since we use reflect DeepEquals. if len(t.Meta) == 0 { t.Meta = nil } if len(t.Config) == 0 { t.Config = nil } if len(t.Env) == 0 { t.Env = nil } for _, service...
go
func (t *Task) Canonicalize(job *Job, tg *TaskGroup) { // Ensure that an empty and nil map are treated the same to avoid scheduling // problems since we use reflect DeepEquals. if len(t.Meta) == 0 { t.Meta = nil } if len(t.Config) == 0 { t.Config = nil } if len(t.Env) == 0 { t.Env = nil } for _, service...
[ "func", "(", "t", "*", "Task", ")", "Canonicalize", "(", "job", "*", "Job", ",", "tg", "*", "TaskGroup", ")", "{", "// Ensure that an empty and nil map are treated the same to avoid scheduling", "// problems since we use reflect DeepEquals.", "if", "len", "(", "t", ".",...
// Canonicalize canonicalizes fields in the task.
[ "Canonicalize", "canonicalizes", "fields", "in", "the", "task", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L5376-L5412
132,347
hashicorp/nomad
nomad/structs/structs.go
SetDisplayMessage
func (te *TaskEvent) SetDisplayMessage(msg string) *TaskEvent { te.DisplayMessage = msg return te }
go
func (te *TaskEvent) SetDisplayMessage(msg string) *TaskEvent { te.DisplayMessage = msg return te }
[ "func", "(", "te", "*", "TaskEvent", ")", "SetDisplayMessage", "(", "msg", "string", ")", "*", "TaskEvent", "{", "te", ".", "DisplayMessage", "=", "msg", "\n", "return", "te", "\n", "}" ]
// SetDisplayMessage sets the display message of TaskEvent
[ "SetDisplayMessage", "sets", "the", "display", "message", "of", "TaskEvent" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6190-L6193
132,348
hashicorp/nomad
nomad/structs/structs.go
SetMessage
func (te *TaskEvent) SetMessage(msg string) *TaskEvent { te.Message = msg te.Details["message"] = msg return te }
go
func (te *TaskEvent) SetMessage(msg string) *TaskEvent { te.Message = msg te.Details["message"] = msg return te }
[ "func", "(", "te", "*", "TaskEvent", ")", "SetMessage", "(", "msg", "string", ")", "*", "TaskEvent", "{", "te", ".", "Message", "=", "msg", "\n", "te", ".", "Details", "[", "\"", "\"", "]", "=", "msg", "\n", "return", "te", "\n", "}" ]
// SetMessage sets the message of TaskEvent
[ "SetMessage", "sets", "the", "message", "of", "TaskEvent" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6196-L6200
132,349
hashicorp/nomad
nomad/structs/structs.go
SetSetupError
func (e *TaskEvent) SetSetupError(err error) *TaskEvent { if err != nil { e.SetupError = err.Error() e.Details["setup_error"] = err.Error() } return e }
go
func (e *TaskEvent) SetSetupError(err error) *TaskEvent { if err != nil { e.SetupError = err.Error() e.Details["setup_error"] = err.Error() } return e }
[ "func", "(", "e", "*", "TaskEvent", ")", "SetSetupError", "(", "err", "error", ")", "*", "TaskEvent", "{", "if", "err", "!=", "nil", "{", "e", ".", "SetupError", "=", "err", ".", "Error", "(", ")", "\n", "e", ".", "Details", "[", "\"", "\"", "]",...
// SetSetupError is used to store an error that occurred while setting up the // task
[ "SetSetupError", "is", "used", "to", "store", "an", "error", "that", "occurred", "while", "setting", "up", "the", "task" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6221-L6227
132,350
hashicorp/nomad
nomad/structs/structs.go
Hash
func (ta *TaskArtifact) Hash() string { hash, err := blake2b.New256(nil) if err != nil { panic(err) } hash.Write([]byte(ta.GetterSource)) // Must iterate over keys in a consistent order keys := make([]string, 0, len(ta.GetterOptions)) for k := range ta.GetterOptions { keys = append(keys, k) } sort.String...
go
func (ta *TaskArtifact) Hash() string { hash, err := blake2b.New256(nil) if err != nil { panic(err) } hash.Write([]byte(ta.GetterSource)) // Must iterate over keys in a consistent order keys := make([]string, 0, len(ta.GetterOptions)) for k := range ta.GetterOptions { keys = append(keys, k) } sort.String...
[ "func", "(", "ta", "*", "TaskArtifact", ")", "Hash", "(", ")", "string", "{", "hash", ",", "err", ":=", "blake2b", ".", "New256", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "hash", ".", "W...
// Hash creates a unique identifier for a TaskArtifact as the same GetterSource // may be specified multiple times with different destinations.
[ "Hash", "creates", "a", "unique", "identifier", "for", "a", "TaskArtifact", "as", "the", "same", "GetterSource", "may", "be", "specified", "multiple", "times", "with", "different", "destinations", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6393-L6415
132,351
hashicorp/nomad
nomad/structs/structs.go
Equals
func (c *Constraint) Equals(o *Constraint) bool { return c == o || c.LTarget == o.LTarget && c.RTarget == o.RTarget && c.Operand == o.Operand }
go
func (c *Constraint) Equals(o *Constraint) bool { return c == o || c.LTarget == o.LTarget && c.RTarget == o.RTarget && c.Operand == o.Operand }
[ "func", "(", "c", "*", "Constraint", ")", "Equals", "(", "o", "*", "Constraint", ")", "bool", "{", "return", "c", "==", "o", "||", "c", ".", "LTarget", "==", "o", ".", "LTarget", "&&", "c", ".", "RTarget", "==", "o", ".", "RTarget", "&&", "c", ...
// Equal checks if two constraints are equal
[ "Equal", "checks", "if", "two", "constraints", "are", "equal" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6543-L6548
132,352
hashicorp/nomad
nomad/structs/structs.go
Equals
func (a *Affinity) Equals(o *Affinity) bool { return a == o || a.LTarget == o.LTarget && a.RTarget == o.RTarget && a.Operand == o.Operand && a.Weight == o.Weight }
go
func (a *Affinity) Equals(o *Affinity) bool { return a == o || a.LTarget == o.LTarget && a.RTarget == o.RTarget && a.Operand == o.Operand && a.Weight == o.Weight }
[ "func", "(", "a", "*", "Affinity", ")", "Equals", "(", "o", "*", "Affinity", ")", "bool", "{", "return", "a", "==", "o", "||", "a", ".", "LTarget", "==", "o", ".", "LTarget", "&&", "a", ".", "RTarget", "==", "o", ".", "RTarget", "&&", "a", ".",...
// Equal checks if two affinities are equal
[ "Equal", "checks", "if", "two", "affinities", "are", "equal" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6662-L6668
132,353
hashicorp/nomad
nomad/structs/structs.go
Equals
func (xs *Affinities) Equals(ys *Affinities) bool { if xs == ys { return true } if xs == nil || ys == nil { return false } if len(*xs) != len(*ys) { return false } SETEQUALS: for _, x := range *xs { for _, y := range *ys { if x.Equals(y) { continue SETEQUALS } } return false } return true...
go
func (xs *Affinities) Equals(ys *Affinities) bool { if xs == ys { return true } if xs == nil || ys == nil { return false } if len(*xs) != len(*ys) { return false } SETEQUALS: for _, x := range *xs { for _, y := range *ys { if x.Equals(y) { continue SETEQUALS } } return false } return true...
[ "func", "(", "xs", "*", "Affinities", ")", "Equals", "(", "ys", "*", "Affinities", ")", "bool", "{", "if", "xs", "==", "ys", "{", "return", "true", "\n", "}", "\n", "if", "xs", "==", "nil", "||", "ys", "==", "nil", "{", "return", "false", "\n", ...
// Equals compares Affinities as a set
[ "Equals", "compares", "Affinities", "as", "a", "set" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6755-L6775
132,354
hashicorp/nomad
nomad/structs/structs.go
Validate
func (d *EphemeralDisk) Validate() error { if d.SizeMB < 10 { return fmt.Errorf("minimum DiskMB value is 10; got %d", d.SizeMB) } return nil }
go
func (d *EphemeralDisk) Validate() error { if d.SizeMB < 10 { return fmt.Errorf("minimum DiskMB value is 10; got %d", d.SizeMB) } return nil }
[ "func", "(", "d", "*", "EphemeralDisk", ")", "Validate", "(", ")", "error", "{", "if", "d", ".", "SizeMB", "<", "10", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "d", ".", "SizeMB", ")", "\n", "}", "\n", "return", "nil", "\n", "}...
// Validate validates EphemeralDisk
[ "Validate", "validates", "EphemeralDisk" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6877-L6882
132,355
hashicorp/nomad
nomad/structs/structs.go
Copy
func (d *EphemeralDisk) Copy() *EphemeralDisk { ld := new(EphemeralDisk) *ld = *d return ld }
go
func (d *EphemeralDisk) Copy() *EphemeralDisk { ld := new(EphemeralDisk) *ld = *d return ld }
[ "func", "(", "d", "*", "EphemeralDisk", ")", "Copy", "(", ")", "*", "EphemeralDisk", "{", "ld", ":=", "new", "(", "EphemeralDisk", ")", "\n", "*", "ld", "=", "*", "d", "\n", "return", "ld", "\n", "}" ]
// Copy copies the EphemeralDisk struct and returns a new one
[ "Copy", "copies", "the", "EphemeralDisk", "struct", "and", "returns", "a", "new", "one" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6885-L6889
132,356
hashicorp/nomad
nomad/structs/structs.go
Copy
func (v *Vault) Copy() *Vault { if v == nil { return nil } nv := new(Vault) *nv = *v return nv }
go
func (v *Vault) Copy() *Vault { if v == nil { return nil } nv := new(Vault) *nv = *v return nv }
[ "func", "(", "v", "*", "Vault", ")", "Copy", "(", ")", "*", "Vault", "{", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "nv", ":=", "new", "(", "Vault", ")", "\n", "*", "nv", "=", "*", "v", "\n", "return", "nv", "\n", "}"...
// Copy returns a copy of this Vault block.
[ "Copy", "returns", "a", "copy", "of", "this", "Vault", "block", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6934-L6942
132,357
hashicorp/nomad
nomad/structs/structs.go
Validate
func (v *Vault) Validate() error { if v == nil { return nil } var mErr multierror.Error if len(v.Policies) == 0 { multierror.Append(&mErr, fmt.Errorf("Policy list cannot be empty")) } for _, p := range v.Policies { if p == "root" { multierror.Append(&mErr, fmt.Errorf("Can not specify \"root\" policy"))...
go
func (v *Vault) Validate() error { if v == nil { return nil } var mErr multierror.Error if len(v.Policies) == 0 { multierror.Append(&mErr, fmt.Errorf("Policy list cannot be empty")) } for _, p := range v.Policies { if p == "root" { multierror.Append(&mErr, fmt.Errorf("Can not specify \"root\" policy"))...
[ "func", "(", "v", "*", "Vault", ")", "Validate", "(", ")", "error", "{", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "var", "mErr", "multierror", ".", "Error", "\n", "if", "len", "(", "v", ".", "Policies", ")", "==", "0", "...
// Validate returns if the Vault block is valid.
[ "Validate", "returns", "if", "the", "Vault", "block", "is", "valid", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L6951-L6978
132,358
hashicorp/nomad
nomad/structs/structs.go
DeploymentStatusDescriptionRollback
func DeploymentStatusDescriptionRollback(baseDescription string, jobVersion uint64) string { return fmt.Sprintf("%s - rolling back to job version %d", baseDescription, jobVersion) }
go
func DeploymentStatusDescriptionRollback(baseDescription string, jobVersion uint64) string { return fmt.Sprintf("%s - rolling back to job version %d", baseDescription, jobVersion) }
[ "func", "DeploymentStatusDescriptionRollback", "(", "baseDescription", "string", ",", "jobVersion", "uint64", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "baseDescription", ",", "jobVersion", ")", "\n", "}" ]
// DeploymentStatusDescriptionRollback is used to get the status description of // a deployment when rolling back to an older job.
[ "DeploymentStatusDescriptionRollback", "is", "used", "to", "get", "the", "status", "description", "of", "a", "deployment", "when", "rolling", "back", "to", "an", "older", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7003-L7005
132,359
hashicorp/nomad
nomad/structs/structs.go
DeploymentStatusDescriptionRollbackNoop
func DeploymentStatusDescriptionRollbackNoop(baseDescription string, jobVersion uint64) string { return fmt.Sprintf("%s - not rolling back to stable job version %d as current job has same specification", baseDescription, jobVersion) }
go
func DeploymentStatusDescriptionRollbackNoop(baseDescription string, jobVersion uint64) string { return fmt.Sprintf("%s - not rolling back to stable job version %d as current job has same specification", baseDescription, jobVersion) }
[ "func", "DeploymentStatusDescriptionRollbackNoop", "(", "baseDescription", "string", ",", "jobVersion", "uint64", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "baseDescription", ",", "jobVersion", ")", "\n", "}" ]
// DeploymentStatusDescriptionRollbackNoop is used to get the status description of // a deployment when rolling back is not possible because it has the same specification
[ "DeploymentStatusDescriptionRollbackNoop", "is", "used", "to", "get", "the", "status", "description", "of", "a", "deployment", "when", "rolling", "back", "is", "not", "possible", "because", "it", "has", "the", "same", "specification" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7009-L7011
132,360
hashicorp/nomad
nomad/structs/structs.go
NewDeployment
func NewDeployment(job *Job) *Deployment { return &Deployment{ ID: uuid.Generate(), Namespace: job.Namespace, JobID: job.ID, JobVersion: job.Version, JobModifyIndex: job.ModifyIndex, JobSpecModifyIndex: job.JobModifyIndex, JobCreateIndex: job.CreateIn...
go
func NewDeployment(job *Job) *Deployment { return &Deployment{ ID: uuid.Generate(), Namespace: job.Namespace, JobID: job.ID, JobVersion: job.Version, JobModifyIndex: job.ModifyIndex, JobSpecModifyIndex: job.JobModifyIndex, JobCreateIndex: job.CreateIn...
[ "func", "NewDeployment", "(", "job", "*", "Job", ")", "*", "Deployment", "{", "return", "&", "Deployment", "{", "ID", ":", "uuid", ".", "Generate", "(", ")", ",", "Namespace", ":", "job", ".", "Namespace", ",", "JobID", ":", "job", ".", "ID", ",", ...
// NewDeployment creates a new deployment given the job.
[ "NewDeployment", "creates", "a", "new", "deployment", "given", "the", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7063-L7076
132,361
hashicorp/nomad
nomad/structs/structs.go
Active
func (d *Deployment) Active() bool { switch d.Status { case DeploymentStatusRunning, DeploymentStatusPaused: return true default: return false } }
go
func (d *Deployment) Active() bool { switch d.Status { case DeploymentStatusRunning, DeploymentStatusPaused: return true default: return false } }
[ "func", "(", "d", "*", "Deployment", ")", "Active", "(", ")", "bool", "{", "switch", "d", ".", "Status", "{", "case", "DeploymentStatusRunning", ",", "DeploymentStatusPaused", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n",...
// Active returns whether the deployment is active or terminal.
[ "Active", "returns", "whether", "the", "deployment", "is", "active", "or", "terminal", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7098-L7105
132,362
hashicorp/nomad
nomad/structs/structs.go
HasPlacedCanaries
func (d *Deployment) HasPlacedCanaries() bool { if d == nil || len(d.TaskGroups) == 0 { return false } for _, group := range d.TaskGroups { if len(group.PlacedCanaries) != 0 { return true } } return false }
go
func (d *Deployment) HasPlacedCanaries() bool { if d == nil || len(d.TaskGroups) == 0 { return false } for _, group := range d.TaskGroups { if len(group.PlacedCanaries) != 0 { return true } } return false }
[ "func", "(", "d", "*", "Deployment", ")", "HasPlacedCanaries", "(", ")", "bool", "{", "if", "d", "==", "nil", "||", "len", "(", "d", ".", "TaskGroups", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "for", "_", ",", "group", ":=", "rang...
// HasPlacedCanaries returns whether the deployment has placed canaries
[ "HasPlacedCanaries", "returns", "whether", "the", "deployment", "has", "placed", "canaries" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7116-L7126
132,363
hashicorp/nomad
nomad/structs/structs.go
RequiresPromotion
func (d *Deployment) RequiresPromotion() bool { if d == nil || len(d.TaskGroups) == 0 || d.Status != DeploymentStatusRunning { return false } for _, group := range d.TaskGroups { if group.DesiredCanaries > 0 && !group.Promoted { return true } } return false }
go
func (d *Deployment) RequiresPromotion() bool { if d == nil || len(d.TaskGroups) == 0 || d.Status != DeploymentStatusRunning { return false } for _, group := range d.TaskGroups { if group.DesiredCanaries > 0 && !group.Promoted { return true } } return false }
[ "func", "(", "d", "*", "Deployment", ")", "RequiresPromotion", "(", ")", "bool", "{", "if", "d", "==", "nil", "||", "len", "(", "d", ".", "TaskGroups", ")", "==", "0", "||", "d", ".", "Status", "!=", "DeploymentStatusRunning", "{", "return", "false", ...
// RequiresPromotion returns whether the deployment requires promotion to // continue
[ "RequiresPromotion", "returns", "whether", "the", "deployment", "requires", "promotion", "to", "continue" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7130-L7140
132,364
hashicorp/nomad
nomad/structs/structs.go
Merge
func (d *DesiredTransition) Merge(o *DesiredTransition) { if o.Migrate != nil { d.Migrate = o.Migrate } if o.Reschedule != nil { d.Reschedule = o.Reschedule } if o.ForceReschedule != nil { d.ForceReschedule = o.ForceReschedule } }
go
func (d *DesiredTransition) Merge(o *DesiredTransition) { if o.Migrate != nil { d.Migrate = o.Migrate } if o.Reschedule != nil { d.Reschedule = o.Reschedule } if o.ForceReschedule != nil { d.ForceReschedule = o.ForceReschedule } }
[ "func", "(", "d", "*", "DesiredTransition", ")", "Merge", "(", "o", "*", "DesiredTransition", ")", "{", "if", "o", ".", "Migrate", "!=", "nil", "{", "d", ".", "Migrate", "=", "o", ".", "Migrate", "\n", "}", "\n\n", "if", "o", ".", "Reschedule", "!=...
// Merge merges the two desired transitions, preferring the values from the // passed in object.
[ "Merge", "merges", "the", "two", "desired", "transitions", "preferring", "the", "values", "from", "the", "passed", "in", "object", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7291-L7303
132,365
hashicorp/nomad
nomad/structs/structs.go
ShouldForceReschedule
func (d *DesiredTransition) ShouldForceReschedule() bool { if d == nil { return false } return d.ForceReschedule != nil && *d.ForceReschedule }
go
func (d *DesiredTransition) ShouldForceReschedule() bool { if d == nil { return false } return d.ForceReschedule != nil && *d.ForceReschedule }
[ "func", "(", "d", "*", "DesiredTransition", ")", "ShouldForceReschedule", "(", ")", "bool", "{", "if", "d", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "d", ".", "ForceReschedule", "!=", "nil", "&&", "*", "d", ".", "ForceReschedule", ...
// ShouldForceReschedule returns whether the transition object dictates a // forced rescheduling.
[ "ShouldForceReschedule", "returns", "whether", "the", "transition", "object", "dictates", "a", "forced", "rescheduling", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7318-L7323
132,366
hashicorp/nomad
nomad/structs/structs.go
Index
func (a *Allocation) Index() uint { l := len(a.Name) prefix := len(a.JobID) + len(a.TaskGroup) + 2 if l <= 3 || l <= prefix { return uint(0) } strNum := a.Name[prefix : len(a.Name)-1] num, _ := strconv.Atoi(strNum) return uint(num) }
go
func (a *Allocation) Index() uint { l := len(a.Name) prefix := len(a.JobID) + len(a.TaskGroup) + 2 if l <= 3 || l <= prefix { return uint(0) } strNum := a.Name[prefix : len(a.Name)-1] num, _ := strconv.Atoi(strNum) return uint(num) }
[ "func", "(", "a", "*", "Allocation", ")", "Index", "(", ")", "uint", "{", "l", ":=", "len", "(", "a", ".", "Name", ")", "\n", "prefix", ":=", "len", "(", "a", ".", "JobID", ")", "+", "len", "(", "a", ".", "TaskGroup", ")", "+", "2", "\n", "...
// Index returns the index of the allocation. If the allocation is from a task // group with count greater than 1, there will be multiple allocations for it.
[ "Index", "returns", "the", "index", "of", "the", "allocation", ".", "If", "the", "allocation", "is", "from", "a", "task", "group", "with", "count", "greater", "than", "1", "there", "will", "be", "multiple", "allocations", "for", "it", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7460-L7470
132,367
hashicorp/nomad
nomad/structs/structs.go
ServerTerminalStatus
func (a *Allocation) ServerTerminalStatus() bool { switch a.DesiredStatus { case AllocDesiredStatusStop, AllocDesiredStatusEvict: return true default: return false } }
go
func (a *Allocation) ServerTerminalStatus() bool { switch a.DesiredStatus { case AllocDesiredStatusStop, AllocDesiredStatusEvict: return true default: return false } }
[ "func", "(", "a", "*", "Allocation", ")", "ServerTerminalStatus", "(", ")", "bool", "{", "switch", "a", ".", "DesiredStatus", "{", "case", "AllocDesiredStatusStop", ",", "AllocDesiredStatusEvict", ":", "return", "true", "\n", "default", ":", "return", "false", ...
// ServerTerminalStatus returns true if the desired state of the allocation is terminal
[ "ServerTerminalStatus", "returns", "true", "if", "the", "desired", "state", "of", "the", "allocation", "is", "terminal" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7530-L7537
132,368
hashicorp/nomad
nomad/structs/structs.go
ClientTerminalStatus
func (a *Allocation) ClientTerminalStatus() bool { switch a.ClientStatus { case AllocClientStatusComplete, AllocClientStatusFailed, AllocClientStatusLost: return true default: return false } }
go
func (a *Allocation) ClientTerminalStatus() bool { switch a.ClientStatus { case AllocClientStatusComplete, AllocClientStatusFailed, AllocClientStatusLost: return true default: return false } }
[ "func", "(", "a", "*", "Allocation", ")", "ClientTerminalStatus", "(", ")", "bool", "{", "switch", "a", ".", "ClientStatus", "{", "case", "AllocClientStatusComplete", ",", "AllocClientStatusFailed", ",", "AllocClientStatusLost", ":", "return", "true", "\n", "defau...
// ClientTerminalStatus returns if the client status is terminal and will no longer transition
[ "ClientTerminalStatus", "returns", "if", "the", "client", "status", "is", "terminal", "and", "will", "no", "longer", "transition" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7540-L7547
132,369
hashicorp/nomad
nomad/structs/structs.go
ShouldReschedule
func (a *Allocation) ShouldReschedule(reschedulePolicy *ReschedulePolicy, failTime time.Time) bool { // First check the desired state switch a.DesiredStatus { case AllocDesiredStatusStop, AllocDesiredStatusEvict: return false default: } switch a.ClientStatus { case AllocClientStatusFailed: return a.Reschedul...
go
func (a *Allocation) ShouldReschedule(reschedulePolicy *ReschedulePolicy, failTime time.Time) bool { // First check the desired state switch a.DesiredStatus { case AllocDesiredStatusStop, AllocDesiredStatusEvict: return false default: } switch a.ClientStatus { case AllocClientStatusFailed: return a.Reschedul...
[ "func", "(", "a", "*", "Allocation", ")", "ShouldReschedule", "(", "reschedulePolicy", "*", "ReschedulePolicy", ",", "failTime", "time", ".", "Time", ")", "bool", "{", "// First check the desired state", "switch", "a", ".", "DesiredStatus", "{", "case", "AllocDesi...
// ShouldReschedule returns if the allocation is eligible to be rescheduled according // to its status and ReschedulePolicy given its failure time
[ "ShouldReschedule", "returns", "if", "the", "allocation", "is", "eligible", "to", "be", "rescheduled", "according", "to", "its", "status", "and", "ReschedulePolicy", "given", "its", "failure", "time" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7551-L7564
132,370
hashicorp/nomad
nomad/structs/structs.go
RescheduleEligible
func (a *Allocation) RescheduleEligible(reschedulePolicy *ReschedulePolicy, failTime time.Time) bool { if reschedulePolicy == nil { return false } attempts := reschedulePolicy.Attempts interval := reschedulePolicy.Interval enabled := attempts > 0 || reschedulePolicy.Unlimited if !enabled { return false } if...
go
func (a *Allocation) RescheduleEligible(reschedulePolicy *ReschedulePolicy, failTime time.Time) bool { if reschedulePolicy == nil { return false } attempts := reschedulePolicy.Attempts interval := reschedulePolicy.Interval enabled := attempts > 0 || reschedulePolicy.Unlimited if !enabled { return false } if...
[ "func", "(", "a", "*", "Allocation", ")", "RescheduleEligible", "(", "reschedulePolicy", "*", "ReschedulePolicy", ",", "failTime", "time", ".", "Time", ")", "bool", "{", "if", "reschedulePolicy", "==", "nil", "{", "return", "false", "\n", "}", "\n", "attempt...
// RescheduleEligible returns if the allocation is eligible to be rescheduled according // to its ReschedulePolicy and the current state of its reschedule trackers
[ "RescheduleEligible", "returns", "if", "the", "allocation", "is", "eligible", "to", "be", "rescheduled", "according", "to", "its", "ReschedulePolicy", "and", "the", "current", "state", "of", "its", "reschedule", "trackers" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7568-L7594
132,371
hashicorp/nomad
nomad/structs/structs.go
LastEventTime
func (a *Allocation) LastEventTime() time.Time { var lastEventTime time.Time if a.TaskStates != nil { for _, s := range a.TaskStates { if lastEventTime.IsZero() || s.FinishedAt.After(lastEventTime) { lastEventTime = s.FinishedAt } } } if lastEventTime.IsZero() { return time.Unix(0, a.ModifyTime).UT...
go
func (a *Allocation) LastEventTime() time.Time { var lastEventTime time.Time if a.TaskStates != nil { for _, s := range a.TaskStates { if lastEventTime.IsZero() || s.FinishedAt.After(lastEventTime) { lastEventTime = s.FinishedAt } } } if lastEventTime.IsZero() { return time.Unix(0, a.ModifyTime).UT...
[ "func", "(", "a", "*", "Allocation", ")", "LastEventTime", "(", ")", "time", ".", "Time", "{", "var", "lastEventTime", "time", ".", "Time", "\n", "if", "a", ".", "TaskStates", "!=", "nil", "{", "for", "_", ",", "s", ":=", "range", "a", ".", "TaskSt...
// LastEventTime is the time of the last task event in the allocation. // It is used to determine allocation failure time. If the FinishedAt field // is not set, the alloc's modify time is used
[ "LastEventTime", "is", "the", "time", "of", "the", "last", "task", "event", "in", "the", "allocation", ".", "It", "is", "used", "to", "determine", "allocation", "failure", "time", ".", "If", "the", "FinishedAt", "field", "is", "not", "set", "the", "alloc",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7599-L7613
132,372
hashicorp/nomad
nomad/structs/structs.go
ReschedulePolicy
func (a *Allocation) ReschedulePolicy() *ReschedulePolicy { tg := a.Job.LookupTaskGroup(a.TaskGroup) if tg == nil { return nil } return tg.ReschedulePolicy }
go
func (a *Allocation) ReschedulePolicy() *ReschedulePolicy { tg := a.Job.LookupTaskGroup(a.TaskGroup) if tg == nil { return nil } return tg.ReschedulePolicy }
[ "func", "(", "a", "*", "Allocation", ")", "ReschedulePolicy", "(", ")", "*", "ReschedulePolicy", "{", "tg", ":=", "a", ".", "Job", ".", "LookupTaskGroup", "(", "a", ".", "TaskGroup", ")", "\n", "if", "tg", "==", "nil", "{", "return", "nil", "\n", "}"...
// ReschedulePolicy returns the reschedule policy based on the task group
[ "ReschedulePolicy", "returns", "the", "reschedule", "policy", "based", "on", "the", "task", "group" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7616-L7622
132,373
hashicorp/nomad
nomad/structs/structs.go
NextRescheduleTime
func (a *Allocation) NextRescheduleTime() (time.Time, bool) { failTime := a.LastEventTime() reschedulePolicy := a.ReschedulePolicy() if a.DesiredStatus == AllocDesiredStatusStop || a.ClientStatus != AllocClientStatusFailed || failTime.IsZero() || reschedulePolicy == nil { return time.Time{}, false } nextDelay :...
go
func (a *Allocation) NextRescheduleTime() (time.Time, bool) { failTime := a.LastEventTime() reschedulePolicy := a.ReschedulePolicy() if a.DesiredStatus == AllocDesiredStatusStop || a.ClientStatus != AllocClientStatusFailed || failTime.IsZero() || reschedulePolicy == nil { return time.Time{}, false } nextDelay :...
[ "func", "(", "a", "*", "Allocation", ")", "NextRescheduleTime", "(", ")", "(", "time", ".", "Time", ",", "bool", ")", "{", "failTime", ":=", "a", ".", "LastEventTime", "(", ")", "\n", "reschedulePolicy", ":=", "a", ".", "ReschedulePolicy", "(", ")", "\...
// NextRescheduleTime returns a time on or after which the allocation is eligible to be rescheduled, // and whether the next reschedule time is within policy's interval if the policy doesn't allow unlimited reschedules
[ "NextRescheduleTime", "returns", "a", "time", "on", "or", "after", "which", "the", "allocation", "is", "eligible", "to", "be", "rescheduled", "and", "whether", "the", "next", "reschedule", "time", "is", "within", "policy", "s", "interval", "if", "the", "policy...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7626-L7649
132,374
hashicorp/nomad
nomad/structs/structs.go
NextDelay
func (a *Allocation) NextDelay() time.Duration { policy := a.ReschedulePolicy() // Can be nil if the task group was updated to remove its reschedule policy if policy == nil { return 0 } delayDur := policy.Delay if a.RescheduleTracker == nil || a.RescheduleTracker.Events == nil || len(a.RescheduleTracker.Events)...
go
func (a *Allocation) NextDelay() time.Duration { policy := a.ReschedulePolicy() // Can be nil if the task group was updated to remove its reschedule policy if policy == nil { return 0 } delayDur := policy.Delay if a.RescheduleTracker == nil || a.RescheduleTracker.Events == nil || len(a.RescheduleTracker.Events)...
[ "func", "(", "a", "*", "Allocation", ")", "NextDelay", "(", ")", "time", ".", "Duration", "{", "policy", ":=", "a", ".", "ReschedulePolicy", "(", ")", "\n", "// Can be nil if the task group was updated to remove its reschedule policy", "if", "policy", "==", "nil", ...
// NextDelay returns a duration after which the allocation can be rescheduled. // It is calculated according to the delay function and previous reschedule attempts.
[ "NextDelay", "returns", "a", "duration", "after", "which", "the", "allocation", "can", "be", "rescheduled", ".", "It", "is", "calculated", "according", "to", "the", "delay", "function", "and", "previous", "reschedule", "attempts", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7653-L7695
132,375
hashicorp/nomad
nomad/structs/structs.go
Terminated
func (a *Allocation) Terminated() bool { if a.ClientStatus == AllocClientStatusFailed || a.ClientStatus == AllocClientStatusComplete || a.ClientStatus == AllocClientStatusLost { return true } return false }
go
func (a *Allocation) Terminated() bool { if a.ClientStatus == AllocClientStatusFailed || a.ClientStatus == AllocClientStatusComplete || a.ClientStatus == AllocClientStatusLost { return true } return false }
[ "func", "(", "a", "*", "Allocation", ")", "Terminated", "(", ")", "bool", "{", "if", "a", ".", "ClientStatus", "==", "AllocClientStatusFailed", "||", "a", ".", "ClientStatus", "==", "AllocClientStatusComplete", "||", "a", ".", "ClientStatus", "==", "AllocClien...
// Terminated returns if the allocation is in a terminal state on a client.
[ "Terminated", "returns", "if", "the", "allocation", "is", "in", "a", "terminal", "state", "on", "a", "client", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7698-L7705
132,376
hashicorp/nomad
nomad/structs/structs.go
RanSuccessfully
func (a *Allocation) RanSuccessfully() bool { // Handle the case the client hasn't started the allocation. if len(a.TaskStates) == 0 { return false } // Check to see if all the tasks finished successfully in the allocation allSuccess := true for _, state := range a.TaskStates { allSuccess = allSuccess && sta...
go
func (a *Allocation) RanSuccessfully() bool { // Handle the case the client hasn't started the allocation. if len(a.TaskStates) == 0 { return false } // Check to see if all the tasks finished successfully in the allocation allSuccess := true for _, state := range a.TaskStates { allSuccess = allSuccess && sta...
[ "func", "(", "a", "*", "Allocation", ")", "RanSuccessfully", "(", ")", "bool", "{", "// Handle the case the client hasn't started the allocation.", "if", "len", "(", "a", ".", "TaskStates", ")", "==", "0", "{", "return", "false", "\n", "}", "\n\n", "// Check to ...
// RanSuccessfully returns whether the client has ran the allocation and all // tasks finished successfully. Critically this function returns whether the // allocation has ran to completion and not just that the alloc has converged to // its desired state. That is to say that a batch allocation must have finished // wi...
[ "RanSuccessfully", "returns", "whether", "the", "client", "has", "ran", "the", "allocation", "and", "all", "tasks", "finished", "successfully", ".", "Critically", "this", "function", "returns", "whether", "the", "allocation", "has", "ran", "to", "completion", "and...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7714-L7727
132,377
hashicorp/nomad
nomad/structs/structs.go
ShouldMigrate
func (a *Allocation) ShouldMigrate() bool { if a.PreviousAllocation == "" { return false } if a.DesiredStatus == AllocDesiredStatusStop || a.DesiredStatus == AllocDesiredStatusEvict { return false } tg := a.Job.LookupTaskGroup(a.TaskGroup) // if the task group is nil or the ephemeral disk block isn't prese...
go
func (a *Allocation) ShouldMigrate() bool { if a.PreviousAllocation == "" { return false } if a.DesiredStatus == AllocDesiredStatusStop || a.DesiredStatus == AllocDesiredStatusEvict { return false } tg := a.Job.LookupTaskGroup(a.TaskGroup) // if the task group is nil or the ephemeral disk block isn't prese...
[ "func", "(", "a", "*", "Allocation", ")", "ShouldMigrate", "(", ")", "bool", "{", "if", "a", ".", "PreviousAllocation", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "if", "a", ".", "DesiredStatus", "==", "AllocDesiredStatusStop", "||", "a...
// ShouldMigrate returns if the allocation needs data migration
[ "ShouldMigrate", "returns", "if", "the", "allocation", "needs", "data", "migration" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7730-L7754
132,378
hashicorp/nomad
nomad/structs/structs.go
LookupTask
func (a *Allocation) LookupTask(name string) *Task { if a.Job == nil { return nil } tg := a.Job.LookupTaskGroup(a.TaskGroup) if tg == nil { return nil } return tg.LookupTask(name) }
go
func (a *Allocation) LookupTask(name string) *Task { if a.Job == nil { return nil } tg := a.Job.LookupTaskGroup(a.TaskGroup) if tg == nil { return nil } return tg.LookupTask(name) }
[ "func", "(", "a", "*", "Allocation", ")", "LookupTask", "(", "name", "string", ")", "*", "Task", "{", "if", "a", ".", "Job", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "tg", ":=", "a", ".", "Job", ".", "LookupTaskGroup", "(", "a", ".",...
// LookupTask by name from the Allocation. Returns nil if the Job is not set, the // TaskGroup does not exist, or the task name cannot be found.
[ "LookupTask", "by", "name", "from", "the", "Allocation", ".", "Returns", "nil", "if", "the", "Job", "is", "not", "set", "the", "TaskGroup", "does", "not", "exist", "or", "the", "task", "name", "cannot", "be", "found", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7803-L7814
132,379
hashicorp/nomad
nomad/structs/structs.go
Stub
func (a *Allocation) Stub() *AllocListStub { return &AllocListStub{ ID: a.ID, EvalID: a.EvalID, Name: a.Name, Namespace: a.Namespace, NodeID: a.NodeID, NodeName: a.NodeName, JobID: a.JobID, JobTyp...
go
func (a *Allocation) Stub() *AllocListStub { return &AllocListStub{ ID: a.ID, EvalID: a.EvalID, Name: a.Name, Namespace: a.Namespace, NodeID: a.NodeID, NodeName: a.NodeName, JobID: a.JobID, JobTyp...
[ "func", "(", "a", "*", "Allocation", ")", "Stub", "(", ")", "*", "AllocListStub", "{", "return", "&", "AllocListStub", "{", "ID", ":", "a", ".", "ID", ",", "EvalID", ":", "a", ".", "EvalID", ",", "Name", ":", "a", ".", "Name", ",", "Namespace", "...
// Stub returns a list stub for the allocation
[ "Stub", "returns", "a", "list", "stub", "for", "the", "allocation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L7817-L7845
132,380
hashicorp/nomad
nomad/structs/structs.go
ScoreNode
func (a *AllocMetric) ScoreNode(node *Node, name string, score float64) { // Create nodeScoreMeta lazily if its the first time or if its a new node if a.nodeScoreMeta == nil || a.nodeScoreMeta.NodeID != node.ID { a.nodeScoreMeta = &NodeScoreMeta{ NodeID: node.ID, Scores: make(map[string]float64), } } if n...
go
func (a *AllocMetric) ScoreNode(node *Node, name string, score float64) { // Create nodeScoreMeta lazily if its the first time or if its a new node if a.nodeScoreMeta == nil || a.nodeScoreMeta.NodeID != node.ID { a.nodeScoreMeta = &NodeScoreMeta{ NodeID: node.ID, Scores: make(map[string]float64), } } if n...
[ "func", "(", "a", "*", "AllocMetric", ")", "ScoreNode", "(", "node", "*", "Node", ",", "name", "string", ",", "score", "float64", ")", "{", "// Create nodeScoreMeta lazily if its the first time or if its a new node", "if", "a", ".", "nodeScoreMeta", "==", "nil", "...
// ScoreNode is used to gather top K scoring nodes in a heap
[ "ScoreNode", "is", "used", "to", "gather", "top", "K", "scoring", "nodes", "in", "a", "heap" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8027-L8051
132,381
hashicorp/nomad
nomad/structs/structs.go
PopulateScoreMetaData
func (a *AllocMetric) PopulateScoreMetaData() { if a.topScores == nil { return } if a.ScoreMetaData == nil { a.ScoreMetaData = make([]*NodeScoreMeta, a.topScores.Len()) } heapItems := a.topScores.GetItemsReverse() for i, item := range heapItems { a.ScoreMetaData[i] = item.(*NodeScoreMeta) } }
go
func (a *AllocMetric) PopulateScoreMetaData() { if a.topScores == nil { return } if a.ScoreMetaData == nil { a.ScoreMetaData = make([]*NodeScoreMeta, a.topScores.Len()) } heapItems := a.topScores.GetItemsReverse() for i, item := range heapItems { a.ScoreMetaData[i] = item.(*NodeScoreMeta) } }
[ "func", "(", "a", "*", "AllocMetric", ")", "PopulateScoreMetaData", "(", ")", "{", "if", "a", ".", "topScores", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "a", ".", "ScoreMetaData", "==", "nil", "{", "a", ".", "ScoreMetaData", "=", "make", ...
// PopulateScoreMetaData populates a map of scorer to scoring metadata // The map is populated by popping elements from a heap of top K scores // maintained per scorer
[ "PopulateScoreMetaData", "populates", "a", "map", "of", "scorer", "to", "scoring", "metadata", "The", "map", "is", "populated", "by", "popping", "elements", "from", "a", "heap", "of", "top", "K", "scores", "maintained", "per", "scorer" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8056-L8068
132,382
hashicorp/nomad
nomad/structs/structs.go
IsHealthy
func (a *AllocDeploymentStatus) IsHealthy() bool { if a == nil { return false } return a.Healthy != nil && *a.Healthy }
go
func (a *AllocDeploymentStatus) IsHealthy() bool { if a == nil { return false } return a.Healthy != nil && *a.Healthy }
[ "func", "(", "a", "*", "AllocDeploymentStatus", ")", "IsHealthy", "(", ")", "bool", "{", "if", "a", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "return", "a", ".", "Healthy", "!=", "nil", "&&", "*", "a", ".", "Healthy", "\n", "}" ]
// IsHealthy returns if the allocation is marked as healthy as part of a // deployment
[ "IsHealthy", "returns", "if", "the", "allocation", "is", "marked", "as", "healthy", "as", "part", "of", "a", "deployment" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8127-L8133
132,383
hashicorp/nomad
nomad/structs/structs.go
IsUnhealthy
func (a *AllocDeploymentStatus) IsUnhealthy() bool { if a == nil { return false } return a.Healthy != nil && !*a.Healthy }
go
func (a *AllocDeploymentStatus) IsUnhealthy() bool { if a == nil { return false } return a.Healthy != nil && !*a.Healthy }
[ "func", "(", "a", "*", "AllocDeploymentStatus", ")", "IsUnhealthy", "(", ")", "bool", "{", "if", "a", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "return", "a", ".", "Healthy", "!=", "nil", "&&", "!", "*", "a", ".", "Healthy", "\n", "}"...
// IsUnhealthy returns if the allocation is marked as unhealthy as part of a // deployment
[ "IsUnhealthy", "returns", "if", "the", "allocation", "is", "marked", "as", "unhealthy", "as", "part", "of", "a", "deployment" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8137-L8143
132,384
hashicorp/nomad
nomad/structs/structs.go
TerminalStatus
func (e *Evaluation) TerminalStatus() bool { switch e.Status { case EvalStatusComplete, EvalStatusFailed, EvalStatusCancelled: return true default: return false } }
go
func (e *Evaluation) TerminalStatus() bool { switch e.Status { case EvalStatusComplete, EvalStatusFailed, EvalStatusCancelled: return true default: return false } }
[ "func", "(", "e", "*", "Evaluation", ")", "TerminalStatus", "(", ")", "bool", "{", "switch", "e", ".", "Status", "{", "case", "EvalStatusComplete", ",", "EvalStatusFailed", ",", "EvalStatusCancelled", ":", "return", "true", "\n", "default", ":", "return", "f...
// TerminalStatus returns if the current status is terminal and // will no longer transition.
[ "TerminalStatus", "returns", "if", "the", "current", "status", "is", "terminal", "and", "will", "no", "longer", "transition", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8342-L8349
132,385
hashicorp/nomad
nomad/structs/structs.go
ShouldEnqueue
func (e *Evaluation) ShouldEnqueue() bool { switch e.Status { case EvalStatusPending: return true case EvalStatusComplete, EvalStatusFailed, EvalStatusBlocked, EvalStatusCancelled: return false default: panic(fmt.Sprintf("unhandled evaluation (%s) status %s", e.ID, e.Status)) } }
go
func (e *Evaluation) ShouldEnqueue() bool { switch e.Status { case EvalStatusPending: return true case EvalStatusComplete, EvalStatusFailed, EvalStatusBlocked, EvalStatusCancelled: return false default: panic(fmt.Sprintf("unhandled evaluation (%s) status %s", e.ID, e.Status)) } }
[ "func", "(", "e", "*", "Evaluation", ")", "ShouldEnqueue", "(", ")", "bool", "{", "switch", "e", ".", "Status", "{", "case", "EvalStatusPending", ":", "return", "true", "\n", "case", "EvalStatusComplete", ",", "EvalStatusFailed", ",", "EvalStatusBlocked", ",",...
// ShouldEnqueue checks if a given evaluation should be enqueued into the // eval_broker
[ "ShouldEnqueue", "checks", "if", "a", "given", "evaluation", "should", "be", "enqueued", "into", "the", "eval_broker" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8394-L8403
132,386
hashicorp/nomad
nomad/structs/structs.go
MakePlan
func (e *Evaluation) MakePlan(j *Job) *Plan { p := &Plan{ EvalID: e.ID, Priority: e.Priority, Job: j, NodeUpdate: make(map[string][]*Allocation), NodeAllocation: make(map[string][]*Allocation), NodePreemptions: make(map[string][]*Allocation), } if j != nil { p.AllAtOnc...
go
func (e *Evaluation) MakePlan(j *Job) *Plan { p := &Plan{ EvalID: e.ID, Priority: e.Priority, Job: j, NodeUpdate: make(map[string][]*Allocation), NodeAllocation: make(map[string][]*Allocation), NodePreemptions: make(map[string][]*Allocation), } if j != nil { p.AllAtOnc...
[ "func", "(", "e", "*", "Evaluation", ")", "MakePlan", "(", "j", "*", "Job", ")", "*", "Plan", "{", "p", ":=", "&", "Plan", "{", "EvalID", ":", "e", ".", "ID", ",", "Priority", ":", "e", ".", "Priority", ",", "Job", ":", "j", ",", "NodeUpdate", ...
// MakePlan is used to make a plan from the given evaluation // for a given Job
[ "MakePlan", "is", "used", "to", "make", "a", "plan", "from", "the", "given", "evaluation", "for", "a", "given", "Job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8420-L8433
132,387
hashicorp/nomad
nomad/structs/structs.go
CreateBlockedEval
func (e *Evaluation) CreateBlockedEval(classEligibility map[string]bool, escaped bool, quotaReached string) *Evaluation { return &Evaluation{ ID: uuid.Generate(), Namespace: e.Namespace, Priority: e.Priority, Type: e.Type, TriggeredBy: EvalT...
go
func (e *Evaluation) CreateBlockedEval(classEligibility map[string]bool, escaped bool, quotaReached string) *Evaluation { return &Evaluation{ ID: uuid.Generate(), Namespace: e.Namespace, Priority: e.Priority, Type: e.Type, TriggeredBy: EvalT...
[ "func", "(", "e", "*", "Evaluation", ")", "CreateBlockedEval", "(", "classEligibility", "map", "[", "string", "]", "bool", ",", "escaped", "bool", ",", "quotaReached", "string", ")", "*", "Evaluation", "{", "return", "&", "Evaluation", "{", "ID", ":", "uui...
// CreateBlockedEval creates a blocked evaluation to followup this eval to place any // failed allocations. It takes the classes marked explicitly eligible or // ineligible, whether the job has escaped computed node classes and whether the // quota limit was reached.
[ "CreateBlockedEval", "creates", "a", "blocked", "evaluation", "to", "followup", "this", "eval", "to", "place", "any", "failed", "allocations", ".", "It", "takes", "the", "classes", "marked", "explicitly", "eligible", "or", "ineligible", "whether", "the", "job", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8455-L8472
132,388
hashicorp/nomad
nomad/structs/structs.go
CreateFailedFollowUpEval
func (e *Evaluation) CreateFailedFollowUpEval(wait time.Duration) *Evaluation { return &Evaluation{ ID: uuid.Generate(), Namespace: e.Namespace, Priority: e.Priority, Type: e.Type, TriggeredBy: EvalTriggerFailedFollowUp, JobID: e.JobID, JobModifyIndex: e.JobMo...
go
func (e *Evaluation) CreateFailedFollowUpEval(wait time.Duration) *Evaluation { return &Evaluation{ ID: uuid.Generate(), Namespace: e.Namespace, Priority: e.Priority, Type: e.Type, TriggeredBy: EvalTriggerFailedFollowUp, JobID: e.JobID, JobModifyIndex: e.JobMo...
[ "func", "(", "e", "*", "Evaluation", ")", "CreateFailedFollowUpEval", "(", "wait", "time", ".", "Duration", ")", "*", "Evaluation", "{", "return", "&", "Evaluation", "{", "ID", ":", "uuid", ".", "Generate", "(", ")", ",", "Namespace", ":", "e", ".", "N...
// CreateFailedFollowUpEval creates a follow up evaluation when the current one // has been marked as failed because it has hit the delivery limit and will not // be retried by the eval_broker. Callers should copy the created eval's ID to // into the old eval's NextEval field.
[ "CreateFailedFollowUpEval", "creates", "a", "follow", "up", "evaluation", "when", "the", "current", "one", "has", "been", "marked", "as", "failed", "because", "it", "has", "hit", "the", "delivery", "limit", "and", "will", "not", "be", "retried", "by", "the", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8478-L8491
132,389
hashicorp/nomad
nomad/structs/structs.go
AppendStoppedAlloc
func (p *Plan) AppendStoppedAlloc(alloc *Allocation, desiredDesc, clientStatus string) { newAlloc := new(Allocation) *newAlloc = *alloc // If the job is not set in the plan we are deregistering a job so we // extract the job from the allocation. if p.Job == nil && newAlloc.Job != nil { p.Job = newAlloc.Job } ...
go
func (p *Plan) AppendStoppedAlloc(alloc *Allocation, desiredDesc, clientStatus string) { newAlloc := new(Allocation) *newAlloc = *alloc // If the job is not set in the plan we are deregistering a job so we // extract the job from the allocation. if p.Job == nil && newAlloc.Job != nil { p.Job = newAlloc.Job } ...
[ "func", "(", "p", "*", "Plan", ")", "AppendStoppedAlloc", "(", "alloc", "*", "Allocation", ",", "desiredDesc", ",", "clientStatus", "string", ")", "{", "newAlloc", ":=", "new", "(", "Allocation", ")", "\n", "*", "newAlloc", "=", "*", "alloc", "\n\n", "//...
// AppendStoppedAlloc marks an allocation to be stopped. The clientStatus of the // allocation may be optionally set by passing in a non-empty value.
[ "AppendStoppedAlloc", "marks", "an", "allocation", "to", "be", "stopped", ".", "The", "clientStatus", "of", "the", "allocation", "may", "be", "optionally", "set", "by", "passing", "in", "a", "non", "-", "empty", "value", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8553-L8579
132,390
hashicorp/nomad
nomad/structs/structs.go
AppendPreemptedAlloc
func (p *Plan) AppendPreemptedAlloc(alloc *Allocation, preemptingAllocID string) { newAlloc := &Allocation{} newAlloc.ID = alloc.ID newAlloc.JobID = alloc.JobID newAlloc.Namespace = alloc.Namespace newAlloc.DesiredStatus = AllocDesiredStatusEvict newAlloc.PreemptedByAllocation = preemptingAllocID desiredDesc :=...
go
func (p *Plan) AppendPreemptedAlloc(alloc *Allocation, preemptingAllocID string) { newAlloc := &Allocation{} newAlloc.ID = alloc.ID newAlloc.JobID = alloc.JobID newAlloc.Namespace = alloc.Namespace newAlloc.DesiredStatus = AllocDesiredStatusEvict newAlloc.PreemptedByAllocation = preemptingAllocID desiredDesc :=...
[ "func", "(", "p", "*", "Plan", ")", "AppendPreemptedAlloc", "(", "alloc", "*", "Allocation", ",", "preemptingAllocID", "string", ")", "{", "newAlloc", ":=", "&", "Allocation", "{", "}", "\n", "newAlloc", ".", "ID", "=", "alloc", ".", "ID", "\n", "newAllo...
// AppendPreemptedAlloc is used to append an allocation that's being preempted to the plan. // To minimize the size of the plan, this only sets a minimal set of fields in the allocation
[ "AppendPreemptedAlloc", "is", "used", "to", "append", "an", "allocation", "that", "s", "being", "preempted", "to", "the", "plan", ".", "To", "minimize", "the", "size", "of", "the", "plan", "this", "only", "sets", "a", "minimal", "set", "of", "fields", "in"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8583-L8608
132,391
hashicorp/nomad
nomad/structs/structs.go
IsNoOp
func (p *Plan) IsNoOp() bool { return len(p.NodeUpdate) == 0 && len(p.NodeAllocation) == 0 && p.Deployment == nil && len(p.DeploymentUpdates) == 0 }
go
func (p *Plan) IsNoOp() bool { return len(p.NodeUpdate) == 0 && len(p.NodeAllocation) == 0 && p.Deployment == nil && len(p.DeploymentUpdates) == 0 }
[ "func", "(", "p", "*", "Plan", ")", "IsNoOp", "(", ")", "bool", "{", "return", "len", "(", "p", ".", "NodeUpdate", ")", "==", "0", "&&", "len", "(", "p", ".", "NodeAllocation", ")", "==", "0", "&&", "p", ".", "Deployment", "==", "nil", "&&", "l...
// IsNoOp checks if this plan would do nothing
[ "IsNoOp", "checks", "if", "this", "plan", "would", "do", "nothing" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8634-L8639
132,392
hashicorp/nomad
nomad/structs/structs.go
NormalizeAllocations
func (p *Plan) NormalizeAllocations() { for _, allocs := range p.NodeUpdate { for i, alloc := range allocs { allocs[i] = &Allocation{ ID: alloc.ID, DesiredDescription: alloc.DesiredDescription, ClientStatus: alloc.ClientStatus, } } } for _, allocs := range p.NodePreemptio...
go
func (p *Plan) NormalizeAllocations() { for _, allocs := range p.NodeUpdate { for i, alloc := range allocs { allocs[i] = &Allocation{ ID: alloc.ID, DesiredDescription: alloc.DesiredDescription, ClientStatus: alloc.ClientStatus, } } } for _, allocs := range p.NodePreemptio...
[ "func", "(", "p", "*", "Plan", ")", "NormalizeAllocations", "(", ")", "{", "for", "_", ",", "allocs", ":=", "range", "p", ".", "NodeUpdate", "{", "for", "i", ",", "alloc", ":=", "range", "allocs", "{", "allocs", "[", "i", "]", "=", "&", "Allocation...
// NormalizeAllocations normalizes allocations to remove fields that can // be fetched from the MemDB instead of sending over the wire
[ "NormalizeAllocations", "normalizes", "allocations", "to", "remove", "fields", "that", "can", "be", "fetched", "from", "the", "MemDB", "instead", "of", "sending", "over", "the", "wire" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8643-L8662
132,393
hashicorp/nomad
nomad/structs/structs.go
FullCommit
func (p *PlanResult) FullCommit(plan *Plan) (bool, int, int) { expected := 0 actual := 0 for name, allocList := range plan.NodeAllocation { didAlloc, _ := p.NodeAllocation[name] expected += len(allocList) actual += len(didAlloc) } return actual == expected, expected, actual }
go
func (p *PlanResult) FullCommit(plan *Plan) (bool, int, int) { expected := 0 actual := 0 for name, allocList := range plan.NodeAllocation { didAlloc, _ := p.NodeAllocation[name] expected += len(allocList) actual += len(didAlloc) } return actual == expected, expected, actual }
[ "func", "(", "p", "*", "PlanResult", ")", "FullCommit", "(", "plan", "*", "Plan", ")", "(", "bool", ",", "int", ",", "int", ")", "{", "expected", ":=", "0", "\n", "actual", ":=", "0", "\n", "for", "name", ",", "allocList", ":=", "range", "plan", ...
// FullCommit is used to check if all the allocations in a plan // were committed as part of the result. Returns if there was // a match, and the number of expected and actual allocations.
[ "FullCommit", "is", "used", "to", "check", "if", "all", "the", "allocations", "in", "a", "plan", "were", "committed", "as", "part", "of", "the", "result", ".", "Returns", "if", "there", "was", "a", "match", "and", "the", "number", "of", "expected", "and"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8703-L8712
132,394
hashicorp/nomad
nomad/structs/structs.go
Decode
func Decode(buf []byte, out interface{}) error { return codec.NewDecoder(bytes.NewReader(buf), MsgpackHandle).Decode(out) }
go
func Decode(buf []byte, out interface{}) error { return codec.NewDecoder(bytes.NewReader(buf), MsgpackHandle).Decode(out) }
[ "func", "Decode", "(", "buf", "[", "]", "byte", ",", "out", "interface", "{", "}", ")", "error", "{", "return", "codec", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "buf", ")", ",", "MsgpackHandle", ")", ".", "Decode", "(", "out", ")", ...
// Decode is used to decode a MsgPack encoded object
[ "Decode", "is", "used", "to", "decode", "a", "MsgPack", "encoded", "object" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8779-L8781
132,395
hashicorp/nomad
nomad/structs/structs.go
NewRecoverableError
func NewRecoverableError(e error, recoverable bool) error { if e == nil { return nil } return &RecoverableError{ Err: e.Error(), Recoverable: recoverable, } }
go
func NewRecoverableError(e error, recoverable bool) error { if e == nil { return nil } return &RecoverableError{ Err: e.Error(), Recoverable: recoverable, } }
[ "func", "NewRecoverableError", "(", "e", "error", ",", "recoverable", "bool", ")", "error", "{", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "RecoverableError", "{", "Err", ":", "e", ".", "Error", "(", ")", ",", "R...
// NewRecoverableError is used to wrap an error and mark it as recoverable or // not.
[ "NewRecoverableError", "is", "used", "to", "wrap", "an", "error", "and", "mark", "it", "as", "recoverable", "or", "not", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8813-L8822
132,396
hashicorp/nomad
nomad/structs/structs.go
WrapRecoverable
func WrapRecoverable(msg string, err error) error { return &RecoverableError{Err: msg, Recoverable: IsRecoverable(err)} }
go
func WrapRecoverable(msg string, err error) error { return &RecoverableError{Err: msg, Recoverable: IsRecoverable(err)} }
[ "func", "WrapRecoverable", "(", "msg", "string", ",", "err", "error", ")", "error", "{", "return", "&", "RecoverableError", "{", "Err", ":", "msg", ",", "Recoverable", ":", "IsRecoverable", "(", "err", ")", "}", "\n", "}" ]
// WrapRecoverable wraps an existing error in a new RecoverableError with a new // message. If the error was recoverable before the returned error is as well; // otherwise it is unrecoverable.
[ "WrapRecoverable", "wraps", "an", "existing", "error", "in", "a", "new", "RecoverableError", "with", "a", "new", "message", ".", "If", "the", "error", "was", "recoverable", "before", "the", "returned", "error", "is", "as", "well", ";", "otherwise", "it", "is...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8827-L8829
132,397
hashicorp/nomad
nomad/structs/structs.go
IsRecoverable
func IsRecoverable(e error) bool { if re, ok := e.(Recoverable); ok { return re.IsRecoverable() } return false }
go
func IsRecoverable(e error) bool { if re, ok := e.(Recoverable); ok { return re.IsRecoverable() } return false }
[ "func", "IsRecoverable", "(", "e", "error", ")", "bool", "{", "if", "re", ",", "ok", ":=", "e", ".", "(", "Recoverable", ")", ";", "ok", "{", "return", "re", ".", "IsRecoverable", "(", ")", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsRecoverable returns true if error is a RecoverableError with // Recoverable=true. Otherwise false is returned.
[ "IsRecoverable", "returns", "true", "if", "error", "is", "a", "RecoverableError", "with", "Recoverable", "=", "true", ".", "Otherwise", "false", "is", "returned", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8852-L8857
132,398
hashicorp/nomad
nomad/structs/structs.go
IsServerSide
func IsServerSide(e error) bool { if se, ok := e.(ServerSideError); ok { return se.IsServerSide() } return false }
go
func IsServerSide(e error) bool { if se, ok := e.(ServerSideError); ok { return se.IsServerSide() } return false }
[ "func", "IsServerSide", "(", "e", "error", ")", "bool", "{", "if", "se", ",", "ok", ":=", "e", ".", "(", "ServerSideError", ")", ";", "ok", "{", "return", "se", ".", "IsServerSide", "(", ")", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsServerSide returns true if error is a wrapped // server side error
[ "IsServerSide", "returns", "true", "if", "error", "is", "a", "wrapped", "server", "side", "error" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8893-L8898
132,399
hashicorp/nomad
nomad/structs/structs.go
SetHash
func (c *ACLPolicy) SetHash() []byte { // Initialize a 256bit Blake2 hash (32 bytes) hash, err := blake2b.New256(nil) if err != nil { panic(err) } // Write all the user set fields hash.Write([]byte(c.Name)) hash.Write([]byte(c.Description)) hash.Write([]byte(c.Rules)) // Finalize the hash hashVal := hash....
go
func (c *ACLPolicy) SetHash() []byte { // Initialize a 256bit Blake2 hash (32 bytes) hash, err := blake2b.New256(nil) if err != nil { panic(err) } // Write all the user set fields hash.Write([]byte(c.Name)) hash.Write([]byte(c.Description)) hash.Write([]byte(c.Rules)) // Finalize the hash hashVal := hash....
[ "func", "(", "c", "*", "ACLPolicy", ")", "SetHash", "(", ")", "[", "]", "byte", "{", "// Initialize a 256bit Blake2 hash (32 bytes)", "hash", ",", "err", ":=", "blake2b", ".", "New256", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", ...
// SetHash is used to compute and set the hash of the ACL policy
[ "SetHash", "is", "used", "to", "compute", "and", "set", "the", "hash", "of", "the", "ACL", "policy" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L8911-L8929