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,200
hashicorp/nomad
helper/pluginutils/loader/init.go
initInternal
func (l *PluginLoader) initInternal(plugins map[PluginID]*InternalPluginConfig, configs map[string]*config.PluginConfig) (map[PluginID]*pluginInfo, error) { var mErr multierror.Error fingerprinted := make(map[PluginID]*pluginInfo, len(plugins)) for k, config := range plugins { // Create an instance raw := config...
go
func (l *PluginLoader) initInternal(plugins map[PluginID]*InternalPluginConfig, configs map[string]*config.PluginConfig) (map[PluginID]*pluginInfo, error) { var mErr multierror.Error fingerprinted := make(map[PluginID]*pluginInfo, len(plugins)) for k, config := range plugins { // Create an instance raw := config...
[ "func", "(", "l", "*", "PluginLoader", ")", "initInternal", "(", "plugins", "map", "[", "PluginID", "]", "*", "InternalPluginConfig", ",", "configs", "map", "[", "string", "]", "*", "config", ".", "PluginConfig", ")", "(", "map", "[", "PluginID", "]", "*...
// initInternal initializes internal plugins.
[ "initInternal", "initializes", "internal", "plugins", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L87-L154
132,201
hashicorp/nomad
helper/pluginutils/loader/init.go
selectApiVersion
func (l *PluginLoader) selectApiVersion(i *base.PluginInfoResponse) (string, error) { if i == nil { return "", fmt.Errorf("nil plugin info given") } if len(i.PluginApiVersions) == 0 { return "", fmt.Errorf("plugin provided no compatible API versions") } pluginVersions, err := convertVersions(i.PluginApiVersio...
go
func (l *PluginLoader) selectApiVersion(i *base.PluginInfoResponse) (string, error) { if i == nil { return "", fmt.Errorf("nil plugin info given") } if len(i.PluginApiVersions) == 0 { return "", fmt.Errorf("plugin provided no compatible API versions") } pluginVersions, err := convertVersions(i.PluginApiVersio...
[ "func", "(", "l", "*", "PluginLoader", ")", "selectApiVersion", "(", "i", "*", "base", ".", "PluginInfoResponse", ")", "(", "string", ",", "error", ")", "{", "if", "i", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "...
// selectApiVersion takes in PluginInfo and returns the highest compatable // version or an error if the plugins response is malformed. If there is no // overlap, an empty string is returned.
[ "selectApiVersion", "takes", "in", "PluginInfo", "and", "returns", "the", "highest", "compatable", "version", "or", "an", "error", "if", "the", "plugins", "response", "is", "malformed", ".", "If", "there", "is", "no", "overlap", "an", "empty", "string", "is", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L159-L187
132,202
hashicorp/nomad
helper/pluginutils/loader/init.go
convertVersions
func convertVersions(in []string) ([]*version.Version, error) { converted := make([]*version.Version, len(in)) for i, v := range in { vv, err := version.NewVersion(v) if err != nil { return nil, fmt.Errorf("failed to convert version %q : %v", v, err) } converted[i] = vv } sort.Slice(converted, func(i, ...
go
func convertVersions(in []string) ([]*version.Version, error) { converted := make([]*version.Version, len(in)) for i, v := range in { vv, err := version.NewVersion(v) if err != nil { return nil, fmt.Errorf("failed to convert version %q : %v", v, err) } converted[i] = vv } sort.Slice(converted, func(i, ...
[ "func", "convertVersions", "(", "in", "[", "]", "string", ")", "(", "[", "]", "*", "version", ".", "Version", ",", "error", ")", "{", "converted", ":=", "make", "(", "[", "]", "*", "version", ".", "Version", ",", "len", "(", "in", ")", ")", "\n",...
// convertVersions takes a list of string versions and returns a sorted list of // versions from highest to lowest.
[ "convertVersions", "takes", "a", "list", "of", "string", "versions", "and", "returns", "a", "sorted", "list", "of", "versions", "from", "highest", "to", "lowest", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L191-L207
132,203
hashicorp/nomad
helper/pluginutils/loader/init.go
scan
func (l *PluginLoader) scan() ([]os.FileInfo, error) { if l.pluginDir == "" { return nil, nil } // Capture the list of binaries in the plugins folder f, err := os.Open(l.pluginDir) if err != nil { // There are no plugins to scan if os.IsNotExist(err) { l.logger.Warn("skipping external plugins since plugi...
go
func (l *PluginLoader) scan() ([]os.FileInfo, error) { if l.pluginDir == "" { return nil, nil } // Capture the list of binaries in the plugins folder f, err := os.Open(l.pluginDir) if err != nil { // There are no plugins to scan if os.IsNotExist(err) { l.logger.Warn("skipping external plugins since plugi...
[ "func", "(", "l", "*", "PluginLoader", ")", "scan", "(", ")", "(", "[", "]", "os", ".", "FileInfo", ",", "error", ")", "{", "if", "l", ".", "pluginDir", "==", "\"", "\"", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "// Capture the list of ...
// scan scans the plugin directory and retrieves potentially eligible binaries
[ "scan", "scans", "the", "plugin", "directory", "and", "retrieves", "potentially", "eligible", "binaries" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L210-L252
132,204
hashicorp/nomad
helper/pluginutils/loader/init.go
fingerprintPlugins
func (l *PluginLoader) fingerprintPlugins(plugins []os.FileInfo, configs map[string]*config.PluginConfig) (map[PluginID]*pluginInfo, error) { var mErr multierror.Error fingerprinted := make(map[PluginID]*pluginInfo, len(plugins)) for _, p := range plugins { name := cleanPluginExecutable(p.Name()) c := configs[na...
go
func (l *PluginLoader) fingerprintPlugins(plugins []os.FileInfo, configs map[string]*config.PluginConfig) (map[PluginID]*pluginInfo, error) { var mErr multierror.Error fingerprinted := make(map[PluginID]*pluginInfo, len(plugins)) for _, p := range plugins { name := cleanPluginExecutable(p.Name()) c := configs[na...
[ "func", "(", "l", "*", "PluginLoader", ")", "fingerprintPlugins", "(", "plugins", "[", "]", "os", ".", "FileInfo", ",", "configs", "map", "[", "string", "]", "*", "config", ".", "PluginConfig", ")", "(", "map", "[", "PluginID", "]", "*", "pluginInfo", ...
// fingerprintPlugins fingerprints all external plugin binaries
[ "fingerprintPlugins", "fingerprints", "all", "external", "plugin", "binaries" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L255-L306
132,205
hashicorp/nomad
helper/pluginutils/loader/init.go
fingerprintPlugin
func (l *PluginLoader) fingerprintPlugin(pluginExe os.FileInfo, config *config.PluginConfig) (*pluginInfo, error) { info := &pluginInfo{ exePath: filepath.Join(l.pluginDir, pluginExe.Name()), } // Build the command cmd := exec.Command(info.exePath) if config != nil { cmd.Args = append(cmd.Args, config.Args......
go
func (l *PluginLoader) fingerprintPlugin(pluginExe os.FileInfo, config *config.PluginConfig) (*pluginInfo, error) { info := &pluginInfo{ exePath: filepath.Join(l.pluginDir, pluginExe.Name()), } // Build the command cmd := exec.Command(info.exePath) if config != nil { cmd.Args = append(cmd.Args, config.Args......
[ "func", "(", "l", "*", "PluginLoader", ")", "fingerprintPlugin", "(", "pluginExe", "os", ".", "FileInfo", ",", "config", "*", "config", ".", "PluginConfig", ")", "(", "*", "pluginInfo", ",", "error", ")", "{", "info", ":=", "&", "pluginInfo", "{", "exePa...
// fingerprintPlugin fingerprints the passed external plugin
[ "fingerprintPlugin", "fingerprints", "the", "passed", "external", "plugin" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L309-L383
132,206
hashicorp/nomad
helper/pluginutils/loader/init.go
mergePlugins
func (l *PluginLoader) mergePlugins(internal, external map[PluginID]*pluginInfo) map[PluginID]*pluginInfo { finalized := make(map[PluginID]*pluginInfo, len(internal)) // Load the internal plugins for k, v := range internal { finalized[k] = v } for k, extPlugin := range external { internal, ok := finalized[k]...
go
func (l *PluginLoader) mergePlugins(internal, external map[PluginID]*pluginInfo) map[PluginID]*pluginInfo { finalized := make(map[PluginID]*pluginInfo, len(internal)) // Load the internal plugins for k, v := range internal { finalized[k] = v } for k, extPlugin := range external { internal, ok := finalized[k]...
[ "func", "(", "l", "*", "PluginLoader", ")", "mergePlugins", "(", "internal", ",", "external", "map", "[", "PluginID", "]", "*", "pluginInfo", ")", "map", "[", "PluginID", "]", "*", "pluginInfo", "{", "finalized", ":=", "make", "(", "map", "[", "PluginID"...
// mergePlugins merges internal and external plugins, preferring the highest // version.
[ "mergePlugins", "merges", "internal", "and", "external", "plugins", "preferring", "the", "highest", "version", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L387-L413
132,207
hashicorp/nomad
helper/pluginutils/loader/init.go
validatePluginConfigs
func (l *PluginLoader) validatePluginConfigs() error { var mErr multierror.Error for id, info := range l.plugins { if err := l.validatePluginConfig(id, info); err != nil { wrapped := multierror.Prefix(err, fmt.Sprintf("plugin %s:", id)) multierror.Append(&mErr, wrapped) } } return mErr.ErrorOrNil() }
go
func (l *PluginLoader) validatePluginConfigs() error { var mErr multierror.Error for id, info := range l.plugins { if err := l.validatePluginConfig(id, info); err != nil { wrapped := multierror.Prefix(err, fmt.Sprintf("plugin %s:", id)) multierror.Append(&mErr, wrapped) } } return mErr.ErrorOrNil() }
[ "func", "(", "l", "*", "PluginLoader", ")", "validatePluginConfigs", "(", ")", "error", "{", "var", "mErr", "multierror", ".", "Error", "\n", "for", "id", ",", "info", ":=", "range", "l", ".", "plugins", "{", "if", "err", ":=", "l", ".", "validatePlugi...
// validatePluginConfigs is used to validate each plugins' configuration. If the // plugin has a config, it is parsed with the plugins config schema and // SetConfig is called to ensure the config is valid.
[ "validatePluginConfigs", "is", "used", "to", "validate", "each", "plugins", "configuration", ".", "If", "the", "plugin", "has", "a", "config", "it", "is", "parsed", "with", "the", "plugins", "config", "schema", "and", "SetConfig", "is", "called", "to", "ensure...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L418-L428
132,208
hashicorp/nomad
helper/pluginutils/loader/init.go
validatePluginConfig
func (l *PluginLoader) validatePluginConfig(id PluginID, info *pluginInfo) error { var mErr multierror.Error // Check if a config is allowed if info.configSchema == nil { if info.config != nil { return fmt.Errorf("configuration not allowed but config passed") } // Nothing to do return nil } // Conver...
go
func (l *PluginLoader) validatePluginConfig(id PluginID, info *pluginInfo) error { var mErr multierror.Error // Check if a config is allowed if info.configSchema == nil { if info.config != nil { return fmt.Errorf("configuration not allowed but config passed") } // Nothing to do return nil } // Conver...
[ "func", "(", "l", "*", "PluginLoader", ")", "validatePluginConfig", "(", "id", "PluginID", ",", "info", "*", "pluginInfo", ")", "error", "{", "var", "mErr", "multierror", ".", "Error", "\n\n", "// Check if a config is allowed", "if", "info", ".", "configSchema",...
// validatePluginConfig is used to validate the plugin's configuration. If the // plugin has a config, it is parsed with the plugins config schema and // SetConfig is called to ensure the config is valid.
[ "validatePluginConfig", "is", "used", "to", "validate", "the", "plugin", "s", "configuration", ".", "If", "the", "plugin", "has", "a", "config", "it", "is", "parsed", "with", "the", "plugins", "config", "schema", "and", "SetConfig", "is", "called", "to", "en...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/init.go#L433-L497
132,209
hashicorp/nomad
command/agent/job_endpoint.go
JobsParseRequest
func (s *HTTPServer) JobsParseRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) { if req.Method != http.MethodPut && req.Method != http.MethodPost { return nil, CodedError(405, ErrInvalidMethod) } args := &api.JobsParseRequest{} if err := decodeBody(req, &args); err != nil { return nil,...
go
func (s *HTTPServer) JobsParseRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) { if req.Method != http.MethodPut && req.Method != http.MethodPost { return nil, CodedError(405, ErrInvalidMethod) } args := &api.JobsParseRequest{} if err := decodeBody(req, &args); err != nil { return nil,...
[ "func", "(", "s", "*", "HTTPServer", ")", "JobsParseRequest", "(", "resp", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "req", ".", "Method", "!=", "http", ".",...
// JobsParseRequest parses a hcl jobspec and returns a api.Job
[ "JobsParseRequest", "parses", "a", "hcl", "jobspec", "and", "returns", "a", "api", ".", "Job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/job_endpoint.go#L566-L589
132,210
hashicorp/nomad
client/state/state_database.go
GetStateDBFactory
func GetStateDBFactory(devMode bool) NewStateDBFunc { // Return a noop state db implementation when in debug mode if devMode { return func(hclog.Logger, string) (StateDB, error) { return NoopDB{}, nil } } return NewBoltStateDB }
go
func GetStateDBFactory(devMode bool) NewStateDBFunc { // Return a noop state db implementation when in debug mode if devMode { return func(hclog.Logger, string) (StateDB, error) { return NoopDB{}, nil } } return NewBoltStateDB }
[ "func", "GetStateDBFactory", "(", "devMode", "bool", ")", "NewStateDBFunc", "{", "// Return a noop state db implementation when in debug mode", "if", "devMode", "{", "return", "func", "(", "hclog", ".", "Logger", ",", "string", ")", "(", "StateDB", ",", "error", ")"...
// GetStateDBFactory returns a func for creating a StateDB
[ "GetStateDBFactory", "returns", "a", "func", "for", "creating", "a", "StateDB" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L92-L101
132,211
hashicorp/nomad
client/state/state_database.go
NewBoltStateDB
func NewBoltStateDB(logger hclog.Logger, stateDir string) (StateDB, error) { fn := filepath.Join(stateDir, "state.db") // Check to see if the DB already exists fi, err := os.Stat(fn) if err != nil && !os.IsNotExist(err) { return nil, err } firstRun := fi == nil // Create or open the boltdb state database db...
go
func NewBoltStateDB(logger hclog.Logger, stateDir string) (StateDB, error) { fn := filepath.Join(stateDir, "state.db") // Check to see if the DB already exists fi, err := os.Stat(fn) if err != nil && !os.IsNotExist(err) { return nil, err } firstRun := fi == nil // Create or open the boltdb state database db...
[ "func", "NewBoltStateDB", "(", "logger", "hclog", ".", "Logger", ",", "stateDir", "string", ")", "(", "StateDB", ",", "error", ")", "{", "fn", ":=", "filepath", ".", "Join", "(", "stateDir", ",", "\"", "\"", ")", "\n\n", "// Check to see if the DB already ex...
// NewBoltStateDB creates or opens an existing boltdb state file or returns an // error.
[ "NewBoltStateDB", "creates", "or", "opens", "an", "existing", "boltdb", "state", "file", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L113-L143
132,212
hashicorp/nomad
client/state/state_database.go
GetAllAllocations
func (s *BoltStateDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error) { var allocs []*structs.Allocation var errs map[string]error err := s.db.View(func(tx *boltdd.Tx) error { allocs, errs = s.getAllAllocations(tx) return nil }) // db.View itself may return an error, so still check if er...
go
func (s *BoltStateDB) GetAllAllocations() ([]*structs.Allocation, map[string]error, error) { var allocs []*structs.Allocation var errs map[string]error err := s.db.View(func(tx *boltdd.Tx) error { allocs, errs = s.getAllAllocations(tx) return nil }) // db.View itself may return an error, so still check if er...
[ "func", "(", "s", "*", "BoltStateDB", ")", "GetAllAllocations", "(", ")", "(", "[", "]", "*", "structs", ".", "Allocation", ",", "map", "[", "string", "]", "error", ",", "error", ")", "{", "var", "allocs", "[", "]", "*", "structs", ".", "Allocation",...
// GetAllAllocations gets all allocations persisted by this client and returns // a map of alloc ids to errors for any allocations that could not be restored. // // If a fatal error was encountered it will be returned and the other two // values will be nil.
[ "GetAllAllocations", "gets", "all", "allocations", "persisted", "by", "this", "client", "and", "returns", "a", "map", "of", "alloc", "ids", "to", "errors", "for", "any", "allocations", "that", "could", "not", "be", "restored", ".", "If", "a", "fatal", "error...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L154-L168
132,213
hashicorp/nomad
client/state/state_database.go
PutAllocation
func (s *BoltStateDB) PutAllocation(alloc *structs.Allocation) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root allocations bucket allocsBkt, err := tx.CreateBucketIfNotExists(allocationsBucketName) if err != nil { return err } // Retrieve the specific allocations bucket key ...
go
func (s *BoltStateDB) PutAllocation(alloc *structs.Allocation) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root allocations bucket allocsBkt, err := tx.CreateBucketIfNotExists(allocationsBucketName) if err != nil { return err } // Retrieve the specific allocations bucket key ...
[ "func", "(", "s", "*", "BoltStateDB", ")", "PutAllocation", "(", "alloc", "*", "structs", ".", "Allocation", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", "Tx", ")", "error", "{", "// Retrieve...
// PutAllocation stores an allocation or returns an error.
[ "PutAllocation", "stores", "an", "allocation", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L210-L230
132,214
hashicorp/nomad
client/state/state_database.go
PutDeploymentStatus
func (s *BoltStateDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error { return s.db.Update(func(tx *boltdd.Tx) error { return putDeploymentStatusImpl(tx, allocID, ds) }) }
go
func (s *BoltStateDB) PutDeploymentStatus(allocID string, ds *structs.AllocDeploymentStatus) error { return s.db.Update(func(tx *boltdd.Tx) error { return putDeploymentStatusImpl(tx, allocID, ds) }) }
[ "func", "(", "s", "*", "BoltStateDB", ")", "PutDeploymentStatus", "(", "allocID", "string", ",", "ds", "*", "structs", ".", "AllocDeploymentStatus", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", ...
// PutDeploymentStatus stores an allocation's DeploymentStatus or returns an // error.
[ "PutDeploymentStatus", "stores", "an", "allocation", "s", "DeploymentStatus", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L239-L243
132,215
hashicorp/nomad
client/state/state_database.go
GetDeploymentStatus
func (s *BoltStateDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error) { var entry deployStatusEntry err := s.db.View(func(tx *boltdd.Tx) error { allAllocsBkt := tx.Bucket(allocationsBucketName) if allAllocsBkt == nil { // No state, return return nil } allocBkt := allAllocsB...
go
func (s *BoltStateDB) GetDeploymentStatus(allocID string) (*structs.AllocDeploymentStatus, error) { var entry deployStatusEntry err := s.db.View(func(tx *boltdd.Tx) error { allAllocsBkt := tx.Bucket(allocationsBucketName) if allAllocsBkt == nil { // No state, return return nil } allocBkt := allAllocsB...
[ "func", "(", "s", "*", "BoltStateDB", ")", "GetDeploymentStatus", "(", "allocID", "string", ")", "(", "*", "structs", ".", "AllocDeploymentStatus", ",", "error", ")", "{", "var", "entry", "deployStatusEntry", "\n\n", "err", ":=", "s", ".", "db", ".", "View...
// GetDeploymentStatus retrieves an allocation's DeploymentStatus or returns an // error.
[ "GetDeploymentStatus", "retrieves", "an", "allocation", "s", "DeploymentStatus", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L259-L288
132,216
hashicorp/nomad
client/state/state_database.go
GetTaskRunnerState
func (s *BoltStateDB) GetTaskRunnerState(allocID, taskName string) (*trstate.LocalState, *structs.TaskState, error) { var ls *trstate.LocalState var ts *structs.TaskState err := s.db.View(func(tx *boltdd.Tx) error { allAllocsBkt := tx.Bucket(allocationsBucketName) if allAllocsBkt == nil { // No state, return...
go
func (s *BoltStateDB) GetTaskRunnerState(allocID, taskName string) (*trstate.LocalState, *structs.TaskState, error) { var ls *trstate.LocalState var ts *structs.TaskState err := s.db.View(func(tx *boltdd.Tx) error { allAllocsBkt := tx.Bucket(allocationsBucketName) if allAllocsBkt == nil { // No state, return...
[ "func", "(", "s", "*", "BoltStateDB", ")", "GetTaskRunnerState", "(", "allocID", ",", "taskName", "string", ")", "(", "*", "trstate", ".", "LocalState", ",", "*", "structs", ".", "TaskState", ",", "error", ")", "{", "var", "ls", "*", "trstate", ".", "L...
// GetTaskRunnerState returns the LocalState and TaskState for a // TaskRunner. LocalState or TaskState will be nil if they do not exist. // // If an error is encountered both LocalState and TaskState will be nil.
[ "GetTaskRunnerState", "returns", "the", "LocalState", "and", "TaskState", "for", "a", "TaskRunner", ".", "LocalState", "or", "TaskState", "will", "be", "nil", "if", "they", "do", "not", "exist", ".", "If", "an", "error", "is", "encountered", "both", "LocalStat...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L294-L347
132,217
hashicorp/nomad
client/state/state_database.go
PutTaskRunnerLocalState
func (s *BoltStateDB) PutTaskRunnerLocalState(allocID, taskName string, val *trstate.LocalState) error { return s.db.Update(func(tx *boltdd.Tx) error { return putTaskRunnerLocalStateImpl(tx, allocID, taskName, val) }) }
go
func (s *BoltStateDB) PutTaskRunnerLocalState(allocID, taskName string, val *trstate.LocalState) error { return s.db.Update(func(tx *boltdd.Tx) error { return putTaskRunnerLocalStateImpl(tx, allocID, taskName, val) }) }
[ "func", "(", "s", "*", "BoltStateDB", ")", "PutTaskRunnerLocalState", "(", "allocID", ",", "taskName", "string", ",", "val", "*", "trstate", ".", "LocalState", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "bo...
// PutTaskRunnerLocalState stores TaskRunner's LocalState or returns an error.
[ "PutTaskRunnerLocalState", "stores", "TaskRunner", "s", "LocalState", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L350-L354
132,218
hashicorp/nomad
client/state/state_database.go
putTaskRunnerLocalStateImpl
func putTaskRunnerLocalStateImpl(tx *boltdd.Tx, allocID, taskName string, val *trstate.LocalState) error { taskBkt, err := getTaskBucket(tx, allocID, taskName) if err != nil { return fmt.Errorf("failed to retrieve allocation bucket: %v", err) } if err := taskBkt.Put(taskLocalStateKey, val); err != nil { return...
go
func putTaskRunnerLocalStateImpl(tx *boltdd.Tx, allocID, taskName string, val *trstate.LocalState) error { taskBkt, err := getTaskBucket(tx, allocID, taskName) if err != nil { return fmt.Errorf("failed to retrieve allocation bucket: %v", err) } if err := taskBkt.Put(taskLocalStateKey, val); err != nil { return...
[ "func", "putTaskRunnerLocalStateImpl", "(", "tx", "*", "boltdd", ".", "Tx", ",", "allocID", ",", "taskName", "string", ",", "val", "*", "trstate", ".", "LocalState", ")", "error", "{", "taskBkt", ",", "err", ":=", "getTaskBucket", "(", "tx", ",", "allocID"...
// putTaskRunnerLocalStateImpl stores TaskRunner's LocalState in an ongoing // transaction or returns an error.
[ "putTaskRunnerLocalStateImpl", "stores", "TaskRunner", "s", "LocalState", "in", "an", "ongoing", "transaction", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L358-L369
132,219
hashicorp/nomad
client/state/state_database.go
PutTaskState
func (s *BoltStateDB) PutTaskState(allocID, taskName string, state *structs.TaskState) error { return s.db.Update(func(tx *boltdd.Tx) error { return putTaskStateImpl(tx, allocID, taskName, state) }) }
go
func (s *BoltStateDB) PutTaskState(allocID, taskName string, state *structs.TaskState) error { return s.db.Update(func(tx *boltdd.Tx) error { return putTaskStateImpl(tx, allocID, taskName, state) }) }
[ "func", "(", "s", "*", "BoltStateDB", ")", "PutTaskState", "(", "allocID", ",", "taskName", "string", ",", "state", "*", "structs", ".", "TaskState", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", "...
// PutTaskState stores a task's state or returns an error.
[ "PutTaskState", "stores", "a", "task", "s", "state", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L372-L376
132,220
hashicorp/nomad
client/state/state_database.go
putTaskStateImpl
func putTaskStateImpl(tx *boltdd.Tx, allocID, taskName string, state *structs.TaskState) error { taskBkt, err := getTaskBucket(tx, allocID, taskName) if err != nil { return fmt.Errorf("failed to retrieve allocation bucket: %v", err) } return taskBkt.Put(taskStateKey, state) }
go
func putTaskStateImpl(tx *boltdd.Tx, allocID, taskName string, state *structs.TaskState) error { taskBkt, err := getTaskBucket(tx, allocID, taskName) if err != nil { return fmt.Errorf("failed to retrieve allocation bucket: %v", err) } return taskBkt.Put(taskStateKey, state) }
[ "func", "putTaskStateImpl", "(", "tx", "*", "boltdd", ".", "Tx", ",", "allocID", ",", "taskName", "string", ",", "state", "*", "structs", ".", "TaskState", ")", "error", "{", "taskBkt", ",", "err", ":=", "getTaskBucket", "(", "tx", ",", "allocID", ",", ...
// putTaskStateImpl stores a task's state in an ongoing transaction or returns // an error.
[ "putTaskStateImpl", "stores", "a", "task", "s", "state", "in", "an", "ongoing", "transaction", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L380-L387
132,221
hashicorp/nomad
client/state/state_database.go
DeleteTaskBucket
func (s *BoltStateDB) DeleteTaskBucket(allocID, taskName string) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root allocations bucket allocations := tx.Bucket(allocationsBucketName) if allocations == nil { return nil } // Retrieve the specific allocations bucket alloc := alloc...
go
func (s *BoltStateDB) DeleteTaskBucket(allocID, taskName string) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root allocations bucket allocations := tx.Bucket(allocationsBucketName) if allocations == nil { return nil } // Retrieve the specific allocations bucket alloc := alloc...
[ "func", "(", "s", "*", "BoltStateDB", ")", "DeleteTaskBucket", "(", "allocID", ",", "taskName", "string", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", "Tx", ")", "error", "{", "// Retrieve the ...
// DeleteTaskBucket is used to delete a task bucket if it exists.
[ "DeleteTaskBucket", "is", "used", "to", "delete", "a", "task", "bucket", "if", "it", "exists", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L390-L408
132,222
hashicorp/nomad
client/state/state_database.go
DeleteAllocationBucket
func (s *BoltStateDB) DeleteAllocationBucket(allocID string) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root allocations bucket allocations := tx.Bucket(allocationsBucketName) if allocations == nil { return nil } key := []byte(allocID) return allocations.DeleteBucket(key) }...
go
func (s *BoltStateDB) DeleteAllocationBucket(allocID string) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root allocations bucket allocations := tx.Bucket(allocationsBucketName) if allocations == nil { return nil } key := []byte(allocID) return allocations.DeleteBucket(key) }...
[ "func", "(", "s", "*", "BoltStateDB", ")", "DeleteAllocationBucket", "(", "allocID", "string", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", "Tx", ")", "error", "{", "// Retrieve the root allocation...
// DeleteAllocationBucket is used to delete an allocation bucket if it exists.
[ "DeleteAllocationBucket", "is", "used", "to", "delete", "an", "allocation", "bucket", "if", "it", "exists", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L411-L422
132,223
hashicorp/nomad
client/state/state_database.go
getAllocationBucket
func getAllocationBucket(tx *boltdd.Tx, allocID string) (*boltdd.Bucket, error) { var err error w := tx.Writable() // Retrieve the root allocations bucket allocations := tx.Bucket(allocationsBucketName) if allocations == nil { if !w { return nil, fmt.Errorf("Allocations bucket doesn't exist and transaction i...
go
func getAllocationBucket(tx *boltdd.Tx, allocID string) (*boltdd.Bucket, error) { var err error w := tx.Writable() // Retrieve the root allocations bucket allocations := tx.Bucket(allocationsBucketName) if allocations == nil { if !w { return nil, fmt.Errorf("Allocations bucket doesn't exist and transaction i...
[ "func", "getAllocationBucket", "(", "tx", "*", "boltdd", ".", "Tx", ",", "allocID", "string", ")", "(", "*", "boltdd", ".", "Bucket", ",", "error", ")", "{", "var", "err", "error", "\n", "w", ":=", "tx", ".", "Writable", "(", ")", "\n\n", "// Retriev...
// getAllocationBucket returns the bucket used to persist state about a // particular allocation. If the root allocation bucket or the specific // allocation bucket doesn't exist, it will be created as long as the // transaction is writable.
[ "getAllocationBucket", "returns", "the", "bucket", "used", "to", "persist", "state", "about", "a", "particular", "allocation", ".", "If", "the", "root", "allocation", "bucket", "or", "the", "specific", "allocation", "bucket", "doesn", "t", "exist", "it", "will",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L434-L466
132,224
hashicorp/nomad
client/state/state_database.go
getTaskBucket
func getTaskBucket(tx *boltdd.Tx, allocID, taskName string) (*boltdd.Bucket, error) { alloc, err := getAllocationBucket(tx, allocID) if err != nil { return nil, err } // Retrieve the specific task bucket w := tx.Writable() key := taskBucketName(taskName) task := alloc.Bucket(key) if task == nil { if !w { ...
go
func getTaskBucket(tx *boltdd.Tx, allocID, taskName string) (*boltdd.Bucket, error) { alloc, err := getAllocationBucket(tx, allocID) if err != nil { return nil, err } // Retrieve the specific task bucket w := tx.Writable() key := taskBucketName(taskName) task := alloc.Bucket(key) if task == nil { if !w { ...
[ "func", "getTaskBucket", "(", "tx", "*", "boltdd", ".", "Tx", ",", "allocID", ",", "taskName", "string", ")", "(", "*", "boltdd", ".", "Bucket", ",", "error", ")", "{", "alloc", ",", "err", ":=", "getAllocationBucket", "(", "tx", ",", "allocID", ")", ...
// getTaskBucket returns the bucket used to persist state about a // particular task. If the root allocation bucket, the specific // allocation or task bucket doesn't exist, they will be created as long as the // transaction is writable.
[ "getTaskBucket", "returns", "the", "bucket", "used", "to", "persist", "state", "about", "a", "particular", "task", ".", "If", "the", "root", "allocation", "bucket", "the", "specific", "allocation", "or", "task", "bucket", "doesn", "t", "exist", "they", "will",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L472-L494
132,225
hashicorp/nomad
client/state/state_database.go
PutDevicePluginState
func (s *BoltStateDB) PutDevicePluginState(ps *dmstate.PluginState) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root device manager bucket devBkt, err := tx.CreateBucketIfNotExists(devManagerBucket) if err != nil { return err } return devBkt.Put(managerPluginStateKey, ps) }) }
go
func (s *BoltStateDB) PutDevicePluginState(ps *dmstate.PluginState) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root device manager bucket devBkt, err := tx.CreateBucketIfNotExists(devManagerBucket) if err != nil { return err } return devBkt.Put(managerPluginStateKey, ps) }) }
[ "func", "(", "s", "*", "BoltStateDB", ")", "PutDevicePluginState", "(", "ps", "*", "dmstate", ".", "PluginState", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", "Tx", ")", "error", "{", "// Ret...
// PutDevicePluginState stores the device manager's plugin state or returns an // error.
[ "PutDevicePluginState", "stores", "the", "device", "manager", "s", "plugin", "state", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L498-L508
132,226
hashicorp/nomad
client/state/state_database.go
PutDriverPluginState
func (s *BoltStateDB) PutDriverPluginState(ps *driverstate.PluginState) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root driver manager bucket driverBkt, err := tx.CreateBucketIfNotExists(driverManagerBucket) if err != nil { return err } return driverBkt.Put(managerPluginStateK...
go
func (s *BoltStateDB) PutDriverPluginState(ps *driverstate.PluginState) error { return s.db.Update(func(tx *boltdd.Tx) error { // Retrieve the root driver manager bucket driverBkt, err := tx.CreateBucketIfNotExists(driverManagerBucket) if err != nil { return err } return driverBkt.Put(managerPluginStateK...
[ "func", "(", "s", "*", "BoltStateDB", ")", "PutDriverPluginState", "(", "ps", "*", "driverstate", ".", "PluginState", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", "Tx", ")", "error", "{", "//...
// PutDriverPluginState stores the driver manager's plugin state or returns an // error.
[ "PutDriverPluginState", "stores", "the", "driver", "manager", "s", "plugin", "state", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L545-L555
132,227
hashicorp/nomad
client/state/state_database.go
GetDriverPluginState
func (s *BoltStateDB) GetDriverPluginState() (*driverstate.PluginState, error) { var ps *driverstate.PluginState err := s.db.View(func(tx *boltdd.Tx) error { driverBkt := tx.Bucket(driverManagerBucket) if driverBkt == nil { // No state, return return nil } // Restore Plugin State if it exists ps = &...
go
func (s *BoltStateDB) GetDriverPluginState() (*driverstate.PluginState, error) { var ps *driverstate.PluginState err := s.db.View(func(tx *boltdd.Tx) error { driverBkt := tx.Bucket(driverManagerBucket) if driverBkt == nil { // No state, return return nil } // Restore Plugin State if it exists ps = &...
[ "func", "(", "s", "*", "BoltStateDB", ")", "GetDriverPluginState", "(", ")", "(", "*", "driverstate", ".", "PluginState", ",", "error", ")", "{", "var", "ps", "*", "driverstate", ".", "PluginState", "\n\n", "err", ":=", "s", ".", "db", ".", "View", "("...
// GetDriverPluginState stores the driver manager's plugin state or returns an // error.
[ "GetDriverPluginState", "stores", "the", "driver", "manager", "s", "plugin", "state", "or", "returns", "an", "error", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L559-L588
132,228
hashicorp/nomad
client/state/state_database.go
init
func (s *BoltStateDB) init() error { return s.db.Update(func(tx *boltdd.Tx) error { return addMeta(tx.BoltTx()) }) }
go
func (s *BoltStateDB) init() error { return s.db.Update(func(tx *boltdd.Tx) error { return addMeta(tx.BoltTx()) }) }
[ "func", "(", "s", "*", "BoltStateDB", ")", "init", "(", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "boltdd", ".", "Tx", ")", "error", "{", "return", "addMeta", "(", "tx", ".", "BoltTx", "(", ")", ")...
// init initializes metadata entries in a newly created state database.
[ "init", "initializes", "metadata", "entries", "in", "a", "newly", "created", "state", "database", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L591-L595
132,229
hashicorp/nomad
client/state/state_database.go
Upgrade
func (s *BoltStateDB) Upgrade() error { // Check to see if the underlying DB needs upgrading. upgrade, err := NeedsUpgrade(s.db.BoltDB()) if err != nil { return err } if !upgrade { // No upgrade needed! return nil } // Upgraded needed. Backup the boltdb first. backupFileName := filepath.Join(s.stateDir, ...
go
func (s *BoltStateDB) Upgrade() error { // Check to see if the underlying DB needs upgrading. upgrade, err := NeedsUpgrade(s.db.BoltDB()) if err != nil { return err } if !upgrade { // No upgrade needed! return nil } // Upgraded needed. Backup the boltdb first. backupFileName := filepath.Join(s.stateDir, ...
[ "func", "(", "s", "*", "BoltStateDB", ")", "Upgrade", "(", ")", "error", "{", "// Check to see if the underlying DB needs upgrading.", "upgrade", ",", "err", ":=", "NeedsUpgrade", "(", "s", ".", "db", ".", "BoltDB", "(", ")", ")", "\n", "if", "err", "!=", ...
// Upgrade bolt state db from 0.8 schema to 0.9 schema. Noop if already using // 0.9 schema. Creates a backup before upgrading.
[ "Upgrade", "bolt", "state", "db", "from", "0", ".", "8", "schema", "to", "0", ".", "9", "schema", ".", "Noop", "if", "already", "using", "0", ".", "9", "schema", ".", "Creates", "a", "backup", "before", "upgrading", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/state_database.go#L599-L639
132,230
hashicorp/nomad
client/allocrunner/state/state.go
Copy
func (s *State) Copy() *State { taskStates := make(map[string]*structs.TaskState, len(s.TaskStates)) for k, v := range s.TaskStates { taskStates[k] = v.Copy() } return &State{ ClientStatus: s.ClientStatus, ClientDescription: s.ClientDescription, DeploymentStatus: s.DeploymentStatus.Copy(), TaskState...
go
func (s *State) Copy() *State { taskStates := make(map[string]*structs.TaskState, len(s.TaskStates)) for k, v := range s.TaskStates { taskStates[k] = v.Copy() } return &State{ ClientStatus: s.ClientStatus, ClientDescription: s.ClientDescription, DeploymentStatus: s.DeploymentStatus.Copy(), TaskState...
[ "func", "(", "s", "*", "State", ")", "Copy", "(", ")", "*", "State", "{", "taskStates", ":=", "make", "(", "map", "[", "string", "]", "*", "structs", ".", "TaskState", ",", "len", "(", "s", ".", "TaskStates", ")", ")", "\n", "for", "k", ",", "v...
// Copy returns a deep copy of State.
[ "Copy", "returns", "a", "deep", "copy", "of", "State", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/state/state.go#L50-L61
132,231
hashicorp/nomad
scheduler/preemption.go
GetNetworkPreemptionResourceFactory
func GetNetworkPreemptionResourceFactory() PreemptionResourceFactory { return func(availableResources *structs.ComparableResources, resourceNeeded *structs.ComparableResources) PreemptionResource { available := availableResources.Flattened.Networks[0] return &NetworkPreemptionResource{ availableResources: avail...
go
func GetNetworkPreemptionResourceFactory() PreemptionResourceFactory { return func(availableResources *structs.ComparableResources, resourceNeeded *structs.ComparableResources) PreemptionResource { available := availableResources.Flattened.Networks[0] return &NetworkPreemptionResource{ availableResources: avail...
[ "func", "GetNetworkPreemptionResourceFactory", "(", ")", "PreemptionResourceFactory", "{", "return", "func", "(", "availableResources", "*", "structs", ".", "ComparableResources", ",", "resourceNeeded", "*", "structs", ".", "ComparableResources", ")", "PreemptionResource", ...
// GetNetworkPreemptionResourceFactory returns a preemption resource factory for network assignments
[ "GetNetworkPreemptionResourceFactory", "returns", "a", "preemption", "resource", "factory", "for", "network", "assignments" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L74-L82
132,232
hashicorp/nomad
scheduler/preemption.go
SetNode
func (p *Preemptor) SetNode(node *structs.Node) { nodeRemainingResources := node.ComparableResources() // Subtract the reserved resources of the node if c := node.ComparableReservedResources(); c != nil { nodeRemainingResources.Subtract(c) } p.nodeRemainingResources = nodeRemainingResources }
go
func (p *Preemptor) SetNode(node *structs.Node) { nodeRemainingResources := node.ComparableResources() // Subtract the reserved resources of the node if c := node.ComparableReservedResources(); c != nil { nodeRemainingResources.Subtract(c) } p.nodeRemainingResources = nodeRemainingResources }
[ "func", "(", "p", "*", "Preemptor", ")", "SetNode", "(", "node", "*", "structs", ".", "Node", ")", "{", "nodeRemainingResources", ":=", "node", ".", "ComparableResources", "(", ")", "\n\n", "// Subtract the reserved resources of the node", "if", "c", ":=", "node...
// SetNode sets the node
[ "SetNode", "sets", "the", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L135-L143
132,233
hashicorp/nomad
scheduler/preemption.go
SetCandidates
func (p *Preemptor) SetCandidates(allocs []*structs.Allocation) { // Reset candidate set p.currentAllocs = []*structs.Allocation{} for _, alloc := range allocs { // Ignore any allocations of the job being placed // This filters out any previous allocs of the job, and any new allocs in the plan if alloc.JobID =...
go
func (p *Preemptor) SetCandidates(allocs []*structs.Allocation) { // Reset candidate set p.currentAllocs = []*structs.Allocation{} for _, alloc := range allocs { // Ignore any allocations of the job being placed // This filters out any previous allocs of the job, and any new allocs in the plan if alloc.JobID =...
[ "func", "(", "p", "*", "Preemptor", ")", "SetCandidates", "(", "allocs", "[", "]", "*", "structs", ".", "Allocation", ")", "{", "// Reset candidate set", "p", ".", "currentAllocs", "=", "[", "]", "*", "structs", ".", "Allocation", "{", "}", "\n", "for", ...
// SetCandidates initializes the candidate set from which preemptions are chosen
[ "SetCandidates", "initializes", "the", "candidate", "set", "from", "which", "preemptions", "are", "chosen" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L146-L164
132,234
hashicorp/nomad
scheduler/preemption.go
getNumPreemptions
func (p *Preemptor) getNumPreemptions(alloc *structs.Allocation) int { c, ok := p.currentPreemptions[structs.NewNamespacedID(alloc.JobID, alloc.Namespace)][alloc.TaskGroup] if !ok { return 0 } return c }
go
func (p *Preemptor) getNumPreemptions(alloc *structs.Allocation) int { c, ok := p.currentPreemptions[structs.NewNamespacedID(alloc.JobID, alloc.Namespace)][alloc.TaskGroup] if !ok { return 0 } return c }
[ "func", "(", "p", "*", "Preemptor", ")", "getNumPreemptions", "(", "alloc", "*", "structs", ".", "Allocation", ")", "int", "{", "c", ",", "ok", ":=", "p", ".", "currentPreemptions", "[", "structs", ".", "NewNamespacedID", "(", "alloc", ".", "JobID", ",",...
// getNumPreemptions counts the number of other allocations being preempted that match the job and task group of // the alloc under consideration. This is used as a scoring factor to minimize too many allocs of the same job being preempted at once
[ "getNumPreemptions", "counts", "the", "number", "of", "other", "allocations", "being", "preempted", "that", "match", "the", "job", "and", "task", "group", "of", "the", "alloc", "under", "consideration", ".", "This", "is", "used", "as", "a", "scoring", "factor"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L187-L193
132,235
hashicorp/nomad
scheduler/preemption.go
PreemptForDevice
func (p *Preemptor) PreemptForDevice(ask *structs.RequestedDevice, devAlloc *deviceAllocator) []*structs.Allocation { // Group allocations by device, tracking the number of // instances used in each device by alloc id deviceToAllocs := make(map[structs.DeviceIdTuple]*deviceGroupAllocs) for _, alloc := range p.curr...
go
func (p *Preemptor) PreemptForDevice(ask *structs.RequestedDevice, devAlloc *deviceAllocator) []*structs.Allocation { // Group allocations by device, tracking the number of // instances used in each device by alloc id deviceToAllocs := make(map[structs.DeviceIdTuple]*deviceGroupAllocs) for _, alloc := range p.curr...
[ "func", "(", "p", "*", "Preemptor", ")", "PreemptForDevice", "(", "ask", "*", "structs", ".", "RequestedDevice", ",", "devAlloc", "*", "deviceAllocator", ")", "[", "]", "*", "structs", ".", "Allocation", "{", "// Group allocations by device, tracking the number of",...
// PreemptForDevice tries to find allocations to preempt to meet devices needed // This is called once per device request when assigning devices to the task
[ "PreemptForDevice", "tries", "to", "find", "allocations", "to", "preempt", "to", "meet", "devices", "needed", "This", "is", "called", "once", "per", "device", "request", "when", "assigning", "devices", "to", "the", "task" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L470-L553
132,236
hashicorp/nomad
scheduler/preemption.go
selectBestAllocs
func selectBestAllocs(preemptionOptions []*deviceGroupAllocs, neededCount int) []*structs.Allocation { bestPriority := math.MaxInt32 var bestAllocs []*structs.Allocation // We iterate over allocations in priority order, so its possible // that we have more allocations than needed to meet the needed count. // e.g ...
go
func selectBestAllocs(preemptionOptions []*deviceGroupAllocs, neededCount int) []*structs.Allocation { bestPriority := math.MaxInt32 var bestAllocs []*structs.Allocation // We iterate over allocations in priority order, so its possible // that we have more allocations than needed to meet the needed count. // e.g ...
[ "func", "selectBestAllocs", "(", "preemptionOptions", "[", "]", "*", "deviceGroupAllocs", ",", "neededCount", "int", ")", "[", "]", "*", "structs", ".", "Allocation", "{", "bestPriority", ":=", "math", ".", "MaxInt32", "\n", "var", "bestAllocs", "[", "]", "*...
// selectBestAllocs finds the best allocations based on minimal net priority amongst // all options. The net priority is the sum of unique priorities in each option
[ "selectBestAllocs", "finds", "the", "best", "allocations", "based", "on", "minimal", "net", "priority", "amongst", "all", "options", ".", "The", "net", "priority", "is", "the", "sum", "of", "unique", "priorities", "in", "each", "option" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L557-L602
132,237
hashicorp/nomad
scheduler/preemption.go
networkResourceDistance
func networkResourceDistance(resourceUsed *structs.NetworkResource, resourceNeeded *structs.NetworkResource) float64 { networkCoord := math.MaxFloat64 if resourceUsed != nil && resourceNeeded != nil { networkCoord = float64(resourceNeeded.MBits-resourceUsed.MBits) / float64(resourceNeeded.MBits) } originDist := ...
go
func networkResourceDistance(resourceUsed *structs.NetworkResource, resourceNeeded *structs.NetworkResource) float64 { networkCoord := math.MaxFloat64 if resourceUsed != nil && resourceNeeded != nil { networkCoord = float64(resourceNeeded.MBits-resourceUsed.MBits) / float64(resourceNeeded.MBits) } originDist := ...
[ "func", "networkResourceDistance", "(", "resourceUsed", "*", "structs", ".", "NetworkResource", ",", "resourceNeeded", "*", "structs", ".", "NetworkResource", ")", "float64", "{", "networkCoord", ":=", "math", ".", "MaxFloat64", "\n", "if", "resourceUsed", "!=", "...
// networkResourceDistance returns a distance based only on network megabits
[ "networkResourceDistance", "returns", "a", "distance", "based", "only", "on", "network", "megabits" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L625-L633
132,238
hashicorp/nomad
scheduler/preemption.go
scoreForNetwork
func scoreForNetwork(resourceUsed *structs.NetworkResource, resourceNeeded *structs.NetworkResource, maxParallel int, numPreemptedAllocs int) float64 { if resourceUsed == nil || resourceNeeded == nil { return math.MaxFloat64 } maxParallelScorePenalty := 0.0 if maxParallel > 0 && numPreemptedAllocs >= maxParallel ...
go
func scoreForNetwork(resourceUsed *structs.NetworkResource, resourceNeeded *structs.NetworkResource, maxParallel int, numPreemptedAllocs int) float64 { if resourceUsed == nil || resourceNeeded == nil { return math.MaxFloat64 } maxParallelScorePenalty := 0.0 if maxParallel > 0 && numPreemptedAllocs >= maxParallel ...
[ "func", "scoreForNetwork", "(", "resourceUsed", "*", "structs", ".", "NetworkResource", ",", "resourceNeeded", "*", "structs", ".", "NetworkResource", ",", "maxParallel", "int", ",", "numPreemptedAllocs", "int", ")", "float64", "{", "if", "resourceUsed", "==", "ni...
// scoreForNetwork is similar to scoreForTaskGroup // but only uses network Mbits to calculate a preemption score
[ "scoreForNetwork", "is", "similar", "to", "scoreForTaskGroup", "but", "only", "uses", "network", "Mbits", "to", "calculate", "a", "preemption", "score" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L648-L657
132,239
hashicorp/nomad
scheduler/preemption.go
filterAndGroupPreemptibleAllocs
func filterAndGroupPreemptibleAllocs(jobPriority int, current []*structs.Allocation) []*groupedAllocs { allocsByPriority := make(map[int][]*structs.Allocation) for _, alloc := range current { if alloc.Job == nil { continue } // Skip allocs whose priority is within a delta of 10 // This also skips any allo...
go
func filterAndGroupPreemptibleAllocs(jobPriority int, current []*structs.Allocation) []*groupedAllocs { allocsByPriority := make(map[int][]*structs.Allocation) for _, alloc := range current { if alloc.Job == nil { continue } // Skip allocs whose priority is within a delta of 10 // This also skips any allo...
[ "func", "filterAndGroupPreemptibleAllocs", "(", "jobPriority", "int", ",", "current", "[", "]", "*", "structs", ".", "Allocation", ")", "[", "]", "*", "groupedAllocs", "{", "allocsByPriority", ":=", "make", "(", "map", "[", "int", "]", "[", "]", "*", "stru...
// filterAndGroupPreemptibleAllocs groups allocations by priority after filtering allocs // that are not preemptible based on the jobPriority arg
[ "filterAndGroupPreemptibleAllocs", "groups", "allocations", "by", "priority", "after", "filtering", "allocs", "that", "are", "not", "preemptible", "based", "on", "the", "jobPriority", "arg" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L661-L695
132,240
hashicorp/nomad
scheduler/preemption.go
filterSuperset
func (p *Preemptor) filterSuperset(bestAllocs []*structs.Allocation, nodeRemainingResources *structs.ComparableResources, resourceAsk *structs.ComparableResources, preemptionResourceFactory PreemptionResourceFactory) []*structs.Allocation { // Sort bestAllocs by distance descending (without penalty) sort.Slice(be...
go
func (p *Preemptor) filterSuperset(bestAllocs []*structs.Allocation, nodeRemainingResources *structs.ComparableResources, resourceAsk *structs.ComparableResources, preemptionResourceFactory PreemptionResourceFactory) []*structs.Allocation { // Sort bestAllocs by distance descending (without penalty) sort.Slice(be...
[ "func", "(", "p", "*", "Preemptor", ")", "filterSuperset", "(", "bestAllocs", "[", "]", "*", "structs", ".", "Allocation", ",", "nodeRemainingResources", "*", "structs", ".", "ComparableResources", ",", "resourceAsk", "*", "structs", ".", "ComparableResources", ...
// filterSuperset is used as a final step to remove // any allocations that meet a superset of requirements from // the set of allocations to preempt
[ "filterSuperset", "is", "used", "as", "a", "final", "step", "to", "remove", "any", "allocations", "that", "meet", "a", "superset", "of", "requirements", "from", "the", "set", "of", "allocations", "to", "preempt" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L700-L731
132,241
hashicorp/nomad
scheduler/preemption.go
distanceComparatorForNetwork
func (p *Preemptor) distanceComparatorForNetwork(allocs []*structs.Allocation, networkResourceAsk *structs.NetworkResource, i int, j int) bool { firstAlloc := allocs[i] currentPreemptionCount1 := p.getNumPreemptions(firstAlloc) // Look up configured maxParallel value for these allocation's task groups var maxParal...
go
func (p *Preemptor) distanceComparatorForNetwork(allocs []*structs.Allocation, networkResourceAsk *structs.NetworkResource, i int, j int) bool { firstAlloc := allocs[i] currentPreemptionCount1 := p.getNumPreemptions(firstAlloc) // Look up configured maxParallel value for these allocation's task groups var maxParal...
[ "func", "(", "p", "*", "Preemptor", ")", "distanceComparatorForNetwork", "(", "allocs", "[", "]", "*", "structs", ".", "Allocation", ",", "networkResourceAsk", "*", "structs", ".", "NetworkResource", ",", "i", "int", ",", "j", "int", ")", "bool", "{", "fir...
// distanceComparatorForNetwork is used as the sorting function when finding allocations to preempt. It uses // both a coordinate distance function based on Mbits needed, and a penalty if the allocation under consideration // belongs to a job that already has more preempted allocations
[ "distanceComparatorForNetwork", "is", "used", "as", "the", "sorting", "function", "when", "finding", "allocations", "to", "preempt", ".", "It", "uses", "both", "a", "coordinate", "distance", "function", "based", "on", "Mbits", "needed", "and", "a", "penalty", "i...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/preemption.go#L736-L774
132,242
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceGroups
func convertProtoDeviceGroups(in []*proto.DeviceGroup) []*DeviceGroup { if in == nil { return nil } out := make([]*DeviceGroup, len(in)) for i, group := range in { out[i] = convertProtoDeviceGroup(group) } return out }
go
func convertProtoDeviceGroups(in []*proto.DeviceGroup) []*DeviceGroup { if in == nil { return nil } out := make([]*DeviceGroup, len(in)) for i, group := range in { out[i] = convertProtoDeviceGroup(group) } return out }
[ "func", "convertProtoDeviceGroups", "(", "in", "[", "]", "*", "proto", ".", "DeviceGroup", ")", "[", "]", "*", "DeviceGroup", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "DeviceGroup...
// convertProtoDeviceGroups converts between a list of proto and structs DeviceGroup
[ "convertProtoDeviceGroups", "converts", "between", "a", "list", "of", "proto", "and", "structs", "DeviceGroup" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L10-L21
132,243
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceGroup
func convertProtoDeviceGroup(in *proto.DeviceGroup) *DeviceGroup { if in == nil { return nil } return &DeviceGroup{ Vendor: in.Vendor, Type: in.DeviceType, Name: in.DeviceName, Devices: convertProtoDevices(in.Devices), Attributes: structs.ConvertProtoAttributeMap(in.Attributes), } }
go
func convertProtoDeviceGroup(in *proto.DeviceGroup) *DeviceGroup { if in == nil { return nil } return &DeviceGroup{ Vendor: in.Vendor, Type: in.DeviceType, Name: in.DeviceName, Devices: convertProtoDevices(in.Devices), Attributes: structs.ConvertProtoAttributeMap(in.Attributes), } }
[ "func", "convertProtoDeviceGroup", "(", "in", "*", "proto", ".", "DeviceGroup", ")", "*", "DeviceGroup", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "DeviceGroup", "{", "Vendor", ":", "in", ".", "Vendor", ",", ...
// convertProtoDeviceGroup converts between a proto and structs DeviceGroup
[ "convertProtoDeviceGroup", "converts", "between", "a", "proto", "and", "structs", "DeviceGroup" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L24-L36
132,244
hashicorp/nomad
plugins/device/util.go
convertProtoDevices
func convertProtoDevices(in []*proto.DetectedDevice) []*Device { if in == nil { return nil } out := make([]*Device, len(in)) for i, d := range in { out[i] = convertProtoDevice(d) } return out }
go
func convertProtoDevices(in []*proto.DetectedDevice) []*Device { if in == nil { return nil } out := make([]*Device, len(in)) for i, d := range in { out[i] = convertProtoDevice(d) } return out }
[ "func", "convertProtoDevices", "(", "in", "[", "]", "*", "proto", ".", "DetectedDevice", ")", "[", "]", "*", "Device", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "Device", ",", ...
// convertProtoDevices converts between a list of proto and structs Device
[ "convertProtoDevices", "converts", "between", "a", "list", "of", "proto", "and", "structs", "Device" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L39-L50
132,245
hashicorp/nomad
plugins/device/util.go
convertProtoDevice
func convertProtoDevice(in *proto.DetectedDevice) *Device { if in == nil { return nil } return &Device{ ID: in.ID, Healthy: in.Healthy, HealthDesc: in.HealthDescription, HwLocality: convertProtoDeviceLocality(in.HwLocality), } }
go
func convertProtoDevice(in *proto.DetectedDevice) *Device { if in == nil { return nil } return &Device{ ID: in.ID, Healthy: in.Healthy, HealthDesc: in.HealthDescription, HwLocality: convertProtoDeviceLocality(in.HwLocality), } }
[ "func", "convertProtoDevice", "(", "in", "*", "proto", ".", "DetectedDevice", ")", "*", "Device", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "Device", "{", "ID", ":", "in", ".", "ID", ",", "Healthy", ":", ...
// convertProtoDevice converts between a proto and structs Device
[ "convertProtoDevice", "converts", "between", "a", "proto", "and", "structs", "Device" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L53-L64
132,246
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceLocality
func convertProtoDeviceLocality(in *proto.DeviceLocality) *DeviceLocality { if in == nil { return nil } return &DeviceLocality{ PciBusID: in.PciBusId, } }
go
func convertProtoDeviceLocality(in *proto.DeviceLocality) *DeviceLocality { if in == nil { return nil } return &DeviceLocality{ PciBusID: in.PciBusId, } }
[ "func", "convertProtoDeviceLocality", "(", "in", "*", "proto", ".", "DeviceLocality", ")", "*", "DeviceLocality", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "DeviceLocality", "{", "PciBusID", ":", "in", ".", "PciB...
// convertProtoDeviceLocality converts between a proto and structs DeviceLocality
[ "convertProtoDeviceLocality", "converts", "between", "a", "proto", "and", "structs", "DeviceLocality" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L67-L75
132,247
hashicorp/nomad
plugins/device/util.go
convertProtoContainerReservation
func convertProtoContainerReservation(in *proto.ContainerReservation) *ContainerReservation { if in == nil { return nil } return &ContainerReservation{ Envs: in.Envs, Mounts: convertProtoMounts(in.Mounts), Devices: convertProtoDeviceSpecs(in.Devices), } }
go
func convertProtoContainerReservation(in *proto.ContainerReservation) *ContainerReservation { if in == nil { return nil } return &ContainerReservation{ Envs: in.Envs, Mounts: convertProtoMounts(in.Mounts), Devices: convertProtoDeviceSpecs(in.Devices), } }
[ "func", "convertProtoContainerReservation", "(", "in", "*", "proto", ".", "ContainerReservation", ")", "*", "ContainerReservation", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "ContainerReservation", "{", "Envs", ":", ...
// convertProtoContainerReservation is used to convert between a proto and struct // ContainerReservation
[ "convertProtoContainerReservation", "is", "used", "to", "convert", "between", "a", "proto", "and", "struct", "ContainerReservation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L79-L89
132,248
hashicorp/nomad
plugins/device/util.go
convertProtoMounts
func convertProtoMounts(in []*proto.Mount) []*Mount { if in == nil { return nil } out := make([]*Mount, len(in)) for i, d := range in { out[i] = convertProtoMount(d) } return out }
go
func convertProtoMounts(in []*proto.Mount) []*Mount { if in == nil { return nil } out := make([]*Mount, len(in)) for i, d := range in { out[i] = convertProtoMount(d) } return out }
[ "func", "convertProtoMounts", "(", "in", "[", "]", "*", "proto", ".", "Mount", ")", "[", "]", "*", "Mount", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "Mount", ",", "len", "("...
// convertProtoMount converts between a list of proto and structs Mount
[ "convertProtoMount", "converts", "between", "a", "list", "of", "proto", "and", "structs", "Mount" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L92-L103
132,249
hashicorp/nomad
plugins/device/util.go
convertProtoMount
func convertProtoMount(in *proto.Mount) *Mount { if in == nil { return nil } return &Mount{ TaskPath: in.TaskPath, HostPath: in.HostPath, ReadOnly: in.ReadOnly, } }
go
func convertProtoMount(in *proto.Mount) *Mount { if in == nil { return nil } return &Mount{ TaskPath: in.TaskPath, HostPath: in.HostPath, ReadOnly: in.ReadOnly, } }
[ "func", "convertProtoMount", "(", "in", "*", "proto", ".", "Mount", ")", "*", "Mount", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "Mount", "{", "TaskPath", ":", "in", ".", "TaskPath", ",", "HostPath", ":", ...
// convertProtoMount converts between a proto and structs Mount
[ "convertProtoMount", "converts", "between", "a", "proto", "and", "structs", "Mount" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L106-L116
132,250
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceSpecs
func convertProtoDeviceSpecs(in []*proto.DeviceSpec) []*DeviceSpec { if in == nil { return nil } out := make([]*DeviceSpec, len(in)) for i, d := range in { out[i] = convertProtoDeviceSpec(d) } return out }
go
func convertProtoDeviceSpecs(in []*proto.DeviceSpec) []*DeviceSpec { if in == nil { return nil } out := make([]*DeviceSpec, len(in)) for i, d := range in { out[i] = convertProtoDeviceSpec(d) } return out }
[ "func", "convertProtoDeviceSpecs", "(", "in", "[", "]", "*", "proto", ".", "DeviceSpec", ")", "[", "]", "*", "DeviceSpec", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "DeviceSpec", ...
// convertProtoDeviceSpecs converts between a list of proto and structs DeviceSpecs
[ "convertProtoDeviceSpecs", "converts", "between", "a", "list", "of", "proto", "and", "structs", "DeviceSpecs" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L119-L130
132,251
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceSpec
func convertProtoDeviceSpec(in *proto.DeviceSpec) *DeviceSpec { if in == nil { return nil } return &DeviceSpec{ TaskPath: in.TaskPath, HostPath: in.HostPath, CgroupPerms: in.Permissions, } }
go
func convertProtoDeviceSpec(in *proto.DeviceSpec) *DeviceSpec { if in == nil { return nil } return &DeviceSpec{ TaskPath: in.TaskPath, HostPath: in.HostPath, CgroupPerms: in.Permissions, } }
[ "func", "convertProtoDeviceSpec", "(", "in", "*", "proto", ".", "DeviceSpec", ")", "*", "DeviceSpec", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "DeviceSpec", "{", "TaskPath", ":", "in", ".", "TaskPath", ",", ...
// convertProtoDeviceSpec converts between a proto and structs DeviceSpec
[ "convertProtoDeviceSpec", "converts", "between", "a", "proto", "and", "structs", "DeviceSpec" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L133-L143
132,252
hashicorp/nomad
plugins/device/util.go
convertStructDeviceGroups
func convertStructDeviceGroups(in []*DeviceGroup) []*proto.DeviceGroup { if in == nil { return nil } out := make([]*proto.DeviceGroup, len(in)) for i, g := range in { out[i] = convertStructDeviceGroup(g) } return out }
go
func convertStructDeviceGroups(in []*DeviceGroup) []*proto.DeviceGroup { if in == nil { return nil } out := make([]*proto.DeviceGroup, len(in)) for i, g := range in { out[i] = convertStructDeviceGroup(g) } return out }
[ "func", "convertStructDeviceGroups", "(", "in", "[", "]", "*", "DeviceGroup", ")", "[", "]", "*", "proto", ".", "DeviceGroup", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "proto", ...
// convertStructDeviceGroup converts between a list of struct and proto DeviceGroup
[ "convertStructDeviceGroup", "converts", "between", "a", "list", "of", "struct", "and", "proto", "DeviceGroup" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L146-L157
132,253
hashicorp/nomad
plugins/device/util.go
convertStructDeviceGroup
func convertStructDeviceGroup(in *DeviceGroup) *proto.DeviceGroup { if in == nil { return nil } return &proto.DeviceGroup{ Vendor: in.Vendor, DeviceType: in.Type, DeviceName: in.Name, Devices: convertStructDevices(in.Devices), Attributes: structs.ConvertStructAttributeMap(in.Attributes), } }
go
func convertStructDeviceGroup(in *DeviceGroup) *proto.DeviceGroup { if in == nil { return nil } return &proto.DeviceGroup{ Vendor: in.Vendor, DeviceType: in.Type, DeviceName: in.Name, Devices: convertStructDevices(in.Devices), Attributes: structs.ConvertStructAttributeMap(in.Attributes), } }
[ "func", "convertStructDeviceGroup", "(", "in", "*", "DeviceGroup", ")", "*", "proto", ".", "DeviceGroup", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "proto", ".", "DeviceGroup", "{", "Vendor", ":", "in", ".", ...
// convertStructDeviceGroup converts between a struct and proto DeviceGroup
[ "convertStructDeviceGroup", "converts", "between", "a", "struct", "and", "proto", "DeviceGroup" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L160-L172
132,254
hashicorp/nomad
plugins/device/util.go
convertStructDevices
func convertStructDevices(in []*Device) []*proto.DetectedDevice { if in == nil { return nil } out := make([]*proto.DetectedDevice, len(in)) for i, d := range in { out[i] = convertStructDevice(d) } return out }
go
func convertStructDevices(in []*Device) []*proto.DetectedDevice { if in == nil { return nil } out := make([]*proto.DetectedDevice, len(in)) for i, d := range in { out[i] = convertStructDevice(d) } return out }
[ "func", "convertStructDevices", "(", "in", "[", "]", "*", "Device", ")", "[", "]", "*", "proto", ".", "DetectedDevice", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "proto", ".", ...
// convertStructDevices converts between a list of struct and proto Device
[ "convertStructDevices", "converts", "between", "a", "list", "of", "struct", "and", "proto", "Device" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L175-L186
132,255
hashicorp/nomad
plugins/device/util.go
convertStructDevice
func convertStructDevice(in *Device) *proto.DetectedDevice { if in == nil { return nil } return &proto.DetectedDevice{ ID: in.ID, Healthy: in.Healthy, HealthDescription: in.HealthDesc, HwLocality: convertStructDeviceLocality(in.HwLocality), } }
go
func convertStructDevice(in *Device) *proto.DetectedDevice { if in == nil { return nil } return &proto.DetectedDevice{ ID: in.ID, Healthy: in.Healthy, HealthDescription: in.HealthDesc, HwLocality: convertStructDeviceLocality(in.HwLocality), } }
[ "func", "convertStructDevice", "(", "in", "*", "Device", ")", "*", "proto", ".", "DetectedDevice", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "proto", ".", "DetectedDevice", "{", "ID", ":", "in", ".", "ID", ...
// convertStructDevice converts between a struct and proto Device
[ "convertStructDevice", "converts", "between", "a", "struct", "and", "proto", "Device" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L189-L200
132,256
hashicorp/nomad
plugins/device/util.go
convertStructDeviceLocality
func convertStructDeviceLocality(in *DeviceLocality) *proto.DeviceLocality { if in == nil { return nil } return &proto.DeviceLocality{ PciBusId: in.PciBusID, } }
go
func convertStructDeviceLocality(in *DeviceLocality) *proto.DeviceLocality { if in == nil { return nil } return &proto.DeviceLocality{ PciBusId: in.PciBusID, } }
[ "func", "convertStructDeviceLocality", "(", "in", "*", "DeviceLocality", ")", "*", "proto", ".", "DeviceLocality", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "proto", ".", "DeviceLocality", "{", "PciBusId", ":", "...
// convertStructDeviceLocality converts between a struct and proto DeviceLocality
[ "convertStructDeviceLocality", "converts", "between", "a", "struct", "and", "proto", "DeviceLocality" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L203-L211
132,257
hashicorp/nomad
plugins/device/util.go
convertStructContainerReservation
func convertStructContainerReservation(in *ContainerReservation) *proto.ContainerReservation { if in == nil { return nil } return &proto.ContainerReservation{ Envs: in.Envs, Mounts: convertStructMounts(in.Mounts), Devices: convertStructDeviceSpecs(in.Devices), } }
go
func convertStructContainerReservation(in *ContainerReservation) *proto.ContainerReservation { if in == nil { return nil } return &proto.ContainerReservation{ Envs: in.Envs, Mounts: convertStructMounts(in.Mounts), Devices: convertStructDeviceSpecs(in.Devices), } }
[ "func", "convertStructContainerReservation", "(", "in", "*", "ContainerReservation", ")", "*", "proto", ".", "ContainerReservation", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "proto", ".", "ContainerReservation", "{", ...
// convertStructContainerReservation is used to convert between a struct and // proto ContainerReservation
[ "convertStructContainerReservation", "is", "used", "to", "convert", "between", "a", "struct", "and", "proto", "ContainerReservation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L215-L225
132,258
hashicorp/nomad
plugins/device/util.go
convertStructMounts
func convertStructMounts(in []*Mount) []*proto.Mount { if in == nil { return nil } out := make([]*proto.Mount, len(in)) for i, m := range in { out[i] = convertStructMount(m) } return out }
go
func convertStructMounts(in []*Mount) []*proto.Mount { if in == nil { return nil } out := make([]*proto.Mount, len(in)) for i, m := range in { out[i] = convertStructMount(m) } return out }
[ "func", "convertStructMounts", "(", "in", "[", "]", "*", "Mount", ")", "[", "]", "*", "proto", ".", "Mount", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "proto", ".", "Mount", ...
// convertStructMount converts between a list of structs and proto Mount
[ "convertStructMount", "converts", "between", "a", "list", "of", "structs", "and", "proto", "Mount" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L228-L239
132,259
hashicorp/nomad
plugins/device/util.go
convertStructMount
func convertStructMount(in *Mount) *proto.Mount { if in == nil { return nil } return &proto.Mount{ TaskPath: in.TaskPath, HostPath: in.HostPath, ReadOnly: in.ReadOnly, } }
go
func convertStructMount(in *Mount) *proto.Mount { if in == nil { return nil } return &proto.Mount{ TaskPath: in.TaskPath, HostPath: in.HostPath, ReadOnly: in.ReadOnly, } }
[ "func", "convertStructMount", "(", "in", "*", "Mount", ")", "*", "proto", ".", "Mount", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "proto", ".", "Mount", "{", "TaskPath", ":", "in", ".", "TaskPath", ",", "...
// convertStructMount converts between a struct and proto Mount
[ "convertStructMount", "converts", "between", "a", "struct", "and", "proto", "Mount" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L242-L252
132,260
hashicorp/nomad
plugins/device/util.go
convertStructDeviceSpecs
func convertStructDeviceSpecs(in []*DeviceSpec) []*proto.DeviceSpec { if in == nil { return nil } out := make([]*proto.DeviceSpec, len(in)) for i, d := range in { out[i] = convertStructDeviceSpec(d) } return out }
go
func convertStructDeviceSpecs(in []*DeviceSpec) []*proto.DeviceSpec { if in == nil { return nil } out := make([]*proto.DeviceSpec, len(in)) for i, d := range in { out[i] = convertStructDeviceSpec(d) } return out }
[ "func", "convertStructDeviceSpecs", "(", "in", "[", "]", "*", "DeviceSpec", ")", "[", "]", "*", "proto", ".", "DeviceSpec", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*", "proto", "."...
// convertStructDeviceSpecs converts between a list of struct and proto DeviceSpecs
[ "convertStructDeviceSpecs", "converts", "between", "a", "list", "of", "struct", "and", "proto", "DeviceSpecs" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L255-L266
132,261
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceGroupsStats
func convertProtoDeviceGroupsStats(in []*proto.DeviceGroupStats) []*DeviceGroupStats { if in == nil { return nil } out := make([]*DeviceGroupStats, len(in)) for i, m := range in { out[i] = convertProtoDeviceGroupStats(m) } return out }
go
func convertProtoDeviceGroupsStats(in []*proto.DeviceGroupStats) []*DeviceGroupStats { if in == nil { return nil } out := make([]*DeviceGroupStats, len(in)) for i, m := range in { out[i] = convertProtoDeviceGroupStats(m) } return out }
[ "func", "convertProtoDeviceGroupsStats", "(", "in", "[", "]", "*", "proto", ".", "DeviceGroupStats", ")", "[", "]", "*", "DeviceGroupStats", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*",...
// convertProtoDeviceGroupsStats converts between a list of struct and proto // DeviceGroupStats
[ "convertProtoDeviceGroupsStats", "converts", "between", "a", "list", "of", "struct", "and", "proto", "DeviceGroupStats" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L283-L294
132,262
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceGroupStats
func convertProtoDeviceGroupStats(in *proto.DeviceGroupStats) *DeviceGroupStats { if in == nil { return nil } out := &DeviceGroupStats{ Vendor: in.Vendor, Type: in.Type, Name: in.Name, InstanceStats: make(map[string]*DeviceStats, len(in.InstanceStats)), } for k, v := range in.I...
go
func convertProtoDeviceGroupStats(in *proto.DeviceGroupStats) *DeviceGroupStats { if in == nil { return nil } out := &DeviceGroupStats{ Vendor: in.Vendor, Type: in.Type, Name: in.Name, InstanceStats: make(map[string]*DeviceStats, len(in.InstanceStats)), } for k, v := range in.I...
[ "func", "convertProtoDeviceGroupStats", "(", "in", "*", "proto", ".", "DeviceGroupStats", ")", "*", "DeviceGroupStats", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "&", "DeviceGroupStats", "{", "Vendor", ":", "in", "...
// convertProtoDeviceGroupStats converts between a proto and struct // DeviceGroupStats
[ "convertProtoDeviceGroupStats", "converts", "between", "a", "proto", "and", "struct", "DeviceGroupStats" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L298-L315
132,263
hashicorp/nomad
plugins/device/util.go
convertProtoDeviceStats
func convertProtoDeviceStats(in *proto.DeviceStats) *DeviceStats { if in == nil { return nil } ts, err := ptypes.Timestamp(in.Timestamp) if err != nil { return nil } return &DeviceStats{ Summary: structs.ConvertProtoStatValue(in.Summary), Stats: structs.ConvertProtoStatObject(in.Stats), Timestam...
go
func convertProtoDeviceStats(in *proto.DeviceStats) *DeviceStats { if in == nil { return nil } ts, err := ptypes.Timestamp(in.Timestamp) if err != nil { return nil } return &DeviceStats{ Summary: structs.ConvertProtoStatValue(in.Summary), Stats: structs.ConvertProtoStatObject(in.Stats), Timestam...
[ "func", "convertProtoDeviceStats", "(", "in", "*", "proto", ".", "DeviceStats", ")", "*", "DeviceStats", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "ts", ",", "err", ":=", "ptypes", ".", "Timestamp", "(", "in", ".", "Timesta...
// convertProtoDeviceStats converts between a proto and struct DeviceStats
[ "convertProtoDeviceStats", "converts", "between", "a", "proto", "and", "struct", "DeviceStats" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L318-L333
132,264
hashicorp/nomad
plugins/device/util.go
convertStructDeviceGroupsStats
func convertStructDeviceGroupsStats(in []*DeviceGroupStats) []*proto.DeviceGroupStats { if in == nil { return nil } out := make([]*proto.DeviceGroupStats, len(in)) for i, m := range in { out[i] = convertStructDeviceGroupStats(m) } return out }
go
func convertStructDeviceGroupsStats(in []*DeviceGroupStats) []*proto.DeviceGroupStats { if in == nil { return nil } out := make([]*proto.DeviceGroupStats, len(in)) for i, m := range in { out[i] = convertStructDeviceGroupStats(m) } return out }
[ "func", "convertStructDeviceGroupsStats", "(", "in", "[", "]", "*", "DeviceGroupStats", ")", "[", "]", "*", "proto", ".", "DeviceGroupStats", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "make", "(", "[", "]", "*"...
// convertStructDeviceGroupsStats converts between a list of struct and proto // DeviceGroupStats
[ "convertStructDeviceGroupsStats", "converts", "between", "a", "list", "of", "struct", "and", "proto", "DeviceGroupStats" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L337-L348
132,265
hashicorp/nomad
plugins/device/util.go
convertStructDeviceGroupStats
func convertStructDeviceGroupStats(in *DeviceGroupStats) *proto.DeviceGroupStats { if in == nil { return nil } out := &proto.DeviceGroupStats{ Vendor: in.Vendor, Type: in.Type, Name: in.Name, InstanceStats: make(map[string]*proto.DeviceStats, len(in.InstanceStats)), } for k, v ...
go
func convertStructDeviceGroupStats(in *DeviceGroupStats) *proto.DeviceGroupStats { if in == nil { return nil } out := &proto.DeviceGroupStats{ Vendor: in.Vendor, Type: in.Type, Name: in.Name, InstanceStats: make(map[string]*proto.DeviceStats, len(in.InstanceStats)), } for k, v ...
[ "func", "convertStructDeviceGroupStats", "(", "in", "*", "DeviceGroupStats", ")", "*", "proto", ".", "DeviceGroupStats", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "out", ":=", "&", "proto", ".", "DeviceGroupStats", "{", "Vendor",...
// convertStructDeviceGroupStats converts between a struct and proto // DeviceGroupStats
[ "convertStructDeviceGroupStats", "converts", "between", "a", "struct", "and", "proto", "DeviceGroupStats" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L352-L369
132,266
hashicorp/nomad
plugins/device/util.go
convertStructDeviceStats
func convertStructDeviceStats(in *DeviceStats) *proto.DeviceStats { if in == nil { return nil } ts, err := ptypes.TimestampProto(in.Timestamp) if err != nil { return nil } return &proto.DeviceStats{ Summary: structs.ConvertStructStatValue(in.Summary), Stats: structs.ConvertStructStatObject(in.Stat...
go
func convertStructDeviceStats(in *DeviceStats) *proto.DeviceStats { if in == nil { return nil } ts, err := ptypes.TimestampProto(in.Timestamp) if err != nil { return nil } return &proto.DeviceStats{ Summary: structs.ConvertStructStatValue(in.Summary), Stats: structs.ConvertStructStatObject(in.Stat...
[ "func", "convertStructDeviceStats", "(", "in", "*", "DeviceStats", ")", "*", "proto", ".", "DeviceStats", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "ts", ",", "err", ":=", "ptypes", ".", "TimestampProto", "(", "in", ".", "T...
// convertStructDeviceStats converts between a struct and proto DeviceStats
[ "convertStructDeviceStats", "converts", "between", "a", "struct", "and", "proto", "DeviceStats" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/util.go#L372-L387
132,267
hashicorp/nomad
command/agent/consul/script.go
Exec
func (c *contextExec) Exec(timeout time.Duration, cmd string, args []string) ([]byte, int, error) { resCh := make(chan execResult, 1) // Don't trust the underlying implementation to obey timeout ctx, cancel := context.WithTimeout(c.pctx, timeout) defer cancel() go func() { output, code, err := c.exec.Exec(time...
go
func (c *contextExec) Exec(timeout time.Duration, cmd string, args []string) ([]byte, int, error) { resCh := make(chan execResult, 1) // Don't trust the underlying implementation to obey timeout ctx, cancel := context.WithTimeout(c.pctx, timeout) defer cancel() go func() { output, code, err := c.exec.Exec(time...
[ "func", "(", "c", "*", "contextExec", ")", "Exec", "(", "timeout", "time", ".", "Duration", ",", "cmd", "string", ",", "args", "[", "]", "string", ")", "(", "[", "]", "byte", ",", "int", ",", "error", ")", "{", "resCh", ":=", "make", "(", "chan",...
// Exec a command until the timeout expires, the context is canceled, or the // underlying Exec returns.
[ "Exec", "a", "command", "until", "the", "timeout", "expires", "the", "context", "is", "canceled", "or", "the", "underlying", "Exec", "returns", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/script.go#L46-L67
132,268
hashicorp/nomad
command/agent/consul/script.go
run
func (s *scriptCheck) run() *scriptHandle { ctx, cancel := context.WithCancel(context.Background()) exitCh := make(chan struct{}) // Wrap the original ScriptExecutor in one that obeys context // cancelation. ctxExec := newContextExec(ctx, s.exec) go func() { defer close(exitCh) timer := time.NewTimer(0) d...
go
func (s *scriptCheck) run() *scriptHandle { ctx, cancel := context.WithCancel(context.Background()) exitCh := make(chan struct{}) // Wrap the original ScriptExecutor in one that obeys context // cancelation. ctxExec := newContextExec(ctx, s.exec) go func() { defer close(exitCh) timer := time.NewTimer(0) d...
[ "func", "(", "s", "*", "scriptCheck", ")", "run", "(", ")", "*", "scriptHandle", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "exitCh", ":=", "make", "(", "chan", "struct", "{"...
// run this script check and return its cancel func. If the shutdownCh is // closed the check will be run once more before exiting.
[ "run", "this", "script", "check", "and", "return", "its", "cancel", "func", ".", "If", "the", "shutdownCh", "is", "closed", "the", "check", "will", "be", "run", "once", "more", "before", "exiting", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/script.go#L122-L215
132,269
hashicorp/nomad
nomad/status_endpoint.go
Version
func (s *Status) Version(args *structs.GenericRequest, reply *structs.VersionResponse) error { if done, err := s.srv.forward("Status.Version", args, args, reply); done { return err } conf := s.srv.config reply.Build = conf.Build reply.Versions = map[string]int{ structs.ProtocolVersion: int(conf.ProtocolVersio...
go
func (s *Status) Version(args *structs.GenericRequest, reply *structs.VersionResponse) error { if done, err := s.srv.forward("Status.Version", args, args, reply); done { return err } conf := s.srv.config reply.Build = conf.Build reply.Versions = map[string]int{ structs.ProtocolVersion: int(conf.ProtocolVersio...
[ "func", "(", "s", "*", "Status", ")", "Version", "(", "args", "*", "structs", ".", "GenericRequest", ",", "reply", "*", "structs", ".", "VersionResponse", ")", "error", "{", "if", "done", ",", "err", ":=", "s", ".", "srv", ".", "forward", "(", "\"", ...
// Version is used to allow clients to determine the capabilities // of the server
[ "Version", "is", "used", "to", "allow", "clients", "to", "determine", "the", "capabilities", "of", "the", "server" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/status_endpoint.go#L22-L35
132,270
hashicorp/nomad
nomad/status_endpoint.go
Members
func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error { // Check node read permissions if aclObj, err := s.srv.ResolveToken(args.AuthToken); err != nil { return err } else if aclObj != nil && !aclObj.AllowNodeRead() { return structs.ErrPermissionDenied } serfMember...
go
func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error { // Check node read permissions if aclObj, err := s.srv.ResolveToken(args.AuthToken); err != nil { return err } else if aclObj != nil && !aclObj.AllowNodeRead() { return structs.ErrPermissionDenied } serfMember...
[ "func", "(", "s", "*", "Status", ")", "Members", "(", "args", "*", "structs", ".", "GenericRequest", ",", "reply", "*", "structs", ".", "ServerMembersResponse", ")", "error", "{", "// Check node read permissions", "if", "aclObj", ",", "err", ":=", "s", ".", ...
// Members return the list of servers in a cluster that a particular server is // aware of
[ "Members", "return", "the", "list", "of", "servers", "in", "a", "cluster", "that", "a", "particular", "server", "is", "aware", "of" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/status_endpoint.go#L82-L114
132,271
hashicorp/nomad
nomad/status_endpoint.go
RaftStats
func (s *Status) RaftStats(args struct{}, reply *autopilot.ServerStats) error { stats := s.srv.raft.Stats() var err error reply.LastContact = stats["last_contact"] reply.LastIndex, err = strconv.ParseUint(stats["last_log_index"], 10, 64) if err != nil { return fmt.Errorf("error parsing server's last_log_index v...
go
func (s *Status) RaftStats(args struct{}, reply *autopilot.ServerStats) error { stats := s.srv.raft.Stats() var err error reply.LastContact = stats["last_contact"] reply.LastIndex, err = strconv.ParseUint(stats["last_log_index"], 10, 64) if err != nil { return fmt.Errorf("error parsing server's last_log_index v...
[ "func", "(", "s", "*", "Status", ")", "RaftStats", "(", "args", "struct", "{", "}", ",", "reply", "*", "autopilot", ".", "ServerStats", ")", "error", "{", "stats", ":=", "s", ".", "srv", ".", "raft", ".", "Stats", "(", ")", "\n\n", "var", "err", ...
// Used by Autopilot to query the raft stats of the local server.
[ "Used", "by", "Autopilot", "to", "query", "the", "raft", "stats", "of", "the", "local", "server", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/status_endpoint.go#L117-L132
132,272
hashicorp/nomad
nomad/status_endpoint.go
HasNodeConn
func (s *Status) HasNodeConn(args *structs.NodeSpecificRequest, reply *structs.NodeConnQueryResponse) error { // Validate the args if args.NodeID == "" { return errors.New("Must provide the NodeID") } state, ok := s.srv.getNodeConn(args.NodeID) if ok { reply.Connected = true reply.Established = state.Establ...
go
func (s *Status) HasNodeConn(args *structs.NodeSpecificRequest, reply *structs.NodeConnQueryResponse) error { // Validate the args if args.NodeID == "" { return errors.New("Must provide the NodeID") } state, ok := s.srv.getNodeConn(args.NodeID) if ok { reply.Connected = true reply.Established = state.Establ...
[ "func", "(", "s", "*", "Status", ")", "HasNodeConn", "(", "args", "*", "structs", ".", "NodeSpecificRequest", ",", "reply", "*", "structs", ".", "NodeConnQueryResponse", ")", "error", "{", "// Validate the args", "if", "args", ".", "NodeID", "==", "\"", "\""...
// HasNodeConn returns whether the server has a connection to the requested // Node.
[ "HasNodeConn", "returns", "whether", "the", "server", "has", "a", "connection", "to", "the", "requested", "Node", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/status_endpoint.go#L136-L149
132,273
hashicorp/nomad
scheduler/device.go
newDeviceAllocator
func newDeviceAllocator(ctx Context, n *structs.Node) *deviceAllocator { return &deviceAllocator{ ctx: ctx, DeviceAccounter: structs.NewDeviceAccounter(n), } }
go
func newDeviceAllocator(ctx Context, n *structs.Node) *deviceAllocator { return &deviceAllocator{ ctx: ctx, DeviceAccounter: structs.NewDeviceAccounter(n), } }
[ "func", "newDeviceAllocator", "(", "ctx", "Context", ",", "n", "*", "structs", ".", "Node", ")", "*", "deviceAllocator", "{", "return", "&", "deviceAllocator", "{", "ctx", ":", "ctx", ",", "DeviceAccounter", ":", "structs", ".", "NewDeviceAccounter", "(", "n...
// newDeviceAllocator returns a new device allocator. The node is used to // populate the set of available devices based on what healthy device instances // exist on the node.
[ "newDeviceAllocator", "returns", "a", "new", "device", "allocator", ".", "The", "node", "is", "used", "to", "populate", "the", "set", "of", "available", "devices", "based", "on", "what", "healthy", "device", "instances", "exist", "on", "the", "node", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/device.go#L22-L27
132,274
hashicorp/nomad
scheduler/device.go
AssignDevice
func (d *deviceAllocator) AssignDevice(ask *structs.RequestedDevice) (out *structs.AllocatedDeviceResource, score float64, err error) { // Try to hot path if len(d.Devices) == 0 { return nil, 0.0, fmt.Errorf("no devices available") } if ask.Count == 0 { return nil, 0.0, fmt.Errorf("invalid request of zero devic...
go
func (d *deviceAllocator) AssignDevice(ask *structs.RequestedDevice) (out *structs.AllocatedDeviceResource, score float64, err error) { // Try to hot path if len(d.Devices) == 0 { return nil, 0.0, fmt.Errorf("no devices available") } if ask.Count == 0 { return nil, 0.0, fmt.Errorf("invalid request of zero devic...
[ "func", "(", "d", "*", "deviceAllocator", ")", "AssignDevice", "(", "ask", "*", "structs", ".", "RequestedDevice", ")", "(", "out", "*", "structs", ".", "AllocatedDeviceResource", ",", "score", "float64", ",", "err", "error", ")", "{", "// Try to hot path", ...
// AssignDevice takes a device request and returns an assignment as well as a // score for the assignment. If no assignment could be made, an error is // returned explaining why.
[ "AssignDevice", "takes", "a", "device", "request", "and", "returns", "an", "assignment", "as", "well", "as", "a", "score", "for", "the", "assignment", ".", "If", "no", "assignment", "could", "be", "made", "an", "error", "is", "returned", "explaining", "why",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/scheduler/device.go#L32-L131
132,275
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
newInstanceManager
func newInstanceManager(c *instanceManagerConfig) *instanceManager { ctx, cancel := context.WithCancel(c.Ctx) i := &instanceManager{ logger: c.Logger.With("driver", c.ID.Name), ctx: ctx, cancel: cancel, loader: c.Loader, storeReattach: c.Sto...
go
func newInstanceManager(c *instanceManagerConfig) *instanceManager { ctx, cancel := context.WithCancel(c.Ctx) i := &instanceManager{ logger: c.Logger.With("driver", c.ID.Name), ctx: ctx, cancel: cancel, loader: c.Loader, storeReattach: c.Sto...
[ "func", "newInstanceManager", "(", "c", "*", "instanceManagerConfig", ")", "*", "instanceManager", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "c", ".", "Ctx", ")", "\n", "i", ":=", "&", "instanceManager", "{", "logger", ":", "c", ...
// newInstanceManager returns a new driver instance manager. It is expected that // the context passed in the configuration is cancelled in order to shutdown // launched goroutines.
[ "newInstanceManager", "returns", "a", "new", "driver", "instance", "manager", ".", "It", "is", "expected", "that", "the", "context", "passed", "in", "the", "configuration", "is", "cancelled", "in", "order", "to", "shutdown", "launched", "goroutines", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L115-L134
132,276
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
WaitForFirstFingerprint
func (i *instanceManager) WaitForFirstFingerprint(ctx context.Context) { select { case <-i.ctx.Done(): case <-ctx.Done(): case <-i.firstFingerprintCh: } }
go
func (i *instanceManager) WaitForFirstFingerprint(ctx context.Context) { select { case <-i.ctx.Done(): case <-ctx.Done(): case <-i.firstFingerprintCh: } }
[ "func", "(", "i", "*", "instanceManager", ")", "WaitForFirstFingerprint", "(", "ctx", "context", ".", "Context", ")", "{", "select", "{", "case", "<-", "i", ".", "ctx", ".", "Done", "(", ")", ":", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "c...
// WaitForFirstFingerprint waits until either the plugin fingerprints, the // passed context is done, or the plugin instance manager is shutdown.
[ "WaitForFirstFingerprint", "waits", "until", "either", "the", "plugin", "fingerprints", "the", "passed", "context", "is", "done", "or", "the", "plugin", "instance", "manager", "is", "shutdown", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L138-L144
132,277
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
dispenseFingerprintCh
func (i *instanceManager) dispenseFingerprintCh() (<-chan *drivers.Fingerprint, context.CancelFunc, error) { driver, err := i.dispense() if err != nil { return nil, nil, err } ctx, cancel := context.WithCancel(i.ctx) fingerCh, err := driver.Fingerprint(ctx) if err != nil { cancel() return nil, nil, err } ...
go
func (i *instanceManager) dispenseFingerprintCh() (<-chan *drivers.Fingerprint, context.CancelFunc, error) { driver, err := i.dispense() if err != nil { return nil, nil, err } ctx, cancel := context.WithCancel(i.ctx) fingerCh, err := driver.Fingerprint(ctx) if err != nil { cancel() return nil, nil, err } ...
[ "func", "(", "i", "*", "instanceManager", ")", "dispenseFingerprintCh", "(", ")", "(", "<-", "chan", "*", "drivers", ".", "Fingerprint", ",", "context", ".", "CancelFunc", ",", "error", ")", "{", "driver", ",", "err", ":=", "i", ".", "dispense", "(", "...
// dispenseFingerprintCh dispenses a driver and makes a Fingerprint RPC call // to the driver. The fingerprint chan is returned along with the cancel func // for the context used in the RPC. This cancel func should always be called // when the caller is finished with the channel.
[ "dispenseFingerprintCh", "dispenses", "a", "driver", "and", "makes", "a", "Fingerprint", "RPC", "call", "to", "the", "driver", ".", "The", "fingerprint", "chan", "is", "returned", "along", "with", "the", "cancel", "func", "for", "the", "context", "used", "in",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L259-L273
132,278
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
fingerprint
func (i *instanceManager) fingerprint() { fpChan, cancel, err := i.dispenseFingerprintCh() if err != nil { i.logger.Error("failed to dispense driver plugin", "error", err) } // backoff and retry used if the RPC is closed by the other end var backoff time.Duration var retry int for { if backoff > 0 { sele...
go
func (i *instanceManager) fingerprint() { fpChan, cancel, err := i.dispenseFingerprintCh() if err != nil { i.logger.Error("failed to dispense driver plugin", "error", err) } // backoff and retry used if the RPC is closed by the other end var backoff time.Duration var retry int for { if backoff > 0 { sele...
[ "func", "(", "i", "*", "instanceManager", ")", "fingerprint", "(", ")", "{", "fpChan", ",", "cancel", ",", "err", ":=", "i", ".", "dispenseFingerprintCh", "(", ")", "\n", "if", "err", "!=", "nil", "{", "i", ".", "logger", ".", "Error", "(", "\"", "...
// fingerprint is the main loop for fingerprinting.
[ "fingerprint", "is", "the", "main", "loop", "for", "fingerprinting", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L276-L334
132,279
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
handleFingerprintError
func (i *instanceManager) handleFingerprintError() { di := &structs.DriverInfo{ Healthy: false, HealthDescription: "failed to fingerprint driver", UpdateTime: time.Now(), } i.updateNodeFromDriver(i.id.Name, di) }
go
func (i *instanceManager) handleFingerprintError() { di := &structs.DriverInfo{ Healthy: false, HealthDescription: "failed to fingerprint driver", UpdateTime: time.Now(), } i.updateNodeFromDriver(i.id.Name, di) }
[ "func", "(", "i", "*", "instanceManager", ")", "handleFingerprintError", "(", ")", "{", "di", ":=", "&", "structs", ".", "DriverInfo", "{", "Healthy", ":", "false", ",", "HealthDescription", ":", "\"", "\"", ",", "UpdateTime", ":", "time", ".", "Now", "(...
// handleFingerprintError is called when an error occurred while fingerprinting // and will set the driver to unhealthy
[ "handleFingerprintError", "is", "called", "when", "an", "error", "occurred", "while", "fingerprinting", "and", "will", "set", "the", "driver", "to", "unhealthy" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L338-L345
132,280
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
handleFingerprint
func (i *instanceManager) handleFingerprint(fp *drivers.Fingerprint) { attrs := make(map[string]string, len(fp.Attributes)) for key, attr := range fp.Attributes { attrs[key] = attr.GoString() } di := &structs.DriverInfo{ Attributes: attrs, Detected: fp.Health != drivers.HealthStateUndetected, ...
go
func (i *instanceManager) handleFingerprint(fp *drivers.Fingerprint) { attrs := make(map[string]string, len(fp.Attributes)) for key, attr := range fp.Attributes { attrs[key] = attr.GoString() } di := &structs.DriverInfo{ Attributes: attrs, Detected: fp.Health != drivers.HealthStateUndetected, ...
[ "func", "(", "i", "*", "instanceManager", ")", "handleFingerprint", "(", "fp", "*", "drivers", ".", "Fingerprint", ")", "{", "attrs", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "fp", ".", "Attributes", ")", ")", "\n", "f...
// handleFingerprint updates the node with the current fingerprint status
[ "handleFingerprint", "updates", "the", "node", "with", "the", "current", "fingerprint", "status" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L348-L378
132,281
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
getLastHealth
func (i *instanceManager) getLastHealth() drivers.HealthState { i.lastHealthStateMu.Lock() defer i.lastHealthStateMu.Unlock() return i.lastHealthState }
go
func (i *instanceManager) getLastHealth() drivers.HealthState { i.lastHealthStateMu.Lock() defer i.lastHealthStateMu.Unlock() return i.lastHealthState }
[ "func", "(", "i", "*", "instanceManager", ")", "getLastHealth", "(", ")", "drivers", ".", "HealthState", "{", "i", ".", "lastHealthStateMu", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "lastHealthStateMu", ".", "Unlock", "(", ")", "\n", "return", "i"...
// getLastHealth returns the most recent HealthState from fingerprinting
[ "getLastHealth", "returns", "the", "most", "recent", "HealthState", "from", "fingerprinting" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L381-L385
132,282
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
dispenseTaskEventsCh
func (i *instanceManager) dispenseTaskEventsCh() (<-chan *drivers.TaskEvent, context.CancelFunc, error) { driver, err := i.dispense() if err != nil { return nil, nil, err } ctx, cancel := context.WithCancel(i.ctx) eventsCh, err := driver.TaskEvents(ctx) if err != nil { cancel() return nil, nil, err } re...
go
func (i *instanceManager) dispenseTaskEventsCh() (<-chan *drivers.TaskEvent, context.CancelFunc, error) { driver, err := i.dispense() if err != nil { return nil, nil, err } ctx, cancel := context.WithCancel(i.ctx) eventsCh, err := driver.TaskEvents(ctx) if err != nil { cancel() return nil, nil, err } re...
[ "func", "(", "i", "*", "instanceManager", ")", "dispenseTaskEventsCh", "(", ")", "(", "<-", "chan", "*", "drivers", ".", "TaskEvent", ",", "context", ".", "CancelFunc", ",", "error", ")", "{", "driver", ",", "err", ":=", "i", ".", "dispense", "(", ")",...
// dispenseTaskEventsCh dispenses a driver plugin and makes a TaskEvents RPC. // The TaskEvent chan and cancel func for the RPC is return. The cancel func must // be called by the caller to properly cleanup the context
[ "dispenseTaskEventsCh", "dispenses", "a", "driver", "plugin", "and", "makes", "a", "TaskEvents", "RPC", ".", "The", "TaskEvent", "chan", "and", "cancel", "func", "for", "the", "RPC", "is", "return", ".", "The", "cancel", "func", "must", "be", "called", "by",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L390-L404
132,283
hashicorp/nomad
client/pluginmanager/drivermanager/instance.go
handleEvents
func (i *instanceManager) handleEvents() { eventsCh, cancel, err := i.dispenseTaskEventsCh() if err != nil { i.logger.Error("failed to dispense driver", "error", err) } var backoff time.Duration var retry int for { if backoff > 0 { select { case <-time.After(backoff): case <-i.ctx.Done(): cancel...
go
func (i *instanceManager) handleEvents() { eventsCh, cancel, err := i.dispenseTaskEventsCh() if err != nil { i.logger.Error("failed to dispense driver", "error", err) } var backoff time.Duration var retry int for { if backoff > 0 { select { case <-time.After(backoff): case <-i.ctx.Done(): cancel...
[ "func", "(", "i", "*", "instanceManager", ")", "handleEvents", "(", ")", "{", "eventsCh", ",", "cancel", ",", "err", ":=", "i", ".", "dispenseTaskEventsCh", "(", ")", "\n", "if", "err", "!=", "nil", "{", "i", ".", "logger", ".", "Error", "(", "\"", ...
// handleEvents is the main loop that receives task events from the driver
[ "handleEvents", "is", "the", "main", "loop", "that", "receives", "task", "events", "from", "the", "driver" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/instance.go#L407-L457
132,284
hashicorp/nomad
devices/gpu/nvidia/fingerprint.go
writeFingerprintToChannel
func (d *NvidiaDevice) writeFingerprintToChannel(devices chan<- *device.FingerprintResponse) { fingerprintData, err := d.nvmlClient.GetFingerprintData() if err != nil { d.logger.Error("failed to get fingerprint nvidia devices", "error", err) devices <- device.NewFingerprintError(err) return } // ignore devic...
go
func (d *NvidiaDevice) writeFingerprintToChannel(devices chan<- *device.FingerprintResponse) { fingerprintData, err := d.nvmlClient.GetFingerprintData() if err != nil { d.logger.Error("failed to get fingerprint nvidia devices", "error", err) devices <- device.NewFingerprintError(err) return } // ignore devic...
[ "func", "(", "d", "*", "NvidiaDevice", ")", "writeFingerprintToChannel", "(", "devices", "chan", "<-", "*", "device", ".", "FingerprintResponse", ")", "{", "fingerprintData", ",", "err", ":=", "d", ".", "nvmlClient", ".", "GetFingerprintData", "(", ")", "\n", ...
// writeFingerprintToChannel makes nvml call and writes response to channel
[ "writeFingerprintToChannel", "makes", "nvml", "call", "and", "writes", "response", "to", "channel" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/fingerprint.go#L56-L97
132,285
hashicorp/nomad
devices/gpu/nvidia/fingerprint.go
ignoreFingerprintedDevices
func ignoreFingerprintedDevices(deviceData []*nvml.FingerprintDeviceData, ignoredGPUIDs map[string]struct{}) []*nvml.FingerprintDeviceData { var result []*nvml.FingerprintDeviceData for _, fingerprintDevice := range deviceData { if _, ignored := ignoredGPUIDs[fingerprintDevice.UUID]; !ignored { result = append(r...
go
func ignoreFingerprintedDevices(deviceData []*nvml.FingerprintDeviceData, ignoredGPUIDs map[string]struct{}) []*nvml.FingerprintDeviceData { var result []*nvml.FingerprintDeviceData for _, fingerprintDevice := range deviceData { if _, ignored := ignoredGPUIDs[fingerprintDevice.UUID]; !ignored { result = append(r...
[ "func", "ignoreFingerprintedDevices", "(", "deviceData", "[", "]", "*", "nvml", ".", "FingerprintDeviceData", ",", "ignoredGPUIDs", "map", "[", "string", "]", "struct", "{", "}", ")", "[", "]", "*", "nvml", ".", "FingerprintDeviceData", "{", "var", "result", ...
// ignoreFingerprintedDevices excludes ignored devices from fingerprint output
[ "ignoreFingerprintedDevices", "excludes", "ignored", "devices", "from", "fingerprint", "output" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/fingerprint.go#L100-L108
132,286
hashicorp/nomad
devices/gpu/nvidia/fingerprint.go
fingerprintChanged
func (d *NvidiaDevice) fingerprintChanged(allDevices []*nvml.FingerprintDeviceData) bool { d.deviceLock.Lock() defer d.deviceLock.Unlock() changeDetected := false // check if every device in allDevices is in d.devices for _, device := range allDevices { if _, ok := d.devices[device.UUID]; !ok { changeDetecte...
go
func (d *NvidiaDevice) fingerprintChanged(allDevices []*nvml.FingerprintDeviceData) bool { d.deviceLock.Lock() defer d.deviceLock.Unlock() changeDetected := false // check if every device in allDevices is in d.devices for _, device := range allDevices { if _, ok := d.devices[device.UUID]; !ok { changeDetecte...
[ "func", "(", "d", "*", "NvidiaDevice", ")", "fingerprintChanged", "(", "allDevices", "[", "]", "*", "nvml", ".", "FingerprintDeviceData", ")", "bool", "{", "d", ".", "deviceLock", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "deviceLock", ".", "Unlock...
// fingerprintChanged checks if there are any previously unseen nvidia devices located // or any of fingerprinted nvidia devices disappeared since the last fingerprint run. // Also, this func updates device map on NvidiaDevice with the latest data
[ "fingerprintChanged", "checks", "if", "there", "are", "any", "previously", "unseen", "nvidia", "devices", "located", "or", "any", "of", "fingerprinted", "nvidia", "devices", "disappeared", "since", "the", "last", "fingerprint", "run", ".", "Also", "this", "func", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/fingerprint.go#L113-L138
132,287
hashicorp/nomad
devices/gpu/nvidia/fingerprint.go
deviceGroupFromFingerprintData
func deviceGroupFromFingerprintData(groupName string, deviceList []*nvml.FingerprintDeviceData, commonAttributes map[string]*structs.Attribute) *device.DeviceGroup { // deviceGroup without devices makes no sense -> return nil when no devices are provided if len(deviceList) == 0 { return nil } devices := make([]*...
go
func deviceGroupFromFingerprintData(groupName string, deviceList []*nvml.FingerprintDeviceData, commonAttributes map[string]*structs.Attribute) *device.DeviceGroup { // deviceGroup without devices makes no sense -> return nil when no devices are provided if len(deviceList) == 0 { return nil } devices := make([]*...
[ "func", "deviceGroupFromFingerprintData", "(", "groupName", "string", ",", "deviceList", "[", "]", "*", "nvml", ".", "FingerprintDeviceData", ",", "commonAttributes", "map", "[", "string", "]", "*", "structs", ".", "Attribute", ")", "*", "device", ".", "DeviceGr...
// deviceGroupFromFingerprintData composes deviceGroup from FingerprintDeviceData slice
[ "deviceGroupFromFingerprintData", "composes", "deviceGroup", "from", "FingerprintDeviceData", "slice" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/fingerprint.go#L141-L176
132,288
hashicorp/nomad
nomad/structs/structs.go
NewNamespacedID
func NewNamespacedID(id, ns string) NamespacedID { return NamespacedID{ ID: id, Namespace: ns, } }
go
func NewNamespacedID(id, ns string) NamespacedID { return NamespacedID{ ID: id, Namespace: ns, } }
[ "func", "NewNamespacedID", "(", "id", ",", "ns", "string", ")", "NamespacedID", "{", "return", "NamespacedID", "{", "ID", ":", "id", ",", "Namespace", ":", "ns", ",", "}", "\n", "}" ]
// NewNamespacedID returns a new namespaced ID given the ID and namespace
[ "NewNamespacedID", "returns", "a", "new", "namespaced", "ID", "given", "the", "ID", "and", "namespace" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L169-L174
132,289
hashicorp/nomad
nomad/structs/structs.go
GetWaitIndex
func (e *EvalDequeueResponse) GetWaitIndex() uint64 { // Prefer the wait index sent. This will be populated on all responses from // 0.7.0 and above if e.WaitIndex != 0 { return e.WaitIndex } else if e.Eval != nil { return e.Eval.ModifyIndex } // This should never happen return 1 }
go
func (e *EvalDequeueResponse) GetWaitIndex() uint64 { // Prefer the wait index sent. This will be populated on all responses from // 0.7.0 and above if e.WaitIndex != 0 { return e.WaitIndex } else if e.Eval != nil { return e.Eval.ModifyIndex } // This should never happen return 1 }
[ "func", "(", "e", "*", "EvalDequeueResponse", ")", "GetWaitIndex", "(", ")", "uint64", "{", "// Prefer the wait index sent. This will be populated on all responses from", "// 0.7.0 and above", "if", "e", ".", "WaitIndex", "!=", "0", "{", "return", "e", ".", "WaitIndex",...
// GetWaitIndex is used to retrieve the Raft index in which state should be at // or beyond before invoking the scheduler.
[ "GetWaitIndex", "is", "used", "to", "retrieve", "the", "Raft", "index", "in", "which", "state", "should", "be", "at", "or", "beyond", "before", "invoking", "the", "scheduler", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1195-L1206
132,290
hashicorp/nomad
nomad/structs/structs.go
SetMessage
func (ne *NodeEvent) SetMessage(msg string) *NodeEvent { ne.Message = msg return ne }
go
func (ne *NodeEvent) SetMessage(msg string) *NodeEvent { ne.Message = msg return ne }
[ "func", "(", "ne", "*", "NodeEvent", ")", "SetMessage", "(", "msg", "string", ")", "*", "NodeEvent", "{", "ne", ".", "Message", "=", "msg", "\n", "return", "ne", "\n", "}" ]
// SetMessage is used to set the message on the node event
[ "SetMessage", "is", "used", "to", "set", "the", "message", "on", "the", "node", "event" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1328-L1331
132,291
hashicorp/nomad
nomad/structs/structs.go
SetSubsystem
func (ne *NodeEvent) SetSubsystem(sys string) *NodeEvent { ne.Subsystem = sys return ne }
go
func (ne *NodeEvent) SetSubsystem(sys string) *NodeEvent { ne.Subsystem = sys return ne }
[ "func", "(", "ne", "*", "NodeEvent", ")", "SetSubsystem", "(", "sys", "string", ")", "*", "NodeEvent", "{", "ne", ".", "Subsystem", "=", "sys", "\n", "return", "ne", "\n", "}" ]
// SetSubsystem is used to set the subsystem on the node event
[ "SetSubsystem", "is", "used", "to", "set", "the", "subsystem", "on", "the", "node", "event" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1334-L1337
132,292
hashicorp/nomad
nomad/structs/structs.go
SetTimestamp
func (ne *NodeEvent) SetTimestamp(ts time.Time) *NodeEvent { ne.Timestamp = ts return ne }
go
func (ne *NodeEvent) SetTimestamp(ts time.Time) *NodeEvent { ne.Timestamp = ts return ne }
[ "func", "(", "ne", "*", "NodeEvent", ")", "SetTimestamp", "(", "ts", "time", ".", "Time", ")", "*", "NodeEvent", "{", "ne", ".", "Timestamp", "=", "ts", "\n", "return", "ne", "\n", "}" ]
// SetTimestamp is used to set the timestamp on the node event
[ "SetTimestamp", "is", "used", "to", "set", "the", "timestamp", "on", "the", "node", "event" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1340-L1343
132,293
hashicorp/nomad
nomad/structs/structs.go
AddDetail
func (ne *NodeEvent) AddDetail(k, v string) *NodeEvent { if ne.Details == nil { ne.Details = make(map[string]string, 1) } ne.Details[k] = v return ne }
go
func (ne *NodeEvent) AddDetail(k, v string) *NodeEvent { if ne.Details == nil { ne.Details = make(map[string]string, 1) } ne.Details[k] = v return ne }
[ "func", "(", "ne", "*", "NodeEvent", ")", "AddDetail", "(", "k", ",", "v", "string", ")", "*", "NodeEvent", "{", "if", "ne", ".", "Details", "==", "nil", "{", "ne", ".", "Details", "=", "make", "(", "map", "[", "string", "]", "string", ",", "1", ...
// AddDetail is used to add a detail to the node event
[ "AddDetail", "is", "used", "to", "add", "a", "detail", "to", "the", "node", "event" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1346-L1352
132,294
hashicorp/nomad
nomad/structs/structs.go
ShouldDrainNode
func ShouldDrainNode(status string) bool { switch status { case NodeStatusInit, NodeStatusReady: return false case NodeStatusDown: return true default: panic(fmt.Sprintf("unhandled node status %s", status)) } }
go
func ShouldDrainNode(status string) bool { switch status { case NodeStatusInit, NodeStatusReady: return false case NodeStatusDown: return true default: panic(fmt.Sprintf("unhandled node status %s", status)) } }
[ "func", "ShouldDrainNode", "(", "status", "string", ")", "bool", "{", "switch", "status", "{", "case", "NodeStatusInit", ",", "NodeStatusReady", ":", "return", "false", "\n", "case", "NodeStatusDown", ":", "return", "true", "\n", "default", ":", "panic", "(", ...
// ShouldDrainNode checks if a given node status should trigger an // evaluation. Some states don't require any further action.
[ "ShouldDrainNode", "checks", "if", "a", "given", "node", "status", "should", "trigger", "an", "evaluation", ".", "Some", "states", "don", "t", "require", "any", "further", "action", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1362-L1371
132,295
hashicorp/nomad
nomad/structs/structs.go
ValidNodeStatus
func ValidNodeStatus(status string) bool { switch status { case NodeStatusInit, NodeStatusReady, NodeStatusDown: return true default: return false } }
go
func ValidNodeStatus(status string) bool { switch status { case NodeStatusInit, NodeStatusReady, NodeStatusDown: return true default: return false } }
[ "func", "ValidNodeStatus", "(", "status", "string", ")", "bool", "{", "switch", "status", "{", "case", "NodeStatusInit", ",", "NodeStatusReady", ",", "NodeStatusDown", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
// ValidNodeStatus is used to check if a node status is valid
[ "ValidNodeStatus", "is", "used", "to", "check", "if", "a", "node", "status", "is", "valid" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1374-L1381
132,296
hashicorp/nomad
nomad/structs/structs.go
DeadlineTime
func (d *DrainStrategy) DeadlineTime() (infinite bool, deadline time.Time) { // Treat the nil case as a force drain so during an upgrade where a node may // not have a drain strategy but has Drain set to true, it is treated as a // force to mimick old behavior. if d == nil { return false, time.Time{} } ns := d...
go
func (d *DrainStrategy) DeadlineTime() (infinite bool, deadline time.Time) { // Treat the nil case as a force drain so during an upgrade where a node may // not have a drain strategy but has Drain set to true, it is treated as a // force to mimick old behavior. if d == nil { return false, time.Time{} } ns := d...
[ "func", "(", "d", "*", "DrainStrategy", ")", "DeadlineTime", "(", ")", "(", "infinite", "bool", ",", "deadline", "time", ".", "Time", ")", "{", "// Treat the nil case as a force drain so during an upgrade where a node may", "// not have a drain strategy but has Drain set to t...
// DeadlineTime returns a boolean whether the drain strategy allows an infinite // duration or otherwise the deadline time. The force drain is captured by the // deadline time being in the past.
[ "DeadlineTime", "returns", "a", "boolean", "whether", "the", "drain", "strategy", "allows", "an", "infinite", "duration", "or", "otherwise", "the", "deadline", "time", ".", "The", "force", "drain", "is", "captured", "by", "the", "deadline", "time", "being", "i...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1425-L1442
132,297
hashicorp/nomad
nomad/structs/structs.go
Ready
func (n *Node) Ready() bool { // Drain is checked directly to support pre-0.8 Node data return n.Status == NodeStatusReady && !n.Drain && n.SchedulingEligibility == NodeSchedulingEligible }
go
func (n *Node) Ready() bool { // Drain is checked directly to support pre-0.8 Node data return n.Status == NodeStatusReady && !n.Drain && n.SchedulingEligibility == NodeSchedulingEligible }
[ "func", "(", "n", "*", "Node", ")", "Ready", "(", ")", "bool", "{", "// Drain is checked directly to support pre-0.8 Node data", "return", "n", ".", "Status", "==", "NodeStatusReady", "&&", "!", "n", ".", "Drain", "&&", "n", ".", "SchedulingEligibility", "==", ...
// Ready returns true if the node is ready for running allocations
[ "Ready", "returns", "true", "if", "the", "node", "is", "ready", "for", "running", "allocations" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1570-L1573
132,298
hashicorp/nomad
nomad/structs/structs.go
copyNodeEvents
func copyNodeEvents(events []*NodeEvent) []*NodeEvent { l := len(events) if l == 0 { return nil } c := make([]*NodeEvent, l) for i, event := range events { c[i] = event.Copy() } return c }
go
func copyNodeEvents(events []*NodeEvent) []*NodeEvent { l := len(events) if l == 0 { return nil } c := make([]*NodeEvent, l) for i, event := range events { c[i] = event.Copy() } return c }
[ "func", "copyNodeEvents", "(", "events", "[", "]", "*", "NodeEvent", ")", "[", "]", "*", "NodeEvent", "{", "l", ":=", "len", "(", "events", ")", "\n", "if", "l", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "c", ":=", "make", "(", "[", "...
// copyNodeEvents is a helper to copy a list of NodeEvent's
[ "copyNodeEvents", "is", "a", "helper", "to", "copy", "a", "list", "of", "NodeEvent", "s" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1612-L1623
132,299
hashicorp/nomad
nomad/structs/structs.go
copyNodeDrivers
func copyNodeDrivers(drivers map[string]*DriverInfo) map[string]*DriverInfo { l := len(drivers) if l == 0 { return nil } c := make(map[string]*DriverInfo, l) for driver, info := range drivers { c[driver] = info.Copy() } return c }
go
func copyNodeDrivers(drivers map[string]*DriverInfo) map[string]*DriverInfo { l := len(drivers) if l == 0 { return nil } c := make(map[string]*DriverInfo, l) for driver, info := range drivers { c[driver] = info.Copy() } return c }
[ "func", "copyNodeDrivers", "(", "drivers", "map", "[", "string", "]", "*", "DriverInfo", ")", "map", "[", "string", "]", "*", "DriverInfo", "{", "l", ":=", "len", "(", "drivers", ")", "\n", "if", "l", "==", "0", "{", "return", "nil", "\n", "}", "\n...
// copyNodeDrivers is a helper to copy a map of DriverInfo
[ "copyNodeDrivers", "is", "a", "helper", "to", "copy", "a", "map", "of", "DriverInfo" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/structs.go#L1626-L1637