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,600
hashicorp/nomad
nomad/structs/diff.go
primitiveObjectSetDiff
func primitiveObjectSetDiff(old, new []interface{}, filter []string, name string, contextual bool) []*ObjectDiff { makeSet := func(objects []interface{}) map[string]interface{} { objMap := make(map[string]interface{}, len(objects)) for _, obj := range objects { hash, err := hashstructure.Hash(obj, nil) if er...
go
func primitiveObjectSetDiff(old, new []interface{}, filter []string, name string, contextual bool) []*ObjectDiff { makeSet := func(objects []interface{}) map[string]interface{} { objMap := make(map[string]interface{}, len(objects)) for _, obj := range objects { hash, err := hashstructure.Hash(obj, nil) if er...
[ "func", "primitiveObjectSetDiff", "(", "old", ",", "new", "[", "]", "interface", "{", "}", ",", "filter", "[", "]", "string", ",", "name", "string", ",", "contextual", "bool", ")", "[", "]", "*", "ObjectDiff", "{", "makeSet", ":=", "func", "(", "object...
// primitiveObjectSetDiff does a set difference of the old and new sets. The // filter parameter can be used to filter a set of primitive fields in the // passed structs. The name corresponds to the name of the passed objects. If // contextual diff is enabled, objects' primitive fields will be returned even if // no di...
[ "primitiveObjectSetDiff", "does", "a", "set", "difference", "of", "the", "old", "and", "new", "sets", ".", "The", "filter", "parameter", "can", "be", "used", "to", "filter", "a", "set", "of", "primitive", "fields", "in", "the", "passed", "structs", ".", "T...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1330-L1363
132,601
hashicorp/nomad
nomad/structs/config/autopilot.go
Copy
func (a *AutopilotConfig) Copy() *AutopilotConfig { if a == nil { return nil } nc := new(AutopilotConfig) *nc = *a // Copy the bools if a.CleanupDeadServers != nil { nc.CleanupDeadServers = helper.BoolToPtr(*a.CleanupDeadServers) } if a.EnableRedundancyZones != nil { nc.EnableRedundancyZones = helper.Bo...
go
func (a *AutopilotConfig) Copy() *AutopilotConfig { if a == nil { return nil } nc := new(AutopilotConfig) *nc = *a // Copy the bools if a.CleanupDeadServers != nil { nc.CleanupDeadServers = helper.BoolToPtr(*a.CleanupDeadServers) } if a.EnableRedundancyZones != nil { nc.EnableRedundancyZones = helper.Bo...
[ "func", "(", "a", "*", "AutopilotConfig", ")", "Copy", "(", ")", "*", "AutopilotConfig", "{", "if", "a", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "nc", ":=", "new", "(", "AutopilotConfig", ")", "\n", "*", "nc", "=", "*", "a", "\n\n", ...
// Copy returns a copy of this Autopilot config.
[ "Copy", "returns", "a", "copy", "of", "this", "Autopilot", "config", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/config/autopilot.go#L79-L102
132,602
hashicorp/nomad
nomad/client_fs_endpoint.go
forwardRegionStreamingRpc
func (f *FileSystem) forwardRegionStreamingRpc(conn io.ReadWriteCloser, encoder *codec.Encoder, args interface{}, method, allocID string, qo *structs.QueryOptions) { // Request the allocation from the target region allocReq := &structs.AllocSpecificRequest{ AllocID: allocID, QueryOptions: *qo, } var alloc...
go
func (f *FileSystem) forwardRegionStreamingRpc(conn io.ReadWriteCloser, encoder *codec.Encoder, args interface{}, method, allocID string, qo *structs.QueryOptions) { // Request the allocation from the target region allocReq := &structs.AllocSpecificRequest{ AllocID: allocID, QueryOptions: *qo, } var alloc...
[ "func", "(", "f", "*", "FileSystem", ")", "forwardRegionStreamingRpc", "(", "conn", "io", ".", "ReadWriteCloser", ",", "encoder", "*", "codec", ".", "Encoder", ",", "args", "interface", "{", "}", ",", "method", ",", "allocID", "string", ",", "qo", "*", "...
// forwardRegionStreamingRpc is used to make a streaming RPC to a different // region. It looks up the allocation in the remote region to determine what // remote server can route the request.
[ "forwardRegionStreamingRpc", "is", "used", "to", "make", "a", "streaming", "RPC", "to", "a", "different", "region", ".", "It", "looks", "up", "the", "allocation", "in", "the", "remote", "region", "to", "determine", "what", "remote", "server", "can", "route", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_fs_endpoint.go#L51-L96
132,603
hashicorp/nomad
client/client_stats_endpoint.go
Stats
func (s *ClientStats) Stats(args *nstructs.NodeSpecificRequest, reply *structs.ClientStatsResponse) error { defer metrics.MeasureSince([]string{"client", "client_stats", "stats"}, time.Now()) // Check node read permissions if aclObj, err := s.c.ResolveToken(args.AuthToken); err != nil { return err } else if aclO...
go
func (s *ClientStats) Stats(args *nstructs.NodeSpecificRequest, reply *structs.ClientStatsResponse) error { defer metrics.MeasureSince([]string{"client", "client_stats", "stats"}, time.Now()) // Check node read permissions if aclObj, err := s.c.ResolveToken(args.AuthToken); err != nil { return err } else if aclO...
[ "func", "(", "s", "*", "ClientStats", ")", "Stats", "(", "args", "*", "nstructs", ".", "NodeSpecificRequest", ",", "reply", "*", "structs", ".", "ClientStatsResponse", ")", "error", "{", "defer", "metrics", ".", "MeasureSince", "(", "[", "]", "string", "{"...
// Stats is used to retrieve the Clients stats.
[ "Stats", "is", "used", "to", "retrieve", "the", "Clients", "stats", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/client_stats_endpoint.go#L17-L30
132,604
hashicorp/nomad
scheduler/annotate.go
annotateTaskGroup
func annotateTaskGroup(diff *structs.TaskGroupDiff, annotations *structs.PlanAnnotations) error { // Annotate the updates if annotations != nil { tg, ok := annotations.DesiredTGUpdates[diff.Name] if ok { if diff.Updates == nil { diff.Updates = make(map[string]uint64, 6) } if tg.Ignore != 0 { dif...
go
func annotateTaskGroup(diff *structs.TaskGroupDiff, annotations *structs.PlanAnnotations) error { // Annotate the updates if annotations != nil { tg, ok := annotations.DesiredTGUpdates[diff.Name] if ok { if diff.Updates == nil { diff.Updates = make(map[string]uint64, 6) } if tg.Ignore != 0 { dif...
[ "func", "annotateTaskGroup", "(", "diff", "*", "structs", ".", "TaskGroupDiff", ",", "annotations", "*", "structs", ".", "PlanAnnotations", ")", "error", "{", "// Annotate the updates", "if", "annotations", "!=", "nil", "{", "tg", ",", "ok", ":=", "annotations",...
// annotateTaskGroup takes a task group diff and annotates it.
[ "annotateTaskGroup", "takes", "a", "task", "group", "diff", "and", "annotates", "it", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/annotate.go#L54-L103
132,605
hashicorp/nomad
scheduler/annotate.go
annotateCountChange
func annotateCountChange(diff *structs.TaskGroupDiff) error { var countDiff *structs.FieldDiff for _, diff := range diff.Fields { if diff.Name == "Count" { countDiff = diff break } } // Didn't find if countDiff == nil { return nil } var oldV, newV int var err error if countDiff.Old == "" { oldV ...
go
func annotateCountChange(diff *structs.TaskGroupDiff) error { var countDiff *structs.FieldDiff for _, diff := range diff.Fields { if diff.Name == "Count" { countDiff = diff break } } // Didn't find if countDiff == nil { return nil } var oldV, newV int var err error if countDiff.Old == "" { oldV ...
[ "func", "annotateCountChange", "(", "diff", "*", "structs", ".", "TaskGroupDiff", ")", "error", "{", "var", "countDiff", "*", "structs", ".", "FieldDiff", "\n", "for", "_", ",", "diff", ":=", "range", "diff", ".", "Fields", "{", "if", "diff", ".", "Name"...
// annotateCountChange takes a task group diff and annotates the count // parameter.
[ "annotateCountChange", "takes", "a", "task", "group", "diff", "and", "annotates", "the", "count", "parameter", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/annotate.go#L107-L147
132,606
hashicorp/nomad
scheduler/annotate.go
annotateTask
func annotateTask(diff *structs.TaskDiff, parent *structs.TaskGroupDiff) { if diff.Type == structs.DiffTypeNone { return } // The whole task group is changing if parent.Type == structs.DiffTypeAdded || parent.Type == structs.DiffTypeDeleted { if diff.Type == structs.DiffTypeAdded { diff.Annotations = append...
go
func annotateTask(diff *structs.TaskDiff, parent *structs.TaskGroupDiff) { if diff.Type == structs.DiffTypeNone { return } // The whole task group is changing if parent.Type == structs.DiffTypeAdded || parent.Type == structs.DiffTypeDeleted { if diff.Type == structs.DiffTypeAdded { diff.Annotations = append...
[ "func", "annotateTask", "(", "diff", "*", "structs", ".", "TaskDiff", ",", "parent", "*", "structs", ".", "TaskGroupDiff", ")", "{", "if", "diff", ".", "Type", "==", "structs", ".", "DiffTypeNone", "{", "return", "\n", "}", "\n\n", "// The whole task group i...
// annotateCountChange takes a task diff and annotates it.
[ "annotateCountChange", "takes", "a", "task", "diff", "and", "annotates", "it", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/annotate.go#L150-L198
132,607
hashicorp/nomad
api/operator_autopilot.go
AutopilotServerHealth
func (op *Operator) AutopilotServerHealth(q *QueryOptions) (*OperatorHealthReply, *QueryMeta, error) { var out OperatorHealthReply qm, err := op.c.query("/v1/operator/autopilot/health", &out, q) if err != nil { return nil, nil, err } return &out, qm, nil }
go
func (op *Operator) AutopilotServerHealth(q *QueryOptions) (*OperatorHealthReply, *QueryMeta, error) { var out OperatorHealthReply qm, err := op.c.query("/v1/operator/autopilot/health", &out, q) if err != nil { return nil, nil, err } return &out, qm, nil }
[ "func", "(", "op", "*", "Operator", ")", "AutopilotServerHealth", "(", "q", "*", "QueryOptions", ")", "(", "*", "OperatorHealthReply", ",", "*", "QueryMeta", ",", "error", ")", "{", "var", "out", "OperatorHealthReply", "\n", "qm", ",", "err", ":=", "op", ...
// AutopilotServerHealth is used to query Autopilot's top-level view of the health // of each Nomad server.
[ "AutopilotServerHealth", "is", "used", "to", "query", "Autopilot", "s", "top", "-", "level", "view", "of", "the", "health", "of", "each", "Nomad", "server", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/operator_autopilot.go#L211-L218
132,608
hashicorp/nomad
nomad/state/schema.go
RegisterSchemaFactories
func RegisterSchemaFactories(factories ...SchemaFactory) { factoriesLock.Lock() defer factoriesLock.Unlock() schemaFactories = append(schemaFactories, factories...) }
go
func RegisterSchemaFactories(factories ...SchemaFactory) { factoriesLock.Lock() defer factoriesLock.Unlock() schemaFactories = append(schemaFactories, factories...) }
[ "func", "RegisterSchemaFactories", "(", "factories", "...", "SchemaFactory", ")", "{", "factoriesLock", ".", "Lock", "(", ")", "\n", "defer", "factoriesLock", ".", "Unlock", "(", ")", "\n", "schemaFactories", "=", "append", "(", "schemaFactories", ",", "factorie...
// RegisterSchemaFactories is used to register a table schema.
[ "RegisterSchemaFactories", "is", "used", "to", "register", "a", "table", "schema", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L21-L25
132,609
hashicorp/nomad
nomad/state/schema.go
stateStoreSchema
func stateStoreSchema() *memdb.DBSchema { // Create the root DB schema db := &memdb.DBSchema{ Tables: make(map[string]*memdb.TableSchema), } // Add each of the tables for _, schemaFn := range GetFactories() { schema := schemaFn() if _, ok := db.Tables[schema.Name]; ok { panic(fmt.Sprintf("duplicate table...
go
func stateStoreSchema() *memdb.DBSchema { // Create the root DB schema db := &memdb.DBSchema{ Tables: make(map[string]*memdb.TableSchema), } // Add each of the tables for _, schemaFn := range GetFactories() { schema := schemaFn() if _, ok := db.Tables[schema.Name]; ok { panic(fmt.Sprintf("duplicate table...
[ "func", "stateStoreSchema", "(", ")", "*", "memdb", ".", "DBSchema", "{", "// Create the root DB schema", "db", ":=", "&", "memdb", ".", "DBSchema", "{", "Tables", ":", "make", "(", "map", "[", "string", "]", "*", "memdb", ".", "TableSchema", ")", ",", "...
// stateStoreSchema is used to return the schema for the state store
[ "stateStoreSchema", "is", "used", "to", "return", "the", "schema", "for", "the", "state", "store" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L52-L67
132,610
hashicorp/nomad
nomad/state/schema.go
jobTableSchema
func jobTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "jobs", Indexes: map[string]*memdb.IndexSchema{ // Primary index is used for job management // and simple direct lookup. ID is required to be // unique within a namespace. "id": { Name: "id", AllowMissing: false...
go
func jobTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "jobs", Indexes: map[string]*memdb.IndexSchema{ // Primary index is used for job management // and simple direct lookup. ID is required to be // unique within a namespace. "id": { Name: "id", AllowMissing: false...
[ "func", "jobTableSchema", "(", ")", "*", "memdb", ".", "TableSchema", "{", "return", "&", "memdb", ".", "TableSchema", "{", "Name", ":", "\"", "\"", ",", "Indexes", ":", "map", "[", "string", "]", "*", "memdb", ".", "IndexSchema", "{", "// Primary index ...
// jobTableSchema returns the MemDB schema for the jobs table. // This table is used to store all the jobs that have been submitted.
[ "jobTableSchema", "returns", "the", "MemDB", "schema", "for", "the", "jobs", "table", ".", "This", "table", "is", "used", "to", "store", "all", "the", "jobs", "that", "have", "been", "submitted", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L118-L171
132,611
hashicorp/nomad
nomad/state/schema.go
jobVersionSchema
func jobVersionSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "job_version", Indexes: map[string]*memdb.IndexSchema{ "id": { Name: "id", AllowMissing: false, Unique: true, // Use a compound index so the tuple of (Namespace, ID, Version) is // uniquely identifyi...
go
func jobVersionSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "job_version", Indexes: map[string]*memdb.IndexSchema{ "id": { Name: "id", AllowMissing: false, Unique: true, // Use a compound index so the tuple of (Namespace, ID, Version) is // uniquely identifyi...
[ "func", "jobVersionSchema", "(", ")", "*", "memdb", ".", "TableSchema", "{", "return", "&", "memdb", ".", "TableSchema", "{", "Name", ":", "\"", "\"", ",", "Indexes", ":", "map", "[", "string", "]", "*", "memdb", ".", "IndexSchema", "{", "\"", "\"", ...
// jobVersionSchema returns the memdb schema for the job version table which // keeps a historical view of job versions.
[ "jobVersionSchema", "returns", "the", "memdb", "schema", "for", "the", "job", "version", "table", "which", "keeps", "a", "historical", "view", "of", "job", "versions", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L203-L233
132,612
hashicorp/nomad
nomad/state/schema.go
jobIsGCable
func jobIsGCable(obj interface{}) (bool, error) { j, ok := obj.(*structs.Job) if !ok { return false, fmt.Errorf("Unexpected type: %v", obj) } // If the job is periodic or parameterized it is only garbage collectable if // it is stopped. periodic := j.Periodic != nil && j.Periodic.Enabled parameterized := j.Is...
go
func jobIsGCable(obj interface{}) (bool, error) { j, ok := obj.(*structs.Job) if !ok { return false, fmt.Errorf("Unexpected type: %v", obj) } // If the job is periodic or parameterized it is only garbage collectable if // it is stopped. periodic := j.Periodic != nil && j.Periodic.Enabled parameterized := j.Is...
[ "func", "jobIsGCable", "(", "obj", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "j", ",", "ok", ":=", "obj", ".", "(", "*", "structs", ".", "Job", ")", "\n", "if", "!", "ok", "{", "return", "false", ",", "fmt", ".", "Errorf"...
// jobIsGCable satisfies the ConditionalIndexFunc interface and creates an index // on whether a job is eligible for garbage collection.
[ "jobIsGCable", "satisfies", "the", "ConditionalIndexFunc", "interface", "and", "creates", "an", "index", "on", "whether", "a", "job", "is", "eligible", "for", "garbage", "collection", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L237-L268
132,613
hashicorp/nomad
nomad/state/schema.go
jobIsPeriodic
func jobIsPeriodic(obj interface{}) (bool, error) { j, ok := obj.(*structs.Job) if !ok { return false, fmt.Errorf("Unexpected type: %v", obj) } if j.Periodic != nil && j.Periodic.Enabled == true { return true, nil } return false, nil }
go
func jobIsPeriodic(obj interface{}) (bool, error) { j, ok := obj.(*structs.Job) if !ok { return false, fmt.Errorf("Unexpected type: %v", obj) } if j.Periodic != nil && j.Periodic.Enabled == true { return true, nil } return false, nil }
[ "func", "jobIsPeriodic", "(", "obj", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "j", ",", "ok", ":=", "obj", ".", "(", "*", "structs", ".", "Job", ")", "\n", "if", "!", "ok", "{", "return", "false", ",", "fmt", ".", "Error...
// jobIsPeriodic satisfies the ConditionalIndexFunc interface and creates an index // on whether a job is periodic.
[ "jobIsPeriodic", "satisfies", "the", "ConditionalIndexFunc", "interface", "and", "creates", "an", "index", "on", "whether", "a", "job", "is", "periodic", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L272-L283
132,614
hashicorp/nomad
nomad/state/schema.go
periodicLaunchTableSchema
func periodicLaunchTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "periodic_launch", Indexes: map[string]*memdb.IndexSchema{ // Primary index is used for job management // and simple direct lookup. ID is required to be // unique. "id": { Name: "id", AllowMissing: fa...
go
func periodicLaunchTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "periodic_launch", Indexes: map[string]*memdb.IndexSchema{ // Primary index is used for job management // and simple direct lookup. ID is required to be // unique. "id": { Name: "id", AllowMissing: fa...
[ "func", "periodicLaunchTableSchema", "(", ")", "*", "memdb", ".", "TableSchema", "{", "return", "&", "memdb", ".", "TableSchema", "{", "Name", ":", "\"", "\"", ",", "Indexes", ":", "map", "[", "string", "]", "*", "memdb", ".", "IndexSchema", "{", "// Pri...
// periodicLaunchTableSchema returns the MemDB schema tracking the most recent // launch time for a periodic job.
[ "periodicLaunchTableSchema", "returns", "the", "MemDB", "schema", "tracking", "the", "most", "recent", "launch", "time", "for", "a", "periodic", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L334-L362
132,615
hashicorp/nomad
nomad/state/schema.go
allocTableSchema
func allocTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "allocs", Indexes: map[string]*memdb.IndexSchema{ // Primary index is a UUID "id": { Name: "id", AllowMissing: false, Unique: true, Indexer: &memdb.UUIDFieldIndex{ Field: "ID", }, }, "n...
go
func allocTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "allocs", Indexes: map[string]*memdb.IndexSchema{ // Primary index is a UUID "id": { Name: "id", AllowMissing: false, Unique: true, Indexer: &memdb.UUIDFieldIndex{ Field: "ID", }, }, "n...
[ "func", "allocTableSchema", "(", ")", "*", "memdb", ".", "TableSchema", "{", "return", "&", "memdb", ".", "TableSchema", "{", "Name", ":", "\"", "\"", ",", "Indexes", ":", "map", "[", "string", "]", "*", "memdb", ".", "IndexSchema", "{", "// Primary inde...
// allocTableSchema returns the MemDB schema for the allocation table. // This table is used to store all the task allocations between task groups // and nodes.
[ "allocTableSchema", "returns", "the", "MemDB", "schema", "for", "the", "allocation", "table", ".", "This", "table", "is", "used", "to", "store", "all", "the", "task", "allocations", "between", "task", "groups", "and", "nodes", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L420-L512
132,616
hashicorp/nomad
nomad/state/schema.go
vaultAccessorTableSchema
func vaultAccessorTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "vault_accessors", Indexes: map[string]*memdb.IndexSchema{ // The primary index is the accessor id "id": { Name: "id", AllowMissing: false, Unique: true, Indexer: &memdb.StringFieldIndex{ ...
go
func vaultAccessorTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "vault_accessors", Indexes: map[string]*memdb.IndexSchema{ // The primary index is the accessor id "id": { Name: "id", AllowMissing: false, Unique: true, Indexer: &memdb.StringFieldIndex{ ...
[ "func", "vaultAccessorTableSchema", "(", ")", "*", "memdb", ".", "TableSchema", "{", "return", "&", "memdb", ".", "TableSchema", "{", "Name", ":", "\"", "\"", ",", "Indexes", ":", "map", "[", "string", "]", "*", "memdb", ".", "IndexSchema", "{", "// The ...
// vaultAccessorTableSchema returns the MemDB schema for the Vault Accessor // Table. This table tracks Vault accessors for tokens created on behalf of // allocations required Vault tokens.
[ "vaultAccessorTableSchema", "returns", "the", "MemDB", "schema", "for", "the", "Vault", "Accessor", "Table", ".", "This", "table", "tracks", "Vault", "accessors", "for", "tokens", "created", "on", "behalf", "of", "allocations", "required", "Vault", "tokens", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L517-L550
132,617
hashicorp/nomad
nomad/state/schema.go
aclTokenTableSchema
func aclTokenTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "acl_token", Indexes: map[string]*memdb.IndexSchema{ "id": { Name: "id", AllowMissing: false, Unique: true, Indexer: &memdb.UUIDFieldIndex{ Field: "AccessorID", }, }, "secret": { Nam...
go
func aclTokenTableSchema() *memdb.TableSchema { return &memdb.TableSchema{ Name: "acl_token", Indexes: map[string]*memdb.IndexSchema{ "id": { Name: "id", AllowMissing: false, Unique: true, Indexer: &memdb.UUIDFieldIndex{ Field: "AccessorID", }, }, "secret": { Nam...
[ "func", "aclTokenTableSchema", "(", ")", "*", "memdb", ".", "TableSchema", "{", "return", "&", "memdb", ".", "TableSchema", "{", "Name", ":", "\"", "\"", ",", "Indexes", ":", "map", "[", "string", "]", "*", "memdb", ".", "IndexSchema", "{", "\"", "\"",...
// aclTokenTableSchema returns the MemDB schema for the tokens table. // This table is used to store the bearer tokens which are used to authenticate
[ "aclTokenTableSchema", "returns", "the", "MemDB", "schema", "for", "the", "tokens", "table", ".", "This", "table", "is", "used", "to", "store", "the", "bearer", "tokens", "which", "are", "used", "to", "authenticate" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/schema.go#L572-L602
132,618
hashicorp/nomad
client/node_updater.go
batchFirstFingerprints
func (c *Client) batchFirstFingerprints() { ctx, cancel := context.WithTimeout(context.Background(), batchFirstFingerprintsTimeout) defer cancel() ch, err := c.pluginManagers.WaitForFirstFingerprint(ctx) if err != nil { c.logger.Warn("failed to batch initial fingerprint updates, switching to incemental updates")...
go
func (c *Client) batchFirstFingerprints() { ctx, cancel := context.WithTimeout(context.Background(), batchFirstFingerprintsTimeout) defer cancel() ch, err := c.pluginManagers.WaitForFirstFingerprint(ctx) if err != nil { c.logger.Warn("failed to batch initial fingerprint updates, switching to incemental updates")...
[ "func", "(", "c", "*", "Client", ")", "batchFirstFingerprints", "(", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "batchFirstFingerprintsTimeout", ")", "\n", "defer", "cancel", "(", ...
// batchFirstFingerprints waits for the first fingerprint response from all // plugin managers and sends a single Node update for all fingerprints. It // should only ever be called once
[ "batchFirstFingerprints", "waits", "for", "the", "first", "fingerprint", "response", "from", "all", "plugin", "managers", "and", "sends", "a", "single", "Node", "update", "for", "all", "fingerprints", ".", "It", "should", "only", "ever", "be", "called", "once" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L23-L69
132,619
hashicorp/nomad
client/node_updater.go
updateNodeFromDriver
func (c *Client) updateNodeFromDriver(name string, info *structs.DriverInfo) { c.configLock.Lock() defer c.configLock.Unlock() if c.updateNodeFromDriverLocked(name, info) { c.config.Node.Drivers[name] = info if c.config.Node.Drivers[name].UpdateTime.IsZero() { c.config.Node.Drivers[name].UpdateTime = time.No...
go
func (c *Client) updateNodeFromDriver(name string, info *structs.DriverInfo) { c.configLock.Lock() defer c.configLock.Unlock() if c.updateNodeFromDriverLocked(name, info) { c.config.Node.Drivers[name] = info if c.config.Node.Drivers[name].UpdateTime.IsZero() { c.config.Node.Drivers[name].UpdateTime = time.No...
[ "func", "(", "c", "*", "Client", ")", "updateNodeFromDriver", "(", "name", "string", ",", "info", "*", "structs", ".", "DriverInfo", ")", "{", "c", ".", "configLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "configLock", ".", "Unlock", "(", "...
// updateNodeFromDriver receives a DriverInfo struct for the driver and updates // the node accordingly
[ "updateNodeFromDriver", "receives", "a", "DriverInfo", "struct", "for", "the", "driver", "and", "updates", "the", "node", "accordingly" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L73-L84
132,620
hashicorp/nomad
client/node_updater.go
updateNodeFromDriverLocked
func (c *Client) updateNodeFromDriverLocked(name string, info *structs.DriverInfo) bool { var hasChanged bool hadDriver := c.config.Node.Drivers[name] != nil if !hadDriver { // If the driver info has not yet been set, do that here hasChanged = true for attrName, newVal := range info.Attributes { c.config.N...
go
func (c *Client) updateNodeFromDriverLocked(name string, info *structs.DriverInfo) bool { var hasChanged bool hadDriver := c.config.Node.Drivers[name] != nil if !hadDriver { // If the driver info has not yet been set, do that here hasChanged = true for attrName, newVal := range info.Attributes { c.config.N...
[ "func", "(", "c", "*", "Client", ")", "updateNodeFromDriverLocked", "(", "name", "string", ",", "info", "*", "structs", ".", "DriverInfo", ")", "bool", "{", "var", "hasChanged", "bool", "\n\n", "hadDriver", ":=", "c", ".", "config", ".", "Node", ".", "Dr...
// updateNodeFromDriverLocked makes the changes to the node from a driver update // but does not send the update to the server. c.configLock must be held before // calling this func
[ "updateNodeFromDriverLocked", "makes", "the", "changes", "to", "the", "node", "from", "a", "driver", "update", "but", "does", "not", "send", "the", "update", "to", "the", "server", ".", "c", ".", "configLock", "must", "be", "held", "before", "calling", "this...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L89-L146
132,621
hashicorp/nomad
client/node_updater.go
updateNodeFromDevicesLocked
func (c *Client) updateNodeFromDevicesLocked(devices []*structs.NodeDeviceResource) bool { if !structs.DevicesEquals(c.config.Node.NodeResources.Devices, devices) { c.logger.Debug("new devices detected", "devices", len(devices)) c.config.Node.NodeResources.Devices = devices return true } return false }
go
func (c *Client) updateNodeFromDevicesLocked(devices []*structs.NodeDeviceResource) bool { if !structs.DevicesEquals(c.config.Node.NodeResources.Devices, devices) { c.logger.Debug("new devices detected", "devices", len(devices)) c.config.Node.NodeResources.Devices = devices return true } return false }
[ "func", "(", "c", "*", "Client", ")", "updateNodeFromDevicesLocked", "(", "devices", "[", "]", "*", "structs", ".", "NodeDeviceResource", ")", "bool", "{", "if", "!", "structs", ".", "DevicesEquals", "(", "c", ".", "config", ".", "Node", ".", "NodeResource...
// updateNodeFromDevicesLocked updates the node with the results of devices, // but does send the update to the server. c.configLock must be held before // calling this func
[ "updateNodeFromDevicesLocked", "updates", "the", "node", "with", "the", "results", "of", "devices", "but", "does", "send", "the", "update", "to", "the", "server", ".", "c", ".", "configLock", "must", "be", "held", "before", "calling", "this", "func" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L165-L173
132,622
hashicorp/nomad
client/node_updater.go
updateNodeFromDriver
func (b *batchNodeUpdates) updateNodeFromDriver(driver string, info *structs.DriverInfo) { b.driversMu.Lock() defer b.driversMu.Unlock() if b.driversBatched { b.driverCB(driver, info) return } b.drivers[driver] = info }
go
func (b *batchNodeUpdates) updateNodeFromDriver(driver string, info *structs.DriverInfo) { b.driversMu.Lock() defer b.driversMu.Unlock() if b.driversBatched { b.driverCB(driver, info) return } b.drivers[driver] = info }
[ "func", "(", "b", "*", "batchNodeUpdates", ")", "updateNodeFromDriver", "(", "driver", "string", ",", "info", "*", "structs", ".", "DriverInfo", ")", "{", "b", ".", "driversMu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "driversMu", ".", "Unlock", ...
// updateNodeFromDriver implements drivermanager.UpdateNodeDriverInfoFn and is // used in the driver manager to send driver fingerprints to
[ "updateNodeFromDriver", "implements", "drivermanager", ".", "UpdateNodeDriverInfoFn", "and", "is", "used", "in", "the", "driver", "manager", "to", "send", "driver", "fingerprints", "to" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L206-L215
132,623
hashicorp/nomad
client/node_updater.go
batchDriverUpdates
func (b *batchNodeUpdates) batchDriverUpdates(f drivermanager.UpdateNodeDriverInfoFn) error { b.driversMu.Lock() defer b.driversMu.Unlock() if b.driversBatched { return fmt.Errorf("driver updates already batched") } b.driversBatched = true for driver, info := range b.drivers { f(driver, info) } return nil ...
go
func (b *batchNodeUpdates) batchDriverUpdates(f drivermanager.UpdateNodeDriverInfoFn) error { b.driversMu.Lock() defer b.driversMu.Unlock() if b.driversBatched { return fmt.Errorf("driver updates already batched") } b.driversBatched = true for driver, info := range b.drivers { f(driver, info) } return nil ...
[ "func", "(", "b", "*", "batchNodeUpdates", ")", "batchDriverUpdates", "(", "f", "drivermanager", ".", "UpdateNodeDriverInfoFn", ")", "error", "{", "b", ".", "driversMu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "driversMu", ".", "Unlock", "(", ")", ...
// batchDriverUpdates sends all of the batched driver node updates by calling f // for each driver batched
[ "batchDriverUpdates", "sends", "all", "of", "the", "batched", "driver", "node", "updates", "by", "calling", "f", "for", "each", "driver", "batched" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L219-L231
132,624
hashicorp/nomad
client/node_updater.go
updateNodeFromDevices
func (b *batchNodeUpdates) updateNodeFromDevices(devices []*structs.NodeDeviceResource) { b.devicesMu.Lock() defer b.devicesMu.Unlock() if b.devicesBatched { b.devicesCB(devices) return } b.devices = devices }
go
func (b *batchNodeUpdates) updateNodeFromDevices(devices []*structs.NodeDeviceResource) { b.devicesMu.Lock() defer b.devicesMu.Unlock() if b.devicesBatched { b.devicesCB(devices) return } b.devices = devices }
[ "func", "(", "b", "*", "batchNodeUpdates", ")", "updateNodeFromDevices", "(", "devices", "[", "]", "*", "structs", ".", "NodeDeviceResource", ")", "{", "b", ".", "devicesMu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "devicesMu", ".", "Unlock", "("...
// updateNodeFromDevices implements devicemanager.UpdateNodeDevicesFn and is // used in the device manager to send device fingerprints to
[ "updateNodeFromDevices", "implements", "devicemanager", ".", "UpdateNodeDevicesFn", "and", "is", "used", "in", "the", "device", "manager", "to", "send", "device", "fingerprints", "to" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L235-L244
132,625
hashicorp/nomad
client/node_updater.go
batchDevicesUpdates
func (b *batchNodeUpdates) batchDevicesUpdates(f devicemanager.UpdateNodeDevicesFn) error { b.devicesMu.Lock() defer b.devicesMu.Unlock() if b.devicesBatched { return fmt.Errorf("devices updates already batched") } b.devicesBatched = true f(b.devices) return nil }
go
func (b *batchNodeUpdates) batchDevicesUpdates(f devicemanager.UpdateNodeDevicesFn) error { b.devicesMu.Lock() defer b.devicesMu.Unlock() if b.devicesBatched { return fmt.Errorf("devices updates already batched") } b.devicesBatched = true f(b.devices) return nil }
[ "func", "(", "b", "*", "batchNodeUpdates", ")", "batchDevicesUpdates", "(", "f", "devicemanager", ".", "UpdateNodeDevicesFn", ")", "error", "{", "b", ".", "devicesMu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "devicesMu", ".", "Unlock", "(", ")", ...
// batchDevicesUpdates sends the batched device node updates by calling f with // the devices
[ "batchDevicesUpdates", "sends", "the", "batched", "device", "node", "updates", "by", "calling", "f", "with", "the", "devices" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/node_updater.go#L248-L258
132,626
hashicorp/nomad
helper/pluginutils/loader/filter_windows.go
executable
func executable(path string, s os.FileInfo) bool { return filepath.Ext(path) == ".exe" }
go
func executable(path string, s os.FileInfo) bool { return filepath.Ext(path) == ".exe" }
[ "func", "executable", "(", "path", "string", ",", "s", "os", ".", "FileInfo", ")", "bool", "{", "return", "filepath", ".", "Ext", "(", "path", ")", "==", "\"", "\"", "\n", "}" ]
// On windows, an executable can be any file with any extension. To avoid // introspecting the file, here we skip executability checks on windows systems // and simply check for the convention of an `.exe` extension.
[ "On", "windows", "an", "executable", "can", "be", "any", "file", "with", "any", "extension", ".", "To", "avoid", "introspecting", "the", "file", "here", "we", "skip", "executability", "checks", "on", "windows", "systems", "and", "simply", "check", "for", "th...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/filter_windows.go#L13-L15
132,627
hashicorp/nomad
command/check.go
checkClientHealth
func (c *AgentCheckCommand) checkClientHealth(clientStats map[string]string, minServers int) int { knownServers, err := strconv.Atoi(clientStats["known_servers"]) if err != nil { c.Ui.Output(fmt.Sprintf("unable to get known servers: %v", err)) return HealthCritical } heartbeatTTL, err := time.ParseDuration(cli...
go
func (c *AgentCheckCommand) checkClientHealth(clientStats map[string]string, minServers int) int { knownServers, err := strconv.Atoi(clientStats["known_servers"]) if err != nil { c.Ui.Output(fmt.Sprintf("unable to get known servers: %v", err)) return HealthCritical } heartbeatTTL, err := time.ParseDuration(cli...
[ "func", "(", "c", "*", "AgentCheckCommand", ")", "checkClientHealth", "(", "clientStats", "map", "[", "string", "]", "string", ",", "minServers", "int", ")", "int", "{", "knownServers", ",", "err", ":=", "strconv", ".", "Atoi", "(", "clientStats", "[", "\"...
// checkClientHealth returns the health of a client
[ "checkClientHealth", "returns", "the", "health", "of", "a", "client" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/check.go#L110-L140
132,628
hashicorp/nomad
nomad/structs/funcs.go
MergeMultierrorWarnings
func MergeMultierrorWarnings(warnings ...error) string { var warningMsg multierror.Error for _, warn := range warnings { if warn != nil { multierror.Append(&warningMsg, warn) } } if len(warningMsg.Errors) == 0 { return "" } // Set the formatter warningMsg.ErrorFormat = warningsFormatter return warnin...
go
func MergeMultierrorWarnings(warnings ...error) string { var warningMsg multierror.Error for _, warn := range warnings { if warn != nil { multierror.Append(&warningMsg, warn) } } if len(warningMsg.Errors) == 0 { return "" } // Set the formatter warningMsg.ErrorFormat = warningsFormatter return warnin...
[ "func", "MergeMultierrorWarnings", "(", "warnings", "...", "error", ")", "string", "{", "var", "warningMsg", "multierror", ".", "Error", "\n", "for", "_", ",", "warn", ":=", "range", "warnings", "{", "if", "warn", "!=", "nil", "{", "multierror", ".", "Appe...
// MergeMultierrorWarnings takes job warnings and canonicalize warnings and // merges them into a returnable string. Both the errors may be nil.
[ "MergeMultierrorWarnings", "takes", "job", "warnings", "and", "canonicalize", "warnings", "and", "merges", "them", "into", "a", "returnable", "string", ".", "Both", "the", "errors", "may", "be", "nil", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L21-L36
132,629
hashicorp/nomad
nomad/structs/funcs.go
warningsFormatter
func warningsFormatter(es []error) string { points := make([]string, len(es)) for i, err := range es { points[i] = fmt.Sprintf("* %s", err) } return fmt.Sprintf( "%d warning(s):\n\n%s", len(es), strings.Join(points, "\n")) }
go
func warningsFormatter(es []error) string { points := make([]string, len(es)) for i, err := range es { points[i] = fmt.Sprintf("* %s", err) } return fmt.Sprintf( "%d warning(s):\n\n%s", len(es), strings.Join(points, "\n")) }
[ "func", "warningsFormatter", "(", "es", "[", "]", "error", ")", "string", "{", "points", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "es", ")", ")", "\n", "for", "i", ",", "err", ":=", "range", "es", "{", "points", "[", "i", "]", "=...
// warningsFormatter is used to format job warnings
[ "warningsFormatter", "is", "used", "to", "format", "job", "warnings" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L39-L48
132,630
hashicorp/nomad
nomad/structs/funcs.go
RemoveAllocs
func RemoveAllocs(alloc []*Allocation, remove []*Allocation) []*Allocation { // Convert remove into a set removeSet := make(map[string]struct{}) for _, remove := range remove { removeSet[remove.ID] = struct{}{} } n := len(alloc) for i := 0; i < n; i++ { if _, ok := removeSet[alloc[i].ID]; ok { alloc[i], a...
go
func RemoveAllocs(alloc []*Allocation, remove []*Allocation) []*Allocation { // Convert remove into a set removeSet := make(map[string]struct{}) for _, remove := range remove { removeSet[remove.ID] = struct{}{} } n := len(alloc) for i := 0; i < n; i++ { if _, ok := removeSet[alloc[i].ID]; ok { alloc[i], a...
[ "func", "RemoveAllocs", "(", "alloc", "[", "]", "*", "Allocation", ",", "remove", "[", "]", "*", "Allocation", ")", "[", "]", "*", "Allocation", "{", "// Convert remove into a set", "removeSet", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", ...
// RemoveAllocs is used to remove any allocs with the given IDs // from the list of allocations
[ "RemoveAllocs", "is", "used", "to", "remove", "any", "allocs", "with", "the", "given", "IDs", "from", "the", "list", "of", "allocations" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L52-L70
132,631
hashicorp/nomad
nomad/structs/funcs.go
FilterTerminalAllocs
func FilterTerminalAllocs(allocs []*Allocation) ([]*Allocation, map[string]*Allocation) { terminalAllocsByName := make(map[string]*Allocation) n := len(allocs) for i := 0; i < n; i++ { if allocs[i].TerminalStatus() { // Add the allocation to the terminal allocs map if it's not already // added or has a high...
go
func FilterTerminalAllocs(allocs []*Allocation) ([]*Allocation, map[string]*Allocation) { terminalAllocsByName := make(map[string]*Allocation) n := len(allocs) for i := 0; i < n; i++ { if allocs[i].TerminalStatus() { // Add the allocation to the terminal allocs map if it's not already // added or has a high...
[ "func", "FilterTerminalAllocs", "(", "allocs", "[", "]", "*", "Allocation", ")", "(", "[", "]", "*", "Allocation", ",", "map", "[", "string", "]", "*", "Allocation", ")", "{", "terminalAllocsByName", ":=", "make", "(", "map", "[", "string", "]", "*", "...
// FilterTerminalAllocs filters out all allocations in a terminal state and // returns the latest terminal allocations
[ "FilterTerminalAllocs", "filters", "out", "all", "allocations", "in", "a", "terminal", "state", "and", "returns", "the", "latest", "terminal", "allocations" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L74-L95
132,632
hashicorp/nomad
nomad/structs/funcs.go
AllocsFit
func AllocsFit(node *Node, allocs []*Allocation, netIdx *NetworkIndex, checkDevices bool) (bool, string, *ComparableResources, error) { // Compute the utilization from zero used := new(ComparableResources) // Add the reserved resources of the node used.Add(node.ComparableReservedResources()) // For each alloc, a...
go
func AllocsFit(node *Node, allocs []*Allocation, netIdx *NetworkIndex, checkDevices bool) (bool, string, *ComparableResources, error) { // Compute the utilization from zero used := new(ComparableResources) // Add the reserved resources of the node used.Add(node.ComparableReservedResources()) // For each alloc, a...
[ "func", "AllocsFit", "(", "node", "*", "Node", ",", "allocs", "[", "]", "*", "Allocation", ",", "netIdx", "*", "NetworkIndex", ",", "checkDevices", "bool", ")", "(", "bool", ",", "string", ",", "*", "ComparableResources", ",", "error", ")", "{", "// Comp...
// AllocsFit checks if a given set of allocations will fit on a node. // The netIdx can optionally be provided if its already been computed. // If the netIdx is provided, it is assumed that the client has already // ensured there are no collisions. If checkDevices is set to true, we check if // there is a device oversu...
[ "AllocsFit", "checks", "if", "a", "given", "set", "of", "allocations", "will", "fit", "on", "a", "node", ".", "The", "netIdx", "can", "optionally", "be", "provided", "if", "its", "already", "been", "computed", ".", "If", "the", "netIdx", "is", "provided", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L102-L149
132,633
hashicorp/nomad
nomad/structs/funcs.go
VaultPoliciesSet
func VaultPoliciesSet(policies map[string]map[string]*Vault) []string { set := make(map[string]struct{}) for _, tgp := range policies { for _, tp := range tgp { for _, p := range tp.Policies { set[p] = struct{}{} } } } flattened := make([]string, 0, len(set)) for p := range set { flattened = appe...
go
func VaultPoliciesSet(policies map[string]map[string]*Vault) []string { set := make(map[string]struct{}) for _, tgp := range policies { for _, tp := range tgp { for _, p := range tp.Policies { set[p] = struct{}{} } } } flattened := make([]string, 0, len(set)) for p := range set { flattened = appe...
[ "func", "VaultPoliciesSet", "(", "policies", "map", "[", "string", "]", "map", "[", "string", "]", "*", "Vault", ")", "[", "]", "string", "{", "set", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n\n", "for", "_", ",", ...
// VaultPoliciesSet takes the structure returned by VaultPolicies and returns // the set of required policies
[ "VaultPoliciesSet", "takes", "the", "structure", "returned", "by", "VaultPolicies", "and", "returns", "the", "set", "of", "required", "policies" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L257-L273
132,634
hashicorp/nomad
nomad/structs/funcs.go
DenormalizeAllocationJobs
func DenormalizeAllocationJobs(job *Job, allocs []*Allocation) { if job != nil { for _, alloc := range allocs { if alloc.Job == nil && !alloc.TerminalStatus() { alloc.Job = job } } } }
go
func DenormalizeAllocationJobs(job *Job, allocs []*Allocation) { if job != nil { for _, alloc := range allocs { if alloc.Job == nil && !alloc.TerminalStatus() { alloc.Job = job } } } }
[ "func", "DenormalizeAllocationJobs", "(", "job", "*", "Job", ",", "allocs", "[", "]", "*", "Allocation", ")", "{", "if", "job", "!=", "nil", "{", "for", "_", ",", "alloc", ":=", "range", "allocs", "{", "if", "alloc", ".", "Job", "==", "nil", "&&", ...
// DenormalizeAllocationJobs is used to attach a job to all allocations that are // non-terminal and do not have a job already. This is useful in cases where the // job is normalized.
[ "DenormalizeAllocationJobs", "is", "used", "to", "attach", "a", "job", "to", "all", "allocations", "that", "are", "non", "-", "terminal", "and", "do", "not", "have", "a", "job", "already", ".", "This", "is", "useful", "in", "cases", "where", "the", "job", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L278-L286
132,635
hashicorp/nomad
nomad/structs/funcs.go
AllocName
func AllocName(job, group string, idx uint) string { return fmt.Sprintf("%s.%s[%d]", job, group, idx) }
go
func AllocName(job, group string, idx uint) string { return fmt.Sprintf("%s.%s[%d]", job, group, idx) }
[ "func", "AllocName", "(", "job", ",", "group", "string", ",", "idx", "uint", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "job", ",", "group", ",", "idx", ")", "\n", "}" ]
// AllocName returns the name of the allocation given the input.
[ "AllocName", "returns", "the", "name", "of", "the", "allocation", "given", "the", "input", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L289-L291
132,636
hashicorp/nomad
nomad/structs/funcs.go
ACLPolicyListHash
func ACLPolicyListHash(policies []*ACLPolicy) string { cacheKeyHash, err := blake2b.New256(nil) if err != nil { panic(err) } for _, policy := range policies { cacheKeyHash.Write([]byte(policy.Name)) binary.Write(cacheKeyHash, binary.BigEndian, policy.ModifyIndex) } cacheKey := string(cacheKeyHash.Sum(nil)) ...
go
func ACLPolicyListHash(policies []*ACLPolicy) string { cacheKeyHash, err := blake2b.New256(nil) if err != nil { panic(err) } for _, policy := range policies { cacheKeyHash.Write([]byte(policy.Name)) binary.Write(cacheKeyHash, binary.BigEndian, policy.ModifyIndex) } cacheKey := string(cacheKeyHash.Sum(nil)) ...
[ "func", "ACLPolicyListHash", "(", "policies", "[", "]", "*", "ACLPolicy", ")", "string", "{", "cacheKeyHash", ",", "err", ":=", "blake2b", ".", "New256", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n",...
// ACLPolicyListHash returns a consistent hash for a set of policies.
[ "ACLPolicyListHash", "returns", "a", "consistent", "hash", "for", "a", "set", "of", "policies", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L294-L305
132,637
hashicorp/nomad
nomad/structs/funcs.go
CompileACLObject
func CompileACLObject(cache *lru.TwoQueueCache, policies []*ACLPolicy) (*acl.ACL, error) { // Sort the policies to ensure consistent ordering sort.Slice(policies, func(i, j int) bool { return policies[i].Name < policies[j].Name }) // Determine the cache key cacheKey := ACLPolicyListHash(policies) aclRaw, ok :=...
go
func CompileACLObject(cache *lru.TwoQueueCache, policies []*ACLPolicy) (*acl.ACL, error) { // Sort the policies to ensure consistent ordering sort.Slice(policies, func(i, j int) bool { return policies[i].Name < policies[j].Name }) // Determine the cache key cacheKey := ACLPolicyListHash(policies) aclRaw, ok :=...
[ "func", "CompileACLObject", "(", "cache", "*", "lru", ".", "TwoQueueCache", ",", "policies", "[", "]", "*", "ACLPolicy", ")", "(", "*", "acl", ".", "ACL", ",", "error", ")", "{", "// Sort the policies to ensure consistent ordering", "sort", ".", "Slice", "(", ...
// CompileACLObject compiles a set of ACL policies into an ACL object with a cache
[ "CompileACLObject", "compiles", "a", "set", "of", "ACL", "policies", "into", "an", "ACL", "object", "with", "a", "cache" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L308-L340
132,638
hashicorp/nomad
nomad/structs/funcs.go
GenerateMigrateToken
func GenerateMigrateToken(allocID, nodeSecretID string) (string, error) { h, err := blake2b.New512([]byte(nodeSecretID)) if err != nil { return "", err } h.Write([]byte(allocID)) return base64.URLEncoding.EncodeToString(h.Sum(nil)), nil }
go
func GenerateMigrateToken(allocID, nodeSecretID string) (string, error) { h, err := blake2b.New512([]byte(nodeSecretID)) if err != nil { return "", err } h.Write([]byte(allocID)) return base64.URLEncoding.EncodeToString(h.Sum(nil)), nil }
[ "func", "GenerateMigrateToken", "(", "allocID", ",", "nodeSecretID", "string", ")", "(", "string", ",", "error", ")", "{", "h", ",", "err", ":=", "blake2b", ".", "New512", "(", "[", "]", "byte", "(", "nodeSecretID", ")", ")", "\n", "if", "err", "!=", ...
// GenerateMigrateToken will create a token for a client to access an // authenticated volume of another client to migrate data for sticky volumes.
[ "GenerateMigrateToken", "will", "create", "a", "token", "for", "a", "client", "to", "access", "an", "authenticated", "volume", "of", "another", "client", "to", "migrate", "data", "for", "sticky", "volumes", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L344-L351
132,639
hashicorp/nomad
nomad/structs/funcs.go
CompareMigrateToken
func CompareMigrateToken(allocID, nodeSecretID, otherMigrateToken string) bool { h, err := blake2b.New512([]byte(nodeSecretID)) if err != nil { return false } h.Write([]byte(allocID)) otherBytes, err := base64.URLEncoding.DecodeString(otherMigrateToken) if err != nil { return false } return subtle.Constant...
go
func CompareMigrateToken(allocID, nodeSecretID, otherMigrateToken string) bool { h, err := blake2b.New512([]byte(nodeSecretID)) if err != nil { return false } h.Write([]byte(allocID)) otherBytes, err := base64.URLEncoding.DecodeString(otherMigrateToken) if err != nil { return false } return subtle.Constant...
[ "func", "CompareMigrateToken", "(", "allocID", ",", "nodeSecretID", ",", "otherMigrateToken", "string", ")", "bool", "{", "h", ",", "err", ":=", "blake2b", ".", "New512", "(", "[", "]", "byte", "(", "nodeSecretID", ")", ")", "\n", "if", "err", "!=", "nil...
// CompareMigrateToken returns true if two migration tokens can be computed and // are equal.
[ "CompareMigrateToken", "returns", "true", "if", "two", "migration", "tokens", "can", "be", "computed", "and", "are", "equal", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/funcs.go#L355-L367
132,640
hashicorp/nomad
nomad/mock/acl.go
NamespacePolicy
func NamespacePolicy(namespace string, policy string, capabilities []string) string { policyHCL := fmt.Sprintf("namespace %q {", namespace) if policy != "" { policyHCL += fmt.Sprintf("\n\tpolicy = %q", policy) } if len(capabilities) != 0 { for i, s := range capabilities { if !strings.HasPrefix(s, "\"") { ...
go
func NamespacePolicy(namespace string, policy string, capabilities []string) string { policyHCL := fmt.Sprintf("namespace %q {", namespace) if policy != "" { policyHCL += fmt.Sprintf("\n\tpolicy = %q", policy) } if len(capabilities) != 0 { for i, s := range capabilities { if !strings.HasPrefix(s, "\"") { ...
[ "func", "NamespacePolicy", "(", "namespace", "string", ",", "policy", "string", ",", "capabilities", "[", "]", "string", ")", "string", "{", "policyHCL", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "namespace", ")", "\n", "if", "policy", "!=", "\"...
// NamespacePolicy is a helper for generating the policy hcl for a given // namespace. Either policy or capabilities may be nil but not both.
[ "NamespacePolicy", "is", "a", "helper", "for", "generating", "the", "policy", "hcl", "for", "a", "given", "namespace", ".", "Either", "policy", "or", "capabilities", "may", "be", "nil", "but", "not", "both", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/mock/acl.go#L23-L39
132,641
hashicorp/nomad
nomad/mock/acl.go
CreatePolicy
func CreatePolicy(t testing.T, state StateStore, index uint64, name, rule string) { t.Helper() // Create the ACLPolicy policy := &structs.ACLPolicy{ Name: name, Rules: rule, } policy.SetHash() assert.Nil(t, state.UpsertACLPolicies(index, []*structs.ACLPolicy{policy})) }
go
func CreatePolicy(t testing.T, state StateStore, index uint64, name, rule string) { t.Helper() // Create the ACLPolicy policy := &structs.ACLPolicy{ Name: name, Rules: rule, } policy.SetHash() assert.Nil(t, state.UpsertACLPolicies(index, []*structs.ACLPolicy{policy})) }
[ "func", "CreatePolicy", "(", "t", "testing", ".", "T", ",", "state", "StateStore", ",", "index", "uint64", ",", "name", ",", "rule", "string", ")", "{", "t", ".", "Helper", "(", ")", "\n\n", "// Create the ACLPolicy", "policy", ":=", "&", "structs", ".",...
// CreatePolicy creates a policy with the given name and rule.
[ "CreatePolicy", "creates", "a", "policy", "with", "the", "given", "name", "and", "rule", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/mock/acl.go#L57-L67
132,642
hashicorp/nomad
nomad/mock/acl.go
CreateToken
func CreateToken(t testing.T, state StateStore, index uint64, policies []string) *structs.ACLToken { t.Helper() // Create the ACLToken token := ACLToken() token.Policies = policies token.SetHash() assert.Nil(t, state.UpsertACLTokens(index, []*structs.ACLToken{token})) return token }
go
func CreateToken(t testing.T, state StateStore, index uint64, policies []string) *structs.ACLToken { t.Helper() // Create the ACLToken token := ACLToken() token.Policies = policies token.SetHash() assert.Nil(t, state.UpsertACLTokens(index, []*structs.ACLToken{token})) return token }
[ "func", "CreateToken", "(", "t", "testing", ".", "T", ",", "state", "StateStore", ",", "index", "uint64", ",", "policies", "[", "]", "string", ")", "*", "structs", ".", "ACLToken", "{", "t", ".", "Helper", "(", ")", "\n\n", "// Create the ACLToken", "tok...
// CreateToken creates a local, client token for the given policies
[ "CreateToken", "creates", "a", "local", "client", "token", "for", "the", "given", "policies" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/mock/acl.go#L70-L79
132,643
hashicorp/nomad
nomad/mock/acl.go
CreatePolicyAndToken
func CreatePolicyAndToken(t testing.T, state StateStore, index uint64, name, rule string) *structs.ACLToken { CreatePolicy(t, state, index, name, rule) return CreateToken(t, state, index+1, []string{name}) }
go
func CreatePolicyAndToken(t testing.T, state StateStore, index uint64, name, rule string) *structs.ACLToken { CreatePolicy(t, state, index, name, rule) return CreateToken(t, state, index+1, []string{name}) }
[ "func", "CreatePolicyAndToken", "(", "t", "testing", ".", "T", ",", "state", "StateStore", ",", "index", "uint64", ",", "name", ",", "rule", "string", ")", "*", "structs", ".", "ACLToken", "{", "CreatePolicy", "(", "t", ",", "state", ",", "index", ",", ...
// CreatePolicyAndToken creates a policy and then returns a token configured for // just that policy. CreatePolicyAndToken uses the given index and index+1.
[ "CreatePolicyAndToken", "creates", "a", "policy", "and", "then", "returns", "a", "token", "configured", "for", "just", "that", "policy", ".", "CreatePolicyAndToken", "uses", "the", "given", "index", "and", "index", "+", "1", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/mock/acl.go#L83-L86
132,644
hashicorp/nomad
client/vaultclient/vaultclient.go
NewVaultClient
func NewVaultClient(config *config.VaultConfig, logger hclog.Logger, tokenDeriver TokenDeriverFunc) (*vaultClient, error) { if config == nil { return nil, fmt.Errorf("nil vault config") } logger = logger.Named("vault") c := &vaultClient{ config: config, stopCh: make(chan struct{}), // Update channel shoul...
go
func NewVaultClient(config *config.VaultConfig, logger hclog.Logger, tokenDeriver TokenDeriverFunc) (*vaultClient, error) { if config == nil { return nil, fmt.Errorf("nil vault config") } logger = logger.Named("vault") c := &vaultClient{ config: config, stopCh: make(chan struct{}), // Update channel shoul...
[ "func", "NewVaultClient", "(", "config", "*", "config", ".", "VaultConfig", ",", "logger", "hclog", ".", "Logger", ",", "tokenDeriver", "TokenDeriverFunc", ")", "(", "*", "vaultClient", ",", "error", ")", "{", "if", "config", "==", "nil", "{", "return", "n...
// NewVaultClient returns a new vault client from the given config.
[ "NewVaultClient", "returns", "a", "new", "vault", "client", "from", "the", "given", "config", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L127-L175
132,645
hashicorp/nomad
client/vaultclient/vaultclient.go
newVaultClientHeap
func newVaultClientHeap() *vaultClientHeap { return &vaultClientHeap{ heapMap: make(map[string]*vaultClientHeapEntry), heap: make(vaultDataHeapImp, 0), } }
go
func newVaultClientHeap() *vaultClientHeap { return &vaultClientHeap{ heapMap: make(map[string]*vaultClientHeapEntry), heap: make(vaultDataHeapImp, 0), } }
[ "func", "newVaultClientHeap", "(", ")", "*", "vaultClientHeap", "{", "return", "&", "vaultClientHeap", "{", "heapMap", ":", "make", "(", "map", "[", "string", "]", "*", "vaultClientHeapEntry", ")", ",", "heap", ":", "make", "(", "vaultDataHeapImp", ",", "0",...
// newVaultClientHeap returns a new vault client heap with both the heap and a // map which is a secondary index for heap elements, both initialized.
[ "newVaultClientHeap", "returns", "a", "new", "vault", "client", "heap", "with", "both", "the", "heap", "and", "a", "map", "which", "is", "a", "secondary", "index", "for", "heap", "elements", "both", "initialized", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L179-L184
132,646
hashicorp/nomad
client/vaultclient/vaultclient.go
isTracked
func (c *vaultClient) isTracked(id string) bool { if id == "" { return false } _, ok := c.heap.heapMap[id] return ok }
go
func (c *vaultClient) isTracked(id string) bool { if id == "" { return false } _, ok := c.heap.heapMap[id] return ok }
[ "func", "(", "c", "*", "vaultClient", ")", "isTracked", "(", "id", "string", ")", "bool", "{", "if", "id", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "_", ",", "ok", ":=", "c", ".", "heap", ".", "heapMap", "[", "id", "]", "\n"...
// isTracked returns if a given identifier is already present in the heap and // hence is being renewed. Lock should be held before calling this method.
[ "isTracked", "returns", "if", "a", "given", "identifier", "is", "already", "present", "in", "the", "heap", "and", "hence", "is", "being", "renewed", ".", "Lock", "should", "be", "held", "before", "calling", "this", "method", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L188-L195
132,647
hashicorp/nomad
client/vaultclient/vaultclient.go
isRunning
func (c *vaultClient) isRunning() bool { c.lock.RLock() defer c.lock.RUnlock() return c.running }
go
func (c *vaultClient) isRunning() bool { c.lock.RLock() defer c.lock.RUnlock() return c.running }
[ "func", "(", "c", "*", "vaultClient", ")", "isRunning", "(", ")", "bool", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n", "return", "c", ".", "running", "\n", "}" ]
// isRunning returns true if the client is running.
[ "isRunning", "returns", "true", "if", "the", "client", "is", "running", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L198-L202
132,648
hashicorp/nomad
client/vaultclient/vaultclient.go
Start
func (c *vaultClient) Start() { c.lock.Lock() defer c.lock.Unlock() if !c.config.IsEnabled() || c.running { return } c.running = true go c.run() }
go
func (c *vaultClient) Start() { c.lock.Lock() defer c.lock.Unlock() if !c.config.IsEnabled() || c.running { return } c.running = true go c.run() }
[ "func", "(", "c", "*", "vaultClient", ")", "Start", "(", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "c", ".", "config", ".", "IsEnabled", "(", ")", "||", "c"...
// Starts the renewal loop of vault client
[ "Starts", "the", "renewal", "loop", "of", "vault", "client" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L205-L216
132,649
hashicorp/nomad
client/vaultclient/vaultclient.go
Stop
func (c *vaultClient) Stop() { c.lock.Lock() defer c.lock.Unlock() if !c.config.IsEnabled() || !c.running { return } c.running = false close(c.stopCh) }
go
func (c *vaultClient) Stop() { c.lock.Lock() defer c.lock.Unlock() if !c.config.IsEnabled() || !c.running { return } c.running = false close(c.stopCh) }
[ "func", "(", "c", "*", "vaultClient", ")", "Stop", "(", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "c", ".", "config", ".", "IsEnabled", "(", ")", "||", "!",...
// Stops the renewal loop of vault client
[ "Stops", "the", "renewal", "loop", "of", "vault", "client" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L219-L229
132,650
hashicorp/nomad
client/vaultclient/vaultclient.go
DeriveToken
func (c *vaultClient) DeriveToken(alloc *structs.Allocation, taskNames []string) (map[string]string, error) { if !c.config.IsEnabled() { return nil, fmt.Errorf("vault client not enabled") } if !c.isRunning() { return nil, fmt.Errorf("vault client is not running") } c.lock.Lock() defer c.unlockAndUnset() //...
go
func (c *vaultClient) DeriveToken(alloc *structs.Allocation, taskNames []string) (map[string]string, error) { if !c.config.IsEnabled() { return nil, fmt.Errorf("vault client not enabled") } if !c.isRunning() { return nil, fmt.Errorf("vault client is not running") } c.lock.Lock() defer c.unlockAndUnset() //...
[ "func", "(", "c", "*", "vaultClient", ")", "DeriveToken", "(", "alloc", "*", "structs", ".", "Allocation", ",", "taskNames", "[", "]", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "if", "!", "c", ".", "config", "...
// DeriveToken takes in an allocation and a set of tasks and for each of the // task, it derives a vault token from nomad server and unwraps it using vault. // The return value is a map containing all the unwrapped tokens indexed by the // task name.
[ "DeriveToken", "takes", "in", "an", "allocation", "and", "a", "set", "of", "tasks", "and", "for", "each", "of", "the", "task", "it", "derives", "a", "vault", "token", "from", "nomad", "server", "and", "unwraps", "it", "using", "vault", ".", "The", "retur...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L242-L263
132,651
hashicorp/nomad
client/vaultclient/vaultclient.go
GetConsulACL
func (c *vaultClient) GetConsulACL(token, path string) (*vaultapi.Secret, error) { if !c.config.IsEnabled() { return nil, fmt.Errorf("vault client not enabled") } if token == "" { return nil, fmt.Errorf("missing token") } if path == "" { return nil, fmt.Errorf("missing consul ACL token vault path") } c.lo...
go
func (c *vaultClient) GetConsulACL(token, path string) (*vaultapi.Secret, error) { if !c.config.IsEnabled() { return nil, fmt.Errorf("vault client not enabled") } if token == "" { return nil, fmt.Errorf("missing token") } if path == "" { return nil, fmt.Errorf("missing consul ACL token vault path") } c.lo...
[ "func", "(", "c", "*", "vaultClient", ")", "GetConsulACL", "(", "token", ",", "path", "string", ")", "(", "*", "vaultapi", ".", "Secret", ",", "error", ")", "{", "if", "!", "c", ".", "config", ".", "IsEnabled", "(", ")", "{", "return", "nil", ",", ...
// GetConsulACL creates a vault API client and reads from vault a consul ACL // token used by the task.
[ "GetConsulACL", "creates", "a", "vault", "API", "client", "and", "reads", "from", "vault", "a", "consul", "ACL", "token", "used", "by", "the", "task", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L267-L286
132,652
hashicorp/nomad
client/vaultclient/vaultclient.go
run
func (c *vaultClient) run() { if !c.config.IsEnabled() { return } var renewalCh <-chan time.Time for c.config.IsEnabled() && c.isRunning() { // Fetches the candidate for next renewal renewalReq, renewalTime := c.nextRenewal() if renewalTime.IsZero() { // If the heap is empty, don't do anything renewa...
go
func (c *vaultClient) run() { if !c.config.IsEnabled() { return } var renewalCh <-chan time.Time for c.config.IsEnabled() && c.isRunning() { // Fetches the candidate for next renewal renewalReq, renewalTime := c.nextRenewal() if renewalTime.IsZero() { // If the heap is empty, don't do anything renewa...
[ "func", "(", "c", "*", "vaultClient", ")", "run", "(", ")", "{", "if", "!", "c", ".", "config", ".", "IsEnabled", "(", ")", "{", "return", "\n", "}", "\n\n", "var", "renewalCh", "<-", "chan", "time", ".", "Time", "\n", "for", "c", ".", "config", ...
// run is the renewal loop which performs the periodic renewals of both the // tokens and the secret leases.
[ "run", "is", "the", "renewal", "loop", "which", "performs", "the", "periodic", "renewals", "of", "both", "the", "tokens", "and", "the", "secret", "leases", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L510-L553
132,653
hashicorp/nomad
client/vaultclient/vaultclient.go
stopRenew
func (c *vaultClient) stopRenew(id string) error { c.lock.Lock() defer c.lock.Unlock() if !c.isTracked(id) { return nil } if err := c.heap.Remove(id); err != nil { return fmt.Errorf("failed to remove heap entry: %v", err) } // Signal an update to the renewal loop. if c.running { select { case c.updat...
go
func (c *vaultClient) stopRenew(id string) error { c.lock.Lock() defer c.lock.Unlock() if !c.isTracked(id) { return nil } if err := c.heap.Remove(id); err != nil { return fmt.Errorf("failed to remove heap entry: %v", err) } // Signal an update to the renewal loop. if c.running { select { case c.updat...
[ "func", "(", "c", "*", "vaultClient", ")", "stopRenew", "(", "id", "string", ")", "error", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "c", ".", "isTracked", "(", "i...
// stopRenew removes the given identifier from the heap and signals the renewal // loop to compute the next best candidate for renewal.
[ "stopRenew", "removes", "the", "given", "identifier", "from", "the", "heap", "and", "signals", "the", "renewal", "loop", "to", "compute", "the", "next", "best", "candidate", "for", "renewal", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L569-L590
132,654
hashicorp/nomad
client/vaultclient/vaultclient.go
nextRenewal
func (c *vaultClient) nextRenewal() (*vaultClientRenewalRequest, time.Time) { c.lock.RLock() defer c.lock.RUnlock() if c.heap.Length() == 0 { return nil, time.Time{} } // Fetches the root element in the min-heap nextEntry := c.heap.Peek() if nextEntry == nil { return nil, time.Time{} } return nextEntry....
go
func (c *vaultClient) nextRenewal() (*vaultClientRenewalRequest, time.Time) { c.lock.RLock() defer c.lock.RUnlock() if c.heap.Length() == 0 { return nil, time.Time{} } // Fetches the root element in the min-heap nextEntry := c.heap.Peek() if nextEntry == nil { return nil, time.Time{} } return nextEntry....
[ "func", "(", "c", "*", "vaultClient", ")", "nextRenewal", "(", ")", "(", "*", "vaultClientRenewalRequest", ",", "time", ".", "Time", ")", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n\...
// nextRenewal returns the root element of the min-heap, which represents the // next element to be renewed and the time at which the renewal needs to be // triggered.
[ "nextRenewal", "returns", "the", "root", "element", "of", "the", "min", "-", "heap", "which", "represents", "the", "next", "element", "to", "be", "renewed", "and", "the", "time", "at", "which", "the", "renewal", "needs", "to", "be", "triggered", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L595-L610
132,655
hashicorp/nomad
client/vaultclient/vaultclient.go
Peek
func (h *vaultClientHeap) Peek() *vaultClientHeapEntry { if len(h.heap) == 0 { return nil } return h.heap[0] }
go
func (h *vaultClientHeap) Peek() *vaultClientHeapEntry { if len(h.heap) == 0 { return nil } return h.heap[0] }
[ "func", "(", "h", "*", "vaultClientHeap", ")", "Peek", "(", ")", "*", "vaultClientHeapEntry", "{", "if", "len", "(", "h", ".", "heap", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "h", ".", "heap", "[", "0", "]", "\n", "}" ]
// Returns the root node of the min-heap
[ "Returns", "the", "root", "node", "of", "the", "min", "-", "heap" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L620-L626
132,656
hashicorp/nomad
client/vaultclient/vaultclient.go
Push
func (h *vaultClientHeap) Push(req *vaultClientRenewalRequest, next time.Time) error { if req == nil { return fmt.Errorf("nil request") } if _, ok := h.heapMap[req.id]; ok { return fmt.Errorf("entry %v already exists", req.id) } heapEntry := &vaultClientHeapEntry{ req: req, next: next, } h.heapMap[req...
go
func (h *vaultClientHeap) Push(req *vaultClientRenewalRequest, next time.Time) error { if req == nil { return fmt.Errorf("nil request") } if _, ok := h.heapMap[req.id]; ok { return fmt.Errorf("entry %v already exists", req.id) } heapEntry := &vaultClientHeapEntry{ req: req, next: next, } h.heapMap[req...
[ "func", "(", "h", "*", "vaultClientHeap", ")", "Push", "(", "req", "*", "vaultClientRenewalRequest", ",", "next", "time", ".", "Time", ")", "error", "{", "if", "req", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", ...
// Push adds the secondary index and inserts an item into the heap
[ "Push", "adds", "the", "secondary", "index", "and", "inserts", "an", "item", "into", "the", "heap" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L629-L645
132,657
hashicorp/nomad
client/vaultclient/vaultclient.go
Update
func (h *vaultClientHeap) Update(req *vaultClientRenewalRequest, next time.Time) error { if entry, ok := h.heapMap[req.id]; ok { entry.req = req entry.next = next heap.Fix(&h.heap, entry.index) return nil } return fmt.Errorf("heap doesn't contain %v", req.id) }
go
func (h *vaultClientHeap) Update(req *vaultClientRenewalRequest, next time.Time) error { if entry, ok := h.heapMap[req.id]; ok { entry.req = req entry.next = next heap.Fix(&h.heap, entry.index) return nil } return fmt.Errorf("heap doesn't contain %v", req.id) }
[ "func", "(", "h", "*", "vaultClientHeap", ")", "Update", "(", "req", "*", "vaultClientRenewalRequest", ",", "next", "time", ".", "Time", ")", "error", "{", "if", "entry", ",", "ok", ":=", "h", ".", "heapMap", "[", "req", ".", "id", "]", ";", "ok", ...
// Update will modify the existing item in the heap with the new data and the // time, and fixes the heap.
[ "Update", "will", "modify", "the", "existing", "item", "in", "the", "heap", "with", "the", "new", "data", "and", "the", "time", "and", "fixes", "the", "heap", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L649-L658
132,658
hashicorp/nomad
client/vaultclient/vaultclient.go
Remove
func (h *vaultClientHeap) Remove(id string) error { if entry, ok := h.heapMap[id]; ok { heap.Remove(&h.heap, entry.index) delete(h.heapMap, id) return nil } return fmt.Errorf("heap doesn't contain entry for %v", id) }
go
func (h *vaultClientHeap) Remove(id string) error { if entry, ok := h.heapMap[id]; ok { heap.Remove(&h.heap, entry.index) delete(h.heapMap, id) return nil } return fmt.Errorf("heap doesn't contain entry for %v", id) }
[ "func", "(", "h", "*", "vaultClientHeap", ")", "Remove", "(", "id", "string", ")", "error", "{", "if", "entry", ",", "ok", ":=", "h", ".", "heapMap", "[", "id", "]", ";", "ok", "{", "heap", ".", "Remove", "(", "&", "h", ".", "heap", ",", "entry...
// Remove will remove an identifier from the secondary index and deletes the // corresponding node from the heap.
[ "Remove", "will", "remove", "an", "identifier", "from", "the", "secondary", "index", "and", "deletes", "the", "corresponding", "node", "from", "the", "heap", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L662-L670
132,659
hashicorp/nomad
client/vaultclient/vaultclient.go
renewalTime
func renewalTime(dice randIntn, leaseDuration int) time.Duration { // Start trying to renew at half the lease duration to allow ample time // for latency and retries. renew := leaseDuration / 2 // Don't bother about introducing randomness if the // leaseDuration is too small. const cutoff = 30 if renew < cutoff...
go
func renewalTime(dice randIntn, leaseDuration int) time.Duration { // Start trying to renew at half the lease duration to allow ample time // for latency and retries. renew := leaseDuration / 2 // Don't bother about introducing randomness if the // leaseDuration is too small. const cutoff = 30 if renew < cutoff...
[ "func", "renewalTime", "(", "dice", "randIntn", ",", "leaseDuration", "int", ")", "time", ".", "Duration", "{", "// Start trying to renew at half the lease duration to allow ample time", "// for latency and retries.", "renew", ":=", "leaseDuration", "/", "2", "\n\n", "// Do...
// renewalTime returns when a token should be renewed given its leaseDuration // and a randomizer to provide jitter. // // Leases < 1m will be not jitter.
[ "renewalTime", "returns", "when", "a", "token", "should", "be", "renewed", "given", "its", "leaseDuration", "and", "a", "randomizer", "to", "provide", "jitter", ".", "Leases", "<", "1m", "will", "be", "not", "jitter", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/vaultclient/vaultclient.go#L736-L754
132,660
hashicorp/nomad
client/fingerprint/storage_unix.go
diskFree
func (f *StorageFingerprint) diskFree(path string) (volume string, total, free uint64, err error) { absPath, err := filepath.Abs(path) if err != nil { return "", 0, 0, fmt.Errorf("failed to determine absolute path for %s", path) } // Use -k to standardize the output values between darwin and linux var dfArgs st...
go
func (f *StorageFingerprint) diskFree(path string) (volume string, total, free uint64, err error) { absPath, err := filepath.Abs(path) if err != nil { return "", 0, 0, fmt.Errorf("failed to determine absolute path for %s", path) } // Use -k to standardize the output values between darwin and linux var dfArgs st...
[ "func", "(", "f", "*", "StorageFingerprint", ")", "diskFree", "(", "path", "string", ")", "(", "volume", "string", ",", "total", ",", "free", "uint64", ",", "err", "error", ")", "{", "absPath", ",", "err", ":=", "filepath", ".", "Abs", "(", "path", "...
// diskFree inspects the filesystem for path and returns the volume name and // the total and free bytes available on the file system.
[ "diskFree", "inspects", "the", "filesystem", "for", "path", "and", "returns", "the", "volume", "name", "and", "the", "total", "and", "free", "bytes", "available", "on", "the", "file", "system", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/storage_unix.go#L16-L64
132,661
hashicorp/nomad
client/structs/broadcaster.go
Send
func (b *AllocBroadcaster) Send(v *structs.Allocation) error { b.mu.Lock() defer b.mu.Unlock() if b.closed { return ErrAllocBroadcasterClosed } b.logger.Trace("sending updated alloc", "client_status", v.ClientStatus, "desired_status", v.DesiredStatus, ) // Store last sent alloc for future listeners b.la...
go
func (b *AllocBroadcaster) Send(v *structs.Allocation) error { b.mu.Lock() defer b.mu.Unlock() if b.closed { return ErrAllocBroadcasterClosed } b.logger.Trace("sending updated alloc", "client_status", v.ClientStatus, "desired_status", v.DesiredStatus, ) // Store last sent alloc for future listeners b.la...
[ "func", "(", "b", "*", "AllocBroadcaster", ")", "Send", "(", "v", "*", "structs", ".", "Allocation", ")", "error", "{", "b", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "b", ".", "closed...
// Send broadcasts an allocation update. Any pending updates are replaced with // this version of the allocation to prevent blocking on slow receivers. // Returns ErrAllocBroadcasterClosed if called after broadcaster is closed.
[ "Send", "broadcasts", "an", "allocation", "update", ".", "Any", "pending", "updates", "are", "replaced", "with", "this", "version", "of", "the", "allocation", "to", "prevent", "blocking", "on", "slow", "receivers", ".", "Returns", "ErrAllocBroadcasterClosed", "if"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/structs/broadcaster.go#L54-L80
132,662
hashicorp/nomad
client/structs/broadcaster.go
Close
func (b *AllocBroadcaster) Close() { b.mu.Lock() defer b.mu.Unlock() if b.closed { return } // Close all listener chans for _, l := range b.listeners { close(l) } // Clear all references and mark broadcaster as closed b.listeners = nil b.closed = true }
go
func (b *AllocBroadcaster) Close() { b.mu.Lock() defer b.mu.Unlock() if b.closed { return } // Close all listener chans for _, l := range b.listeners { close(l) } // Clear all references and mark broadcaster as closed b.listeners = nil b.closed = true }
[ "func", "(", "b", "*", "AllocBroadcaster", ")", "Close", "(", ")", "{", "b", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "b", ".", "closed", "{", "return", "\n", "}", "\n\n", "// Close a...
// Close closes the channel, disabling the sending of further allocation // updates. Pending updates are still received by listeners. Safe to call // concurrently and more than once.
[ "Close", "closes", "the", "channel", "disabling", "the", "sending", "of", "further", "allocation", "updates", ".", "Pending", "updates", "are", "still", "received", "by", "listeners", ".", "Safe", "to", "call", "concurrently", "and", "more", "than", "once", "....
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/structs/broadcaster.go#L85-L100
132,663
hashicorp/nomad
client/structs/broadcaster.go
stop
func (b *AllocBroadcaster) stop(id int) { b.mu.Lock() defer b.mu.Unlock() // If broadcaster has been closed there's nothing more to do. if b.closed { return } l, ok := b.listeners[id] if !ok { // If this listener has been stopped already there's nothing // more to do. return } close(l) delete(b.lis...
go
func (b *AllocBroadcaster) stop(id int) { b.mu.Lock() defer b.mu.Unlock() // If broadcaster has been closed there's nothing more to do. if b.closed { return } l, ok := b.listeners[id] if !ok { // If this listener has been stopped already there's nothing // more to do. return } close(l) delete(b.lis...
[ "func", "(", "b", "*", "AllocBroadcaster", ")", "stop", "(", "id", "int", ")", "{", "b", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "// If broadcaster has been closed there's nothing more to do.", "if"...
// stop an individual listener
[ "stop", "an", "individual", "listener" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/structs/broadcaster.go#L103-L121
132,664
hashicorp/nomad
client/structs/broadcaster.go
Listen
func (b *AllocBroadcaster) Listen() *AllocListener { b.mu.Lock() defer b.mu.Unlock() if b.listeners == nil { b.listeners = make(map[int]chan *structs.Allocation) } for b.listeners[b.nextId] != nil { b.nextId++ } ch := make(chan *structs.Allocation, listenerCap) // Send last update if there was one if b....
go
func (b *AllocBroadcaster) Listen() *AllocListener { b.mu.Lock() defer b.mu.Unlock() if b.listeners == nil { b.listeners = make(map[int]chan *structs.Allocation) } for b.listeners[b.nextId] != nil { b.nextId++ } ch := make(chan *structs.Allocation, listenerCap) // Send last update if there was one if b....
[ "func", "(", "b", "*", "AllocBroadcaster", ")", "Listen", "(", ")", "*", "AllocListener", "{", "b", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "b", ".", "listeners", "==", "nil", "{", "...
// Listen returns a Listener for the broadcast channel. New listeners receive // the last sent alloc update.
[ "Listen", "returns", "a", "Listener", "for", "the", "broadcast", "channel", ".", "New", "listeners", "receive", "the", "last", "sent", "alloc", "update", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/structs/broadcaster.go#L125-L152
132,665
hashicorp/nomad
client/fingerprint/signal.go
NewSignalFingerprint
func NewSignalFingerprint(logger log.Logger) Fingerprint { f := &SignalFingerprint{logger: logger.Named("signals")} return f }
go
func NewSignalFingerprint(logger log.Logger) Fingerprint { f := &SignalFingerprint{logger: logger.Named("signals")} return f }
[ "func", "NewSignalFingerprint", "(", "logger", "log", ".", "Logger", ")", "Fingerprint", "{", "f", ":=", "&", "SignalFingerprint", "{", "logger", ":", "logger", ".", "Named", "(", "\"", "\"", ")", "}", "\n", "return", "f", "\n", "}" ]
// NewSignalFingerprint is used to create a Signal fingerprint
[ "NewSignalFingerprint", "is", "used", "to", "create", "a", "Signal", "fingerprint" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/signal.go#L17-L20
132,666
hashicorp/nomad
drivers/docker/docklog/docker_logger.go
NewDockerLogger
func NewDockerLogger(logger hclog.Logger) DockerLogger { return &dockerLogger{ logger: logger, doneCh: make(chan interface{}), } }
go
func NewDockerLogger(logger hclog.Logger) DockerLogger { return &dockerLogger{ logger: logger, doneCh: make(chan interface{}), } }
[ "func", "NewDockerLogger", "(", "logger", "hclog", ".", "Logger", ")", "DockerLogger", "{", "return", "&", "dockerLogger", "{", "logger", ":", "logger", ",", "doneCh", ":", "make", "(", "chan", "interface", "{", "}", ")", ",", "}", "\n", "}" ]
// NewDockerLogger returns an implementation of the DockerLogger interface
[ "NewDockerLogger", "returns", "an", "implementation", "of", "the", "DockerLogger", "interface" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/docker_logger.go#L50-L55
132,667
hashicorp/nomad
drivers/docker/docklog/docker_logger.go
Start
func (d *dockerLogger) Start(opts *StartOpts) error { client, err := d.getDockerClient(opts) if err != nil { return fmt.Errorf("failed to open docker client: %v", err) } ctx, cancel := context.WithCancel(context.Background()) d.cancelCtx = cancel go func() { defer close(d.doneCh) stdout, stderr, err := d...
go
func (d *dockerLogger) Start(opts *StartOpts) error { client, err := d.getDockerClient(opts) if err != nil { return fmt.Errorf("failed to open docker client: %v", err) } ctx, cancel := context.WithCancel(context.Background()) d.cancelCtx = cancel go func() { defer close(d.doneCh) stdout, stderr, err := d...
[ "func", "(", "d", "*", "dockerLogger", ")", "Start", "(", "opts", "*", "StartOpts", ")", "error", "{", "client", ",", "err", ":=", "d", ".", "getDockerClient", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "...
// Start log monitoring
[ "Start", "log", "monitoring" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/docker_logger.go#L70-L135
132,668
hashicorp/nomad
drivers/docker/docklog/docker_logger.go
Stop
func (d *dockerLogger) Stop() error { if d.cancelCtx != nil { d.cancelCtx() } d.stdLock.Lock() stdout, stderr := d.stdout, d.stderr d.stdLock.Unlock() if stdout != nil { stdout.Close() } if stderr != nil { stderr.Close() } return nil }
go
func (d *dockerLogger) Stop() error { if d.cancelCtx != nil { d.cancelCtx() } d.stdLock.Lock() stdout, stderr := d.stdout, d.stderr d.stdLock.Unlock() if stdout != nil { stdout.Close() } if stderr != nil { stderr.Close() } return nil }
[ "func", "(", "d", "*", "dockerLogger", ")", "Stop", "(", ")", "error", "{", "if", "d", ".", "cancelCtx", "!=", "nil", "{", "d", ".", "cancelCtx", "(", ")", "\n", "}", "\n\n", "d", ".", "stdLock", ".", "Lock", "(", ")", "\n", "stdout", ",", "std...
// Stop log monitoring
[ "Stop", "log", "monitoring" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/docker_logger.go#L181-L197
132,669
hashicorp/nomad
drivers/docker/docklog/docker_logger.go
nextBackoff
func nextBackoff(backoff float64) float64 { if backoff < 0.5 { backoff = 0.5 } backoff = backoff * 1.15 * (1.0 + rand.Float64()) if backoff > 120 { backoff = 120 } else if backoff < 0.5 { backoff = 0.5 } return backoff }
go
func nextBackoff(backoff float64) float64 { if backoff < 0.5 { backoff = 0.5 } backoff = backoff * 1.15 * (1.0 + rand.Float64()) if backoff > 120 { backoff = 120 } else if backoff < 0.5 { backoff = 0.5 } return backoff }
[ "func", "nextBackoff", "(", "backoff", "float64", ")", "float64", "{", "if", "backoff", "<", "0.5", "{", "backoff", "=", "0.5", "\n", "}", "\n\n", "backoff", "=", "backoff", "*", "1.15", "*", "(", "1.0", "+", "rand", ".", "Float64", "(", ")", ")", ...
// nextBackoff returns the next backoff period in seconds given current backoff
[ "nextBackoff", "returns", "the", "next", "backoff", "period", "in", "seconds", "given", "current", "backoff" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/docker_logger.go#L260-L273
132,670
hashicorp/nomad
drivers/docker/docklog/server.go
Start
func (s *dockerLoggerServer) Start(ctx context.Context, req *proto.StartRequest) (*proto.StartResponse, error) { opts := &StartOpts{ Endpoint: req.Endpoint, ContainerID: req.ContainerId, Stdout: req.StdoutFifo, Stderr: req.StderrFifo, TTY: req.Tty, TLSCert: req.TlsCert, TLSKey: req...
go
func (s *dockerLoggerServer) Start(ctx context.Context, req *proto.StartRequest) (*proto.StartResponse, error) { opts := &StartOpts{ Endpoint: req.Endpoint, ContainerID: req.ContainerId, Stdout: req.StdoutFifo, Stderr: req.StderrFifo, TTY: req.Tty, TLSCert: req.TlsCert, TLSKey: req...
[ "func", "(", "s", "*", "dockerLoggerServer", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "req", "*", "proto", ".", "StartRequest", ")", "(", "*", "proto", ".", "StartResponse", ",", "error", ")", "{", "opts", ":=", "&", "StartOpts", "{", ...
// Start proxies the protobuf Start RPC to the Start fun of the DockerLogger interface
[ "Start", "proxies", "the", "protobuf", "Start", "RPC", "to", "the", "Start", "fun", "of", "the", "DockerLogger", "interface" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/server.go#L17-L35
132,671
hashicorp/nomad
drivers/docker/docklog/server.go
Stop
func (s *dockerLoggerServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) { return &proto.StopResponse{}, s.impl.Stop() }
go
func (s *dockerLoggerServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) { return &proto.StopResponse{}, s.impl.Stop() }
[ "func", "(", "s", "*", "dockerLoggerServer", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "req", "*", "proto", ".", "StopRequest", ")", "(", "*", "proto", ".", "StopResponse", ",", "error", ")", "{", "return", "&", "proto", ".", "StopRespon...
// Stop proxies the protobuf Stop RPC to the Stop fun of the DockerLogger interface
[ "Stop", "proxies", "the", "protobuf", "Stop", "RPC", "to", "the", "Stop", "fun", "of", "the", "DockerLogger", "interface" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/docklog/server.go#L38-L40
132,672
hashicorp/nomad
nomad/structs/batch_future.go
Respond
func (b *BatchFuture) Respond(index uint64, err error) { b.index = index b.err = err close(b.doneCh) }
go
func (b *BatchFuture) Respond(index uint64, err error) { b.index = index b.err = err close(b.doneCh) }
[ "func", "(", "b", "*", "BatchFuture", ")", "Respond", "(", "index", "uint64", ",", "err", "error", ")", "{", "b", ".", "index", "=", "index", "\n", "b", ".", "err", "=", "err", "\n", "close", "(", "b", ".", "doneCh", ")", "\n", "}" ]
// Respond is used to unblock the future
[ "Respond", "is", "used", "to", "unblock", "the", "future" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/batch_future.go#L39-L43
132,673
hashicorp/nomad
client/fingerprint/network.go
NewNetworkFingerprint
func NewNetworkFingerprint(logger log.Logger) Fingerprint { f := &NetworkFingerprint{logger: logger.Named("network"), interfaceDetector: &DefaultNetworkInterfaceDetector{}} return f }
go
func NewNetworkFingerprint(logger log.Logger) Fingerprint { f := &NetworkFingerprint{logger: logger.Named("network"), interfaceDetector: &DefaultNetworkInterfaceDetector{}} return f }
[ "func", "NewNetworkFingerprint", "(", "logger", "log", ".", "Logger", ")", "Fingerprint", "{", "f", ":=", "&", "NetworkFingerprint", "{", "logger", ":", "logger", ".", "Named", "(", "\"", "\"", ")", ",", "interfaceDetector", ":", "&", "DefaultNetworkInterfaceD...
// NewNetworkFingerprint returns a new NetworkFingerprinter with the given // logger
[ "NewNetworkFingerprint", "returns", "a", "new", "NetworkFingerprinter", "with", "the", "given", "logger" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/network.go#L58-L61
132,674
hashicorp/nomad
client/fingerprint/network.go
createNetworkResources
func (f *NetworkFingerprint) createNetworkResources(throughput int, intf *net.Interface, disallowLinkLocal bool) ([]*structs.NetworkResource, error) { // Find the interface with the name addrs, err := f.interfaceDetector.Addrs(intf) if err != nil { return nil, err } nwResources := make([]*structs.NetworkResourc...
go
func (f *NetworkFingerprint) createNetworkResources(throughput int, intf *net.Interface, disallowLinkLocal bool) ([]*structs.NetworkResource, error) { // Find the interface with the name addrs, err := f.interfaceDetector.Addrs(intf) if err != nil { return nil, err } nwResources := make([]*structs.NetworkResourc...
[ "func", "(", "f", "*", "NetworkFingerprint", ")", "createNetworkResources", "(", "throughput", "int", ",", "intf", "*", "net", ".", "Interface", ",", "disallowLinkLocal", "bool", ")", "(", "[", "]", "*", "structs", ".", "NetworkResource", ",", "error", ")", ...
// createNetworkResources creates network resources for every IP
[ "createNetworkResources", "creates", "network", "resources", "for", "every", "IP" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/network.go#L122-L175
132,675
hashicorp/nomad
client/fingerprint/network.go
findInterface
func (f *NetworkFingerprint) findInterface(deviceName string) (*net.Interface, error) { // If we aren't given a device, look it up by using the interface with the default route if deviceName == "" { ri, err := sockaddr.NewRouteInfo() if err != nil { return nil, err } defaultIfName, err := ri.GetDefaultInt...
go
func (f *NetworkFingerprint) findInterface(deviceName string) (*net.Interface, error) { // If we aren't given a device, look it up by using the interface with the default route if deviceName == "" { ri, err := sockaddr.NewRouteInfo() if err != nil { return nil, err } defaultIfName, err := ri.GetDefaultInt...
[ "func", "(", "f", "*", "NetworkFingerprint", ")", "findInterface", "(", "deviceName", "string", ")", "(", "*", "net", ".", "Interface", ",", "error", ")", "{", "// If we aren't given a device, look it up by using the interface with the default route", "if", "deviceName", ...
// Returns the interface with the name passed by user. If the name is blank, we // use the interface attached to the default route.
[ "Returns", "the", "interface", "with", "the", "name", "passed", "by", "user", ".", "If", "the", "name", "is", "blank", "we", "use", "the", "interface", "attached", "to", "the", "default", "route", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/fingerprint/network.go#L179-L198
132,676
hashicorp/nomad
helper/flatmap/flatmap.go
Flatten
func Flatten(obj interface{}, filter []string, primitiveOnly bool) map[string]string { flat := make(map[string]string) v := reflect.ValueOf(obj) if !v.IsValid() { return nil } flatten("", v, primitiveOnly, false, flat) for _, f := range filter { if _, ok := flat[f]; ok { delete(flat, f) } } return fla...
go
func Flatten(obj interface{}, filter []string, primitiveOnly bool) map[string]string { flat := make(map[string]string) v := reflect.ValueOf(obj) if !v.IsValid() { return nil } flatten("", v, primitiveOnly, false, flat) for _, f := range filter { if _, ok := flat[f]; ok { delete(flat, f) } } return fla...
[ "func", "Flatten", "(", "obj", "interface", "{", "}", ",", "filter", "[", "]", "string", ",", "primitiveOnly", "bool", ")", "map", "[", "string", "]", "string", "{", "flat", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "v", ":...
// Flatten takes an object and returns a flat map of the object. The keys of the // map is the path of the field names until a primitive field is reached and the // value is a string representation of the terminal field.
[ "Flatten", "takes", "an", "object", "and", "returns", "a", "flat", "map", "of", "the", "object", ".", "The", "keys", "of", "the", "map", "is", "the", "path", "of", "the", "field", "names", "until", "a", "primitive", "field", "is", "reached", "and", "th...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/flatmap/flatmap.go#L11-L25
132,677
hashicorp/nomad
helper/flatmap/flatmap.go
getSubPrefix
func getSubPrefix(curPrefix, subField string) string { if curPrefix != "" { return fmt.Sprintf("%s.%s", curPrefix, subField) } return fmt.Sprintf("%s", subField) }
go
func getSubPrefix(curPrefix, subField string) string { if curPrefix != "" { return fmt.Sprintf("%s.%s", curPrefix, subField) } return fmt.Sprintf("%s", subField) }
[ "func", "getSubPrefix", "(", "curPrefix", ",", "subField", "string", ")", "string", "{", "if", "curPrefix", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "curPrefix", ",", "subField", ")", "\n", "}", "\n", "return", "fmt...
// getSubPrefix takes the current prefix and the next subfield and returns an // appropriate prefix.
[ "getSubPrefix", "takes", "the", "current", "prefix", "and", "the", "next", "subfield", "and", "returns", "an", "appropriate", "prefix", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/flatmap/flatmap.go#L115-L120
132,678
hashicorp/nomad
helper/flatmap/flatmap.go
getSubKeyPrefix
func getSubKeyPrefix(curPrefix, subField string) string { if curPrefix != "" { return fmt.Sprintf("%s[%s]", curPrefix, subField) } return fmt.Sprintf("%s", subField) }
go
func getSubKeyPrefix(curPrefix, subField string) string { if curPrefix != "" { return fmt.Sprintf("%s[%s]", curPrefix, subField) } return fmt.Sprintf("%s", subField) }
[ "func", "getSubKeyPrefix", "(", "curPrefix", ",", "subField", "string", ")", "string", "{", "if", "curPrefix", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "curPrefix", ",", "subField", ")", "\n", "}", "\n", "return", "...
// getSubKeyPrefix takes the current prefix and the next subfield and returns an // appropriate prefix for a map field.
[ "getSubKeyPrefix", "takes", "the", "current", "prefix", "and", "the", "next", "subfield", "and", "returns", "an", "appropriate", "prefix", "for", "a", "map", "field", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/flatmap/flatmap.go#L124-L129
132,679
hashicorp/nomad
scheduler/select.go
NewLimitIterator
func NewLimitIterator(ctx Context, source RankIterator, limit int, scoreThreshold float64, maxSkip int) *LimitIterator { iter := &LimitIterator{ ctx: ctx, source: source, limit: limit, maxSkip: maxSkip, scoreThreshold: scoreThreshold, skippedNodes: make([]*RankedNode, 0...
go
func NewLimitIterator(ctx Context, source RankIterator, limit int, scoreThreshold float64, maxSkip int) *LimitIterator { iter := &LimitIterator{ ctx: ctx, source: source, limit: limit, maxSkip: maxSkip, scoreThreshold: scoreThreshold, skippedNodes: make([]*RankedNode, 0...
[ "func", "NewLimitIterator", "(", "ctx", "Context", ",", "source", "RankIterator", ",", "limit", "int", ",", "scoreThreshold", "float64", ",", "maxSkip", "int", ")", "*", "LimitIterator", "{", "iter", ":=", "&", "LimitIterator", "{", "ctx", ":", "ctx", ",", ...
// NewLimitIterator returns a LimitIterator with a fixed limit of returned options. // Up to maxSkip options whose score is below scoreThreshold are skipped // if there are additional options available in the source iterator
[ "NewLimitIterator", "returns", "a", "LimitIterator", "with", "a", "fixed", "limit", "of", "returned", "options", ".", "Up", "to", "maxSkip", "options", "whose", "score", "is", "below", "scoreThreshold", "are", "skipped", "if", "there", "are", "additional", "opti...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/select.go#L19-L29
132,680
hashicorp/nomad
scheduler/select.go
nextOption
func (iter *LimitIterator) nextOption() *RankedNode { sourceOption := iter.source.Next() if sourceOption == nil && iter.skippedNodeIndex < len(iter.skippedNodes) { skippedOption := iter.skippedNodes[iter.skippedNodeIndex] iter.skippedNodeIndex += 1 return skippedOption } return sourceOption }
go
func (iter *LimitIterator) nextOption() *RankedNode { sourceOption := iter.source.Next() if sourceOption == nil && iter.skippedNodeIndex < len(iter.skippedNodes) { skippedOption := iter.skippedNodes[iter.skippedNodeIndex] iter.skippedNodeIndex += 1 return skippedOption } return sourceOption }
[ "func", "(", "iter", "*", "LimitIterator", ")", "nextOption", "(", ")", "*", "RankedNode", "{", "sourceOption", ":=", "iter", ".", "source", ".", "Next", "(", ")", "\n", "if", "sourceOption", "==", "nil", "&&", "iter", ".", "skippedNodeIndex", "<", "len"...
// nextOption uses the iterator's list of skipped nodes if the source iterator is exhausted
[ "nextOption", "uses", "the", "iterator", "s", "list", "of", "skipped", "nodes", "if", "the", "source", "iterator", "is", "exhausted" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/select.go#L59-L67
132,681
hashicorp/nomad
scheduler/select.go
NewMaxScoreIterator
func NewMaxScoreIterator(ctx Context, source RankIterator) *MaxScoreIterator { iter := &MaxScoreIterator{ ctx: ctx, source: source, } return iter }
go
func NewMaxScoreIterator(ctx Context, source RankIterator) *MaxScoreIterator { iter := &MaxScoreIterator{ ctx: ctx, source: source, } return iter }
[ "func", "NewMaxScoreIterator", "(", "ctx", "Context", ",", "source", "RankIterator", ")", "*", "MaxScoreIterator", "{", "iter", ":=", "&", "MaxScoreIterator", "{", "ctx", ":", "ctx", ",", "source", ":", "source", ",", "}", "\n", "return", "iter", "\n", "}"...
// MaxScoreIterator returns a MaxScoreIterator over the given source
[ "MaxScoreIterator", "returns", "a", "MaxScoreIterator", "over", "the", "given", "source" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/select.go#L86-L92
132,682
hashicorp/nomad
api/constraint.go
NewConstraint
func NewConstraint(left, operand, right string) *Constraint { return &Constraint{ LTarget: left, RTarget: right, Operand: operand, } }
go
func NewConstraint(left, operand, right string) *Constraint { return &Constraint{ LTarget: left, RTarget: right, Operand: operand, } }
[ "func", "NewConstraint", "(", "left", ",", "operand", ",", "right", "string", ")", "*", "Constraint", "{", "return", "&", "Constraint", "{", "LTarget", ":", "left", ",", "RTarget", ":", "right", ",", "Operand", ":", "operand", ",", "}", "\n", "}" ]
// NewConstraint generates a new job placement constraint.
[ "NewConstraint", "generates", "a", "new", "job", "placement", "constraint", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/constraint.go#L11-L17
132,683
hashicorp/nomad
plugins/device/client.go
handleFingerprint
func (d *devicePluginClient) handleFingerprint( reqCtx context.Context, stream proto.DevicePlugin_FingerprintClient, out chan *FingerprintResponse) { defer close(out) for { resp, err := stream.Recv() if err != nil { if err != io.EOF { out <- &FingerprintResponse{ Error: grpcutils.HandleReqCtxGrpcE...
go
func (d *devicePluginClient) handleFingerprint( reqCtx context.Context, stream proto.DevicePlugin_FingerprintClient, out chan *FingerprintResponse) { defer close(out) for { resp, err := stream.Recv() if err != nil { if err != io.EOF { out <- &FingerprintResponse{ Error: grpcutils.HandleReqCtxGrpcE...
[ "func", "(", "d", "*", "devicePluginClient", ")", "handleFingerprint", "(", "reqCtx", "context", ".", "Context", ",", "stream", "proto", ".", "DevicePlugin_FingerprintClient", ",", "out", "chan", "*", "FingerprintResponse", ")", "{", "defer", "close", "(", "out"...
// handleFingerprint should be launched in a goroutine and handles converting // the gRPC stream to a channel. Exits either when context is cancelled or the // stream has an error.
[ "handleFingerprint", "should", "be", "launched", "in", "a", "goroutine", "and", "handles", "converting", "the", "gRPC", "stream", "to", "a", "channel", ".", "Exits", "either", "when", "context", "is", "cancelled", "or", "the", "stream", "has", "an", "error", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/client.go#L49-L78
132,684
hashicorp/nomad
plugins/device/client.go
Stats
func (d *devicePluginClient) Stats(ctx context.Context, interval time.Duration) (<-chan *StatsResponse, error) { // Join the passed context and the shutdown context joinedCtx, _ := joincontext.Join(ctx, d.doneCtx) req := proto.StatsRequest{ CollectionInterval: ptypes.DurationProto(interval), } stream, err := d....
go
func (d *devicePluginClient) Stats(ctx context.Context, interval time.Duration) (<-chan *StatsResponse, error) { // Join the passed context and the shutdown context joinedCtx, _ := joincontext.Join(ctx, d.doneCtx) req := proto.StatsRequest{ CollectionInterval: ptypes.DurationProto(interval), } stream, err := d....
[ "func", "(", "d", "*", "devicePluginClient", ")", "Stats", "(", "ctx", "context", ".", "Context", ",", "interval", "time", ".", "Duration", ")", "(", "<-", "chan", "*", "StatsResponse", ",", "error", ")", "{", "// Join the passed context and the shutdown context...
// Stats is used to retrieve device statistics from the device plugin. An error // may be immediately returned if the stats call could not be made or as part of // the streaming response. If the context is cancelled, the error will be // propagated.
[ "Stats", "is", "used", "to", "retrieve", "device", "statistics", "from", "the", "device", "plugin", ".", "An", "error", "may", "be", "immediately", "returned", "if", "the", "stats", "call", "could", "not", "be", "made", "or", "as", "part", "of", "the", "...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/client.go#L101-L116
132,685
hashicorp/nomad
plugins/device/client.go
handleStats
func (d *devicePluginClient) handleStats( reqCtx context.Context, stream proto.DevicePlugin_StatsClient, out chan *StatsResponse) { defer close(out) for { resp, err := stream.Recv() if err != nil { if err != io.EOF { out <- &StatsResponse{ Error: grpcutils.HandleReqCtxGrpcErr(err, reqCtx, d.doneCt...
go
func (d *devicePluginClient) handleStats( reqCtx context.Context, stream proto.DevicePlugin_StatsClient, out chan *StatsResponse) { defer close(out) for { resp, err := stream.Recv() if err != nil { if err != io.EOF { out <- &StatsResponse{ Error: grpcutils.HandleReqCtxGrpcErr(err, reqCtx, d.doneCt...
[ "func", "(", "d", "*", "devicePluginClient", ")", "handleStats", "(", "reqCtx", "context", ".", "Context", ",", "stream", "proto", ".", "DevicePlugin_StatsClient", ",", "out", "chan", "*", "StatsResponse", ")", "{", "defer", "close", "(", "out", ")", "\n", ...
// handleStats should be launched in a goroutine and handles converting // the gRPC stream to a channel. Exits either when context is cancelled or the // stream has an error.
[ "handleStats", "should", "be", "launched", "in", "a", "goroutine", "and", "handles", "converting", "the", "gRPC", "stream", "to", "a", "channel", ".", "Exits", "either", "when", "context", "is", "cancelled", "or", "the", "stream", "has", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/client.go#L121-L150
132,686
hashicorp/nomad
drivers/docker/handle.go
Kill
func (h *taskHandle) Kill(killTimeout time.Duration, signal os.Signal) error { // Only send signal if killTimeout is set, otherwise stop container if killTimeout > 0 { if err := h.Signal(signal); err != nil { // Container has already been removed. if strings.Contains(err.Error(), NoSuchContainerError) { h...
go
func (h *taskHandle) Kill(killTimeout time.Duration, signal os.Signal) error { // Only send signal if killTimeout is set, otherwise stop container if killTimeout > 0 { if err := h.Signal(signal); err != nil { // Container has already been removed. if strings.Contains(err.Error(), NoSuchContainerError) { h...
[ "func", "(", "h", "*", "taskHandle", ")", "Kill", "(", "killTimeout", "time", ".", "Duration", ",", "signal", "os", ".", "Signal", ")", "error", "{", "// Only send signal if killTimeout is set, otherwise stop container", "if", "killTimeout", ">", "0", "{", "if", ...
// Kill is used to terminate the task.
[ "Kill", "is", "used", "to", "terminate", "the", "task", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/handle.go#L124-L171
132,687
hashicorp/nomad
e2e/nomad09upgrade/upgrade.go
BeforeAll
func (tc *UpgradePathTC) BeforeAll(f *framework.F) { // Upgrade tests currently fail because the nomad binary isn't found by // discover.NomadExecutable(). Ensure that nomad binary is available // and discoverable and enable this test f.T().Skip("upgrade tests are expected to fail. TODO: Fix") bin, err := disco...
go
func (tc *UpgradePathTC) BeforeAll(f *framework.F) { // Upgrade tests currently fail because the nomad binary isn't found by // discover.NomadExecutable(). Ensure that nomad binary is available // and discoverable and enable this test f.T().Skip("upgrade tests are expected to fail. TODO: Fix") bin, err := disco...
[ "func", "(", "tc", "*", "UpgradePathTC", ")", "BeforeAll", "(", "f", "*", "framework", ".", "F", ")", "{", "// Upgrade tests currently fail because the nomad binary isn't found by", "// discover.NomadExecutable(). Ensure that nomad binary is available", "// and discoverable and en...
// BeforeAll downloads all of the desired nomad versions to test against
[ "BeforeAll", "downloads", "all", "of", "the", "desired", "nomad", "versions", "to", "test", "against" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/nomad09upgrade/upgrade.go#L87-L110
132,688
hashicorp/nomad
e2e/nomad09upgrade/upgrade.go
AfterAll
func (tc *UpgradePathTC) AfterAll(f *framework.F) { os.RemoveAll(tc.binDir) }
go
func (tc *UpgradePathTC) AfterAll(f *framework.F) { os.RemoveAll(tc.binDir) }
[ "func", "(", "tc", "*", "UpgradePathTC", ")", "AfterAll", "(", "f", "*", "framework", ".", "F", ")", "{", "os", ".", "RemoveAll", "(", "tc", ".", "binDir", ")", "\n", "}" ]
// AfterAll cleans up the downloaded nomad binaries
[ "AfterAll", "cleans", "up", "the", "downloaded", "nomad", "binaries" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/nomad09upgrade/upgrade.go#L113-L115
132,689
hashicorp/nomad
drivers/shared/executor/executor_linux.go
init
func init() { last := capability.CAP_LAST_CAP // workaround for RHEL6 which has no /proc/sys/kernel/cap_last_cap if last == capability.Cap(63) { last = capability.CAP_BLOCK_SUSPEND } for _, cap := range capability.List() { if cap > last { continue } allCaps = append(allCaps, fmt.Sprintf("CAP_%s", string...
go
func init() { last := capability.CAP_LAST_CAP // workaround for RHEL6 which has no /proc/sys/kernel/cap_last_cap if last == capability.Cap(63) { last = capability.CAP_BLOCK_SUSPEND } for _, cap := range capability.List() { if cap > last { continue } allCaps = append(allCaps, fmt.Sprintf("CAP_%s", string...
[ "func", "init", "(", ")", "{", "last", ":=", "capability", ".", "CAP_LAST_CAP", "\n", "// workaround for RHEL6 which has no /proc/sys/kernel/cap_last_cap", "if", "last", "==", "capability", ".", "Cap", "(", "63", ")", "{", "last", "=", "capability", ".", "CAP_BLOC...
// initialize the allCaps var with all capabilities available on the system
[ "initialize", "the", "allCaps", "var", "with", "all", "capabilities", "available", "on", "the", "system" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L51-L63
132,690
hashicorp/nomad
drivers/shared/executor/executor_linux.go
Stats
func (l *LibcontainerExecutor) Stats(ctx context.Context, interval time.Duration) (<-chan *cstructs.TaskResourceUsage, error) { ch := make(chan *cstructs.TaskResourceUsage) go l.handleStats(ch, ctx, interval) return ch, nil }
go
func (l *LibcontainerExecutor) Stats(ctx context.Context, interval time.Duration) (<-chan *cstructs.TaskResourceUsage, error) { ch := make(chan *cstructs.TaskResourceUsage) go l.handleStats(ch, ctx, interval) return ch, nil }
[ "func", "(", "l", "*", "LibcontainerExecutor", ")", "Stats", "(", "ctx", "context", ".", "Context", ",", "interval", "time", ".", "Duration", ")", "(", "<-", "chan", "*", "cstructs", ".", "TaskResourceUsage", ",", "error", ")", "{", "ch", ":=", "make", ...
// Stats returns the resource statistics for processes managed by the executor
[ "Stats", "returns", "the", "resource", "statistics", "for", "processes", "managed", "by", "the", "executor" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L374-L379
132,691
hashicorp/nomad
drivers/shared/executor/executor_linux.go
Signal
func (l *LibcontainerExecutor) Signal(s os.Signal) error { return l.userProc.Signal(s) }
go
func (l *LibcontainerExecutor) Signal(s os.Signal) error { return l.userProc.Signal(s) }
[ "func", "(", "l", "*", "LibcontainerExecutor", ")", "Signal", "(", "s", "os", ".", "Signal", ")", "error", "{", "return", "l", ".", "userProc", ".", "Signal", "(", "s", ")", "\n", "}" ]
// Signal sends a signal to the process managed by the executor
[ "Signal", "sends", "a", "signal", "to", "the", "process", "managed", "by", "the", "executor" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L458-L460
132,692
hashicorp/nomad
drivers/shared/executor/executor_linux.go
Exec
func (l *LibcontainerExecutor) Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) { combined := append([]string{cmd}, args...) // Capture output buf, _ := circbuf.NewBuffer(int64(drivers.CheckBufSize)) process := &libcontainer.Process{ Args: combined, Env: l.command.Env, Stdout: bu...
go
func (l *LibcontainerExecutor) Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) { combined := append([]string{cmd}, args...) // Capture output buf, _ := circbuf.NewBuffer(int64(drivers.CheckBufSize)) process := &libcontainer.Process{ Args: combined, Env: l.command.Env, Stdout: bu...
[ "func", "(", "l", "*", "LibcontainerExecutor", ")", "Exec", "(", "deadline", "time", ".", "Time", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "(", "[", "]", "byte", ",", "int", ",", "error", ")", "{", "combined", ":=", "append", "("...
// Exec starts an additional process inside the container
[ "Exec", "starts", "an", "additional", "process", "inside", "the", "container" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L463-L505
132,693
hashicorp/nomad
drivers/shared/executor/executor_linux.go
JoinRootCgroup
func JoinRootCgroup(subsystems []string) error { mErrs := new(multierror.Error) paths := map[string]string{} for _, s := range subsystems { mnt, _, err := cgroups.FindCgroupMountpointAndRoot("", s) if err != nil { multierror.Append(mErrs, fmt.Errorf("error getting cgroup path for subsystem: %s", s)) contin...
go
func JoinRootCgroup(subsystems []string) error { mErrs := new(multierror.Error) paths := map[string]string{} for _, s := range subsystems { mnt, _, err := cgroups.FindCgroupMountpointAndRoot("", s) if err != nil { multierror.Append(mErrs, fmt.Errorf("error getting cgroup path for subsystem: %s", s)) contin...
[ "func", "JoinRootCgroup", "(", "subsystems", "[", "]", "string", ")", "error", "{", "mErrs", ":=", "new", "(", "multierror", ".", "Error", ")", "\n", "paths", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "for", "_", ",", "s", ":=", "r...
// JoinRootCgroup moves the current process to the cgroups of the init process
[ "JoinRootCgroup", "moves", "the", "current", "process", "to", "the", "cgroups", "of", "the", "init", "process" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L706-L725
132,694
hashicorp/nomad
drivers/shared/executor/executor_linux.go
cmdDevices
func cmdDevices(devices []*drivers.DeviceConfig) ([]*lconfigs.Device, error) { if len(devices) == 0 { return nil, nil } r := make([]*lconfigs.Device, len(devices)) for i, d := range devices { ed, err := ldevices.DeviceFromPath(d.HostPath, d.Permissions) if err != nil { return nil, fmt.Errorf("failed to m...
go
func cmdDevices(devices []*drivers.DeviceConfig) ([]*lconfigs.Device, error) { if len(devices) == 0 { return nil, nil } r := make([]*lconfigs.Device, len(devices)) for i, d := range devices { ed, err := ldevices.DeviceFromPath(d.HostPath, d.Permissions) if err != nil { return nil, fmt.Errorf("failed to m...
[ "func", "cmdDevices", "(", "devices", "[", "]", "*", "drivers", ".", "DeviceConfig", ")", "(", "[", "]", "*", "lconfigs", ".", "Device", ",", "error", ")", "{", "if", "len", "(", "devices", ")", "==", "0", "{", "return", "nil", ",", "nil", "\n", ...
// cmdDevices converts a list of driver.DeviceConfigs into excutor.Devices.
[ "cmdDevices", "converts", "a", "list", "of", "driver", ".", "DeviceConfigs", "into", "excutor", ".", "Devices", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L728-L745
132,695
hashicorp/nomad
drivers/shared/executor/executor_linux.go
cmdMounts
func cmdMounts(mounts []*drivers.MountConfig) []*lconfigs.Mount { if len(mounts) == 0 { return nil } r := make([]*lconfigs.Mount, len(mounts)) for i, m := range mounts { flags := unix.MS_BIND if m.Readonly { flags |= unix.MS_RDONLY } r[i] = &lconfigs.Mount{ Source: m.HostPath, Destination:...
go
func cmdMounts(mounts []*drivers.MountConfig) []*lconfigs.Mount { if len(mounts) == 0 { return nil } r := make([]*lconfigs.Mount, len(mounts)) for i, m := range mounts { flags := unix.MS_BIND if m.Readonly { flags |= unix.MS_RDONLY } r[i] = &lconfigs.Mount{ Source: m.HostPath, Destination:...
[ "func", "cmdMounts", "(", "mounts", "[", "]", "*", "drivers", ".", "MountConfig", ")", "[", "]", "*", "lconfigs", ".", "Mount", "{", "if", "len", "(", "mounts", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "r", ":=", "make", "(", "[",...
// cmdMounts converts a list of driver.MountConfigs into excutor.Mounts.
[ "cmdMounts", "converts", "a", "list", "of", "driver", ".", "MountConfigs", "into", "excutor", ".", "Mounts", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/executor_linux.go#L748-L769
132,696
hashicorp/nomad
api/tasks.go
Canonicalize
func (c *CheckRestart) Canonicalize() { if c == nil { return } if c.Grace == nil { c.Grace = timeToPtr(1 * time.Second) } }
go
func (c *CheckRestart) Canonicalize() { if c == nil { return } if c.Grace == nil { c.Grace = timeToPtr(1 * time.Second) } }
[ "func", "(", "c", "*", "CheckRestart", ")", "Canonicalize", "(", ")", "{", "if", "c", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "c", ".", "Grace", "==", "nil", "{", "c", ".", "Grace", "=", "timeToPtr", "(", "1", "*", "time", ".", "Se...
// Canonicalize CheckRestart fields if not nil.
[ "Canonicalize", "CheckRestart", "fields", "if", "not", "nil", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L286-L294
132,697
hashicorp/nomad
api/tasks.go
Copy
func (c *CheckRestart) Copy() *CheckRestart { if c == nil { return nil } nc := new(CheckRestart) nc.Limit = c.Limit if c.Grace != nil { g := *c.Grace nc.Grace = &g } nc.IgnoreWarnings = c.IgnoreWarnings return nc }
go
func (c *CheckRestart) Copy() *CheckRestart { if c == nil { return nil } nc := new(CheckRestart) nc.Limit = c.Limit if c.Grace != nil { g := *c.Grace nc.Grace = &g } nc.IgnoreWarnings = c.IgnoreWarnings return nc }
[ "func", "(", "c", "*", "CheckRestart", ")", "Copy", "(", ")", "*", "CheckRestart", "{", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "nc", ":=", "new", "(", "CheckRestart", ")", "\n", "nc", ".", "Limit", "=", "c", ".", "Limit"...
// Copy returns a copy of CheckRestart or nil if unset.
[ "Copy", "returns", "a", "copy", "of", "CheckRestart", "or", "nil", "if", "unset", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L297-L310
132,698
hashicorp/nomad
api/tasks.go
Merge
func (c *CheckRestart) Merge(o *CheckRestart) *CheckRestart { if c == nil { // Just return other return o } nc := c.Copy() if o == nil { // Nothing to merge return nc } if o.Limit > 0 { nc.Limit = o.Limit } if o.Grace != nil { nc.Grace = o.Grace } if o.IgnoreWarnings { nc.IgnoreWarnings = o...
go
func (c *CheckRestart) Merge(o *CheckRestart) *CheckRestart { if c == nil { // Just return other return o } nc := c.Copy() if o == nil { // Nothing to merge return nc } if o.Limit > 0 { nc.Limit = o.Limit } if o.Grace != nil { nc.Grace = o.Grace } if o.IgnoreWarnings { nc.IgnoreWarnings = o...
[ "func", "(", "c", "*", "CheckRestart", ")", "Merge", "(", "o", "*", "CheckRestart", ")", "*", "CheckRestart", "{", "if", "c", "==", "nil", "{", "// Just return other", "return", "o", "\n", "}", "\n\n", "nc", ":=", "c", ".", "Copy", "(", ")", "\n\n", ...
// Merge values from other CheckRestart over default values on this // CheckRestart and return merged copy.
[ "Merge", "values", "from", "other", "CheckRestart", "over", "default", "values", "on", "this", "CheckRestart", "and", "return", "merged", "copy", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L314-L340
132,699
hashicorp/nomad
api/tasks.go
NewTaskGroup
func NewTaskGroup(name string, count int) *TaskGroup { return &TaskGroup{ Name: stringToPtr(name), Count: intToPtr(count), } }
go
func NewTaskGroup(name string, count int) *TaskGroup { return &TaskGroup{ Name: stringToPtr(name), Count: intToPtr(count), } }
[ "func", "NewTaskGroup", "(", "name", "string", ",", "count", "int", ")", "*", "TaskGroup", "{", "return", "&", "TaskGroup", "{", "Name", ":", "stringToPtr", "(", "name", ")", ",", "Count", ":", "intToPtr", "(", "count", ")", ",", "}", "\n", "}" ]
// NewTaskGroup creates a new TaskGroup.
[ "NewTaskGroup", "creates", "a", "new", "TaskGroup", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/tasks.go#L500-L505