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,800
hashicorp/nomad
nomad/drainer/watch_nodes.go
Remove
func (n *NodeDrainer) Remove(nodeID string) { n.l.Lock() defer n.l.Unlock() // TODO test the notifier is updated // Remove it from being tracked and remove it from the dealiner delete(n.nodes, nodeID) n.deadlineNotifier.Remove(nodeID) }
go
func (n *NodeDrainer) Remove(nodeID string) { n.l.Lock() defer n.l.Unlock() // TODO test the notifier is updated // Remove it from being tracked and remove it from the dealiner delete(n.nodes, nodeID) n.deadlineNotifier.Remove(nodeID) }
[ "func", "(", "n", "*", "NodeDrainer", ")", "Remove", "(", "nodeID", "string", ")", "{", "n", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "n", ".", "l", ".", "Unlock", "(", ")", "\n\n", "// TODO test the notifier is updated", "// Remove it from being tr...
// Remove removes the given node from being tracked
[ "Remove", "removes", "the", "given", "node", "from", "being", "tracked" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L32-L40
132,801
hashicorp/nomad
nomad/drainer/watch_nodes.go
Update
func (n *NodeDrainer) Update(node *structs.Node) { n.l.Lock() defer n.l.Unlock() if node == nil { return } draining, ok := n.nodes[node.ID] if !ok { draining = NewDrainingNode(node, n.state) n.nodes[node.ID] = draining } else { // Update it draining.Update(node) } // TODO test the notifier is upda...
go
func (n *NodeDrainer) Update(node *structs.Node) { n.l.Lock() defer n.l.Unlock() if node == nil { return } draining, ok := n.nodes[node.ID] if !ok { draining = NewDrainingNode(node, n.state) n.nodes[node.ID] = draining } else { // Update it draining.Update(node) } // TODO test the notifier is upda...
[ "func", "(", "n", "*", "NodeDrainer", ")", "Update", "(", "node", "*", "structs", ".", "Node", ")", "{", "n", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "n", ".", "l", ".", "Unlock", "(", ")", "\n\n", "if", "node", "==", "nil", "{", "ret...
// Update updates the node, either updating the tracked version or starting to // track the node.
[ "Update", "updates", "the", "node", "either", "updating", "the", "tracked", "version", "or", "starting", "to", "track", "the", "node", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L44-L116
132,802
hashicorp/nomad
nomad/drainer/watch_nodes.go
NewNodeDrainWatcher
func NewNodeDrainWatcher(ctx context.Context, limiter *rate.Limiter, state *state.StateStore, logger log.Logger, tracker NodeTracker) *nodeDrainWatcher { w := &nodeDrainWatcher{ ctx: ctx, limiter: limiter, logger: logger.Named("node_watcher"), tracker: tracker, state: state, } go w.watch() return ...
go
func NewNodeDrainWatcher(ctx context.Context, limiter *rate.Limiter, state *state.StateStore, logger log.Logger, tracker NodeTracker) *nodeDrainWatcher { w := &nodeDrainWatcher{ ctx: ctx, limiter: limiter, logger: logger.Named("node_watcher"), tracker: tracker, state: state, } go w.watch() return ...
[ "func", "NewNodeDrainWatcher", "(", "ctx", "context", ".", "Context", ",", "limiter", "*", "rate", ".", "Limiter", ",", "state", "*", "state", ".", "StateStore", ",", "logger", "log", ".", "Logger", ",", "tracker", "NodeTracker", ")", "*", "nodeDrainWatcher"...
// NewNodeDrainWatcher returns a new node drain watcher.
[ "NewNodeDrainWatcher", "returns", "a", "new", "node", "drain", "watcher", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L136-L147
132,803
hashicorp/nomad
nomad/drainer/watch_nodes.go
watch
func (w *nodeDrainWatcher) watch() { nindex := uint64(1) for { w.logger.Trace("getting nodes at index", "index", nindex) nodes, index, err := w.getNodes(nindex) w.logger.Trace("got nodes at index", "num_nodes", len(nodes), "index", nindex, "error", err) if err != nil { if err == context.Canceled { w.lo...
go
func (w *nodeDrainWatcher) watch() { nindex := uint64(1) for { w.logger.Trace("getting nodes at index", "index", nindex) nodes, index, err := w.getNodes(nindex) w.logger.Trace("got nodes at index", "num_nodes", len(nodes), "index", nindex, "error", err) if err != nil { if err == context.Canceled { w.lo...
[ "func", "(", "w", "*", "nodeDrainWatcher", ")", "watch", "(", ")", "{", "nindex", ":=", "uint64", "(", "1", ")", "\n", "for", "{", "w", ".", "logger", ".", "Trace", "(", "\"", "\"", ",", "\"", "\"", ",", "nindex", ")", "\n", "nodes", ",", "inde...
// watch is the long lived watching routine that detects node changes.
[ "watch", "is", "the", "long", "lived", "watching", "routine", "that", "detects", "node", "changes", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L150-L209
132,804
hashicorp/nomad
nomad/drainer/watch_nodes.go
getNodes
func (w *nodeDrainWatcher) getNodes(minIndex uint64) (map[string]*structs.Node, uint64, error) { if err := w.limiter.Wait(w.ctx); err != nil { return nil, 0, err } resp, index, err := w.state.BlockingQuery(w.getNodesImpl, minIndex, w.ctx) if err != nil { return nil, 0, err } return resp.(map[string]*structs...
go
func (w *nodeDrainWatcher) getNodes(minIndex uint64) (map[string]*structs.Node, uint64, error) { if err := w.limiter.Wait(w.ctx); err != nil { return nil, 0, err } resp, index, err := w.state.BlockingQuery(w.getNodesImpl, minIndex, w.ctx) if err != nil { return nil, 0, err } return resp.(map[string]*structs...
[ "func", "(", "w", "*", "nodeDrainWatcher", ")", "getNodes", "(", "minIndex", "uint64", ")", "(", "map", "[", "string", "]", "*", "structs", ".", "Node", ",", "uint64", ",", "error", ")", "{", "if", "err", ":=", "w", ".", "limiter", ".", "Wait", "("...
// getNodes returns all nodes blocking until the nodes are after the given index.
[ "getNodes", "returns", "all", "nodes", "blocking", "until", "the", "nodes", "are", "after", "the", "given", "index", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L212-L223
132,805
hashicorp/nomad
nomad/drainer/watch_nodes.go
getNodesImpl
func (w *nodeDrainWatcher) getNodesImpl(ws memdb.WatchSet, state *state.StateStore) (interface{}, uint64, error) { iter, err := state.Nodes(ws) if err != nil { return nil, 0, err } index, err := state.Index("nodes") if err != nil { return nil, 0, err } var maxIndex uint64 = 0 resp := make(map[string]*stru...
go
func (w *nodeDrainWatcher) getNodesImpl(ws memdb.WatchSet, state *state.StateStore) (interface{}, uint64, error) { iter, err := state.Nodes(ws) if err != nil { return nil, 0, err } index, err := state.Index("nodes") if err != nil { return nil, 0, err } var maxIndex uint64 = 0 resp := make(map[string]*stru...
[ "func", "(", "w", "*", "nodeDrainWatcher", ")", "getNodesImpl", "(", "ws", "memdb", ".", "WatchSet", ",", "state", "*", "state", ".", "StateStore", ")", "(", "interface", "{", "}", ",", "uint64", ",", "error", ")", "{", "iter", ",", "err", ":=", "sta...
// getNodesImpl is used to get nodes from the state store, returning the set of // nodes and the given index.
[ "getNodesImpl", "is", "used", "to", "get", "nodes", "from", "the", "state", "store", "returning", "the", "set", "of", "nodes", "and", "the", "given", "index", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/watch_nodes.go#L227-L260
132,806
hashicorp/nomad
client/allocrunner/taskrunner/stats_hook.go
collectResourceUsageStats
func (h *statsHook) collectResourceUsageStats(ctx context.Context, handle interfaces.DriverStats) { ch, err := handle.Stats(ctx, h.interval) if err != nil { // Check if the driver doesn't implement stats if err.Error() == cstructs.DriverStatsNotImplemented.Error() { h.logger.Debug("driver does not support sta...
go
func (h *statsHook) collectResourceUsageStats(ctx context.Context, handle interfaces.DriverStats) { ch, err := handle.Stats(ctx, h.interval) if err != nil { // Check if the driver doesn't implement stats if err.Error() == cstructs.DriverStatsNotImplemented.Error() { h.logger.Debug("driver does not support sta...
[ "func", "(", "h", "*", "statsHook", ")", "collectResourceUsageStats", "(", "ctx", "context", ".", "Context", ",", "handle", "interfaces", ".", "DriverStats", ")", "{", "ch", ",", "err", ":=", "handle", ".", "Stats", "(", "ctx", ",", "h", ".", "interval",...
// collectResourceUsageStats starts collecting resource usage stats of a Task. // Collection ends when the passed channel is closed
[ "collectResourceUsageStats", "starts", "collecting", "resource", "usage", "stats", "of", "a", "Task", ".", "Collection", "ends", "when", "the", "passed", "channel", "is", "closed" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/stats_hook.go#L89-L150
132,807
hashicorp/nomad
nomad/client_rpc.go
getNodeConn
func (s *Server) getNodeConn(nodeID string) (*nodeConnState, bool) { s.nodeConnsLock.RLock() defer s.nodeConnsLock.RUnlock() conns, ok := s.nodeConns[nodeID] if !ok { return nil, false } // Return the latest conn var state *nodeConnState for _, conn := range conns { if state == nil || state.Established.Bef...
go
func (s *Server) getNodeConn(nodeID string) (*nodeConnState, bool) { s.nodeConnsLock.RLock() defer s.nodeConnsLock.RUnlock() conns, ok := s.nodeConns[nodeID] if !ok { return nil, false } // Return the latest conn var state *nodeConnState for _, conn := range conns { if state == nil || state.Established.Bef...
[ "func", "(", "s", "*", "Server", ")", "getNodeConn", "(", "nodeID", "string", ")", "(", "*", "nodeConnState", ",", "bool", ")", "{", "s", ".", "nodeConnsLock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "nodeConnsLock", ".", "RUnlock", "(", ")"...
// getNodeConn returns the connection to the given node and whether it exists.
[ "getNodeConn", "returns", "the", "connection", "to", "the", "given", "node", "and", "whether", "it", "exists", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L30-L53
132,808
hashicorp/nomad
nomad/client_rpc.go
connectedNodes
func (s *Server) connectedNodes() map[string]time.Time { s.nodeConnsLock.RLock() defer s.nodeConnsLock.RUnlock() nodes := make(map[string]time.Time, len(s.nodeConns)) for nodeID, conns := range s.nodeConns { for _, conn := range conns { if nodes[nodeID].Before(conn.Established) { nodes[nodeID] = conn.Estab...
go
func (s *Server) connectedNodes() map[string]time.Time { s.nodeConnsLock.RLock() defer s.nodeConnsLock.RUnlock() nodes := make(map[string]time.Time, len(s.nodeConns)) for nodeID, conns := range s.nodeConns { for _, conn := range conns { if nodes[nodeID].Before(conn.Established) { nodes[nodeID] = conn.Estab...
[ "func", "(", "s", "*", "Server", ")", "connectedNodes", "(", ")", "map", "[", "string", "]", "time", ".", "Time", "{", "s", ".", "nodeConnsLock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "nodeConnsLock", ".", "RUnlock", "(", ")", "\n", "nod...
// connectedNodes returns the set of nodes we have a connection with.
[ "connectedNodes", "returns", "the", "set", "of", "nodes", "we", "have", "a", "connection", "with", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L56-L68
132,809
hashicorp/nomad
nomad/client_rpc.go
addNodeConn
func (s *Server) addNodeConn(ctx *RPCContext) { // Hotpath the no-op if ctx == nil || ctx.NodeID == "" { return } s.nodeConnsLock.Lock() defer s.nodeConnsLock.Unlock() // Capture the tracked connections so far currentConns := s.nodeConns[ctx.NodeID] // Check if we already have the connection. If we do, jus...
go
func (s *Server) addNodeConn(ctx *RPCContext) { // Hotpath the no-op if ctx == nil || ctx.NodeID == "" { return } s.nodeConnsLock.Lock() defer s.nodeConnsLock.Unlock() // Capture the tracked connections so far currentConns := s.nodeConns[ctx.NodeID] // Check if we already have the connection. If we do, jus...
[ "func", "(", "s", "*", "Server", ")", "addNodeConn", "(", "ctx", "*", "RPCContext", ")", "{", "// Hotpath the no-op", "if", "ctx", "==", "nil", "||", "ctx", ".", "NodeID", "==", "\"", "\"", "{", "return", "\n", "}", "\n\n", "s", ".", "nodeConnsLock", ...
// addNodeConn adds the mapping between a node and its session.
[ "addNodeConn", "adds", "the", "mapping", "between", "a", "node", "and", "its", "session", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L71-L99
132,810
hashicorp/nomad
nomad/client_rpc.go
removeNodeConn
func (s *Server) removeNodeConn(ctx *RPCContext) { // Hotpath the no-op if ctx == nil || ctx.NodeID == "" { return } s.nodeConnsLock.Lock() defer s.nodeConnsLock.Unlock() conns, ok := s.nodeConns[ctx.NodeID] if !ok { return } // It is important that we check that the connection being removed is the // a...
go
func (s *Server) removeNodeConn(ctx *RPCContext) { // Hotpath the no-op if ctx == nil || ctx.NodeID == "" { return } s.nodeConnsLock.Lock() defer s.nodeConnsLock.Unlock() conns, ok := s.nodeConns[ctx.NodeID] if !ok { return } // It is important that we check that the connection being removed is the // a...
[ "func", "(", "s", "*", "Server", ")", "removeNodeConn", "(", "ctx", "*", "RPCContext", ")", "{", "// Hotpath the no-op", "if", "ctx", "==", "nil", "||", "ctx", ".", "NodeID", "==", "\"", "\"", "{", "return", "\n", "}", "\n\n", "s", ".", "nodeConnsLock"...
// removeNodeConn removes the mapping between a node and its session.
[ "removeNodeConn", "removes", "the", "mapping", "between", "a", "node", "and", "its", "session", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L102-L135
132,811
hashicorp/nomad
nomad/client_rpc.go
serverWithNodeConn
func (s *Server) serverWithNodeConn(nodeID, region string) (*serverParts, error) { // We skip ourselves. selfAddr := s.LocalMember().Addr.String() // Build the request req := &structs.NodeSpecificRequest{ NodeID: nodeID, QueryOptions: structs.QueryOptions{ Region: s.config.Region, }, } // Select the li...
go
func (s *Server) serverWithNodeConn(nodeID, region string) (*serverParts, error) { // We skip ourselves. selfAddr := s.LocalMember().Addr.String() // Build the request req := &structs.NodeSpecificRequest{ NodeID: nodeID, QueryOptions: structs.QueryOptions{ Region: s.config.Region, }, } // Select the li...
[ "func", "(", "s", "*", "Server", ")", "serverWithNodeConn", "(", "nodeID", ",", "region", "string", ")", "(", "*", "serverParts", ",", "error", ")", "{", "// We skip ourselves.", "selfAddr", ":=", "s", ".", "LocalMember", "(", ")", ".", "Addr", ".", "Str...
// serverWithNodeConn is used to determine which remote server has the most // recent connection to the given node. The local server is not queried. // ErrNoNodeConn is returned if all local peers could be queried but did not // have a connection to the node. Otherwise if a connection could not be found // and there we...
[ "serverWithNodeConn", "is", "used", "to", "determine", "which", "remote", "server", "has", "the", "most", "recent", "connection", "to", "the", "given", "node", ".", "The", "local", "server", "is", "not", "queried", ".", "ErrNoNodeConn", "is", "returned", "if",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L142-L214
132,812
hashicorp/nomad
nomad/client_rpc.go
NodeRpc
func NodeRpc(session *yamux.Session, method string, args, reply interface{}) error { // Open a new session stream, err := session.Open() if err != nil { return err } defer stream.Close() // Write the RpcNomad byte to set the mode if _, err := stream.Write([]byte{byte(pool.RpcNomad)}); err != nil { stream.Cl...
go
func NodeRpc(session *yamux.Session, method string, args, reply interface{}) error { // Open a new session stream, err := session.Open() if err != nil { return err } defer stream.Close() // Write the RpcNomad byte to set the mode if _, err := stream.Write([]byte{byte(pool.RpcNomad)}); err != nil { stream.Cl...
[ "func", "NodeRpc", "(", "session", "*", "yamux", ".", "Session", ",", "method", "string", ",", "args", ",", "reply", "interface", "{", "}", ")", "error", "{", "// Open a new session", "stream", ",", "err", ":=", "session", ".", "Open", "(", ")", "\n", ...
// NodeRpc is used to make an RPC call to a node. The method takes the // Yamux session for the node and the method to be called.
[ "NodeRpc", "is", "used", "to", "make", "an", "RPC", "call", "to", "a", "node", ".", "The", "method", "takes", "the", "Yamux", "session", "for", "the", "node", "and", "the", "method", "to", "be", "called", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L218-L239
132,813
hashicorp/nomad
nomad/client_rpc.go
NodeStreamingRpc
func NodeStreamingRpc(session *yamux.Session, method string) (net.Conn, error) { // Open a new session stream, err := session.Open() if err != nil { return nil, err } // Write the RpcNomad byte to set the mode if _, err := stream.Write([]byte{byte(pool.RpcStreaming)}); err != nil { stream.Close() return ni...
go
func NodeStreamingRpc(session *yamux.Session, method string) (net.Conn, error) { // Open a new session stream, err := session.Open() if err != nil { return nil, err } // Write the RpcNomad byte to set the mode if _, err := stream.Write([]byte{byte(pool.RpcStreaming)}); err != nil { stream.Close() return ni...
[ "func", "NodeStreamingRpc", "(", "session", "*", "yamux", ".", "Session", ",", "method", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "// Open a new session", "stream", ",", "err", ":=", "session", ".", "Open", "(", ")", "\n", "if", ...
// NodeStreamingRpc is used to make a streaming RPC call to a node. The method // takes the Yamux session for the node and the method to be called. It conducts // the initial handshake and returns a connection to be used or an error. It is // the callers responsibility to close the connection if there is no error.
[ "NodeStreamingRpc", "is", "used", "to", "make", "a", "streaming", "RPC", "call", "to", "a", "node", ".", "The", "method", "takes", "the", "Yamux", "session", "for", "the", "node", "and", "the", "method", "to", "be", "called", ".", "It", "conducts", "the"...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L245-L282
132,814
hashicorp/nomad
nomad/client_rpc.go
findNodeConnAndForward
func findNodeConnAndForward(srv *Server, nodeID, method string, args, reply interface{}) error { // Determine the Server that has a connection to the node. srvWithConn, err := srv.serverWithNodeConn(nodeID, srv.Region()) if err != nil { return err } if srvWithConn == nil { return structs.ErrNoNodeConn } re...
go
func findNodeConnAndForward(srv *Server, nodeID, method string, args, reply interface{}) error { // Determine the Server that has a connection to the node. srvWithConn, err := srv.serverWithNodeConn(nodeID, srv.Region()) if err != nil { return err } if srvWithConn == nil { return structs.ErrNoNodeConn } re...
[ "func", "findNodeConnAndForward", "(", "srv", "*", "Server", ",", "nodeID", ",", "method", "string", ",", "args", ",", "reply", "interface", "{", "}", ")", "error", "{", "// Determine the Server that has a connection to the node.", "srvWithConn", ",", "err", ":=", ...
// findNodeConnAndForward is a helper for finding the server with a connection // to the given node and forwarding the RPC to the correct server. This does not // work for streaming RPCs.
[ "findNodeConnAndForward", "is", "a", "helper", "for", "finding", "the", "server", "with", "a", "connection", "to", "the", "given", "node", "and", "forwarding", "the", "RPC", "to", "the", "correct", "server", ".", "This", "does", "not", "work", "for", "stream...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/client_rpc.go#L287-L299
132,815
hashicorp/nomad
drivers/docker/progress.go
get
func (p *imageProgress) get() (string, time.Time) { p.RLock() defer p.RUnlock() if p.lastMessage == nil { return "No progress", p.timestamp } var pulled, pulling, waiting int for _, l := range p.layers { switch { case l.status == layerProgressStatusStarting || l.status == layerProgressStatusWaiting: ...
go
func (p *imageProgress) get() (string, time.Time) { p.RLock() defer p.RUnlock() if p.lastMessage == nil { return "No progress", p.timestamp } var pulled, pulling, waiting int for _, l := range p.layers { switch { case l.status == layerProgressStatusStarting || l.status == layerProgressStatusWaiting: ...
[ "func", "(", "p", "*", "imageProgress", ")", "get", "(", ")", "(", "string", ",", "time", ".", "Time", ")", "{", "p", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "RUnlock", "(", ")", "\n\n", "if", "p", ".", "lastMessage", "==", "nil", "{",...
// get returns a status message and the timestamp of the last status update
[ "get", "returns", "a", "status", "message", "and", "the", "timestamp", "of", "the", "last", "status", "update" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/progress.go#L88-L127
132,816
hashicorp/nomad
drivers/docker/progress.go
set
func (p *imageProgress) set(msg *jsonmessage.JSONMessage) { p.Lock() defer p.Unlock() p.lastMessage = msg p.timestamp = time.Now() lps := lpsFromString(msg.Status) if lps == layerProgressStatusUnknown { return } layer, ok := p.layers[msg.ID] if !ok { layer = &layerProgress{id: msg.ID} p.layers[msg.ID]...
go
func (p *imageProgress) set(msg *jsonmessage.JSONMessage) { p.Lock() defer p.Unlock() p.lastMessage = msg p.timestamp = time.Now() lps := lpsFromString(msg.Status) if lps == layerProgressStatusUnknown { return } layer, ok := p.layers[msg.ID] if !ok { layer = &layerProgress{id: msg.ID} p.layers[msg.ID]...
[ "func", "(", "p", "*", "imageProgress", ")", "set", "(", "msg", "*", "jsonmessage", ".", "JSONMessage", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n\n", "p", ".", "lastMessage", "=", "msg", "\n", "p", "."...
// set takes a status message received from the docker engine api during an image // pull and updates the status of the corresponding layer
[ "set", "takes", "a", "status", "message", "received", "from", "the", "docker", "engine", "api", "during", "an", "image", "pull", "and", "updates", "the", "status", "of", "the", "corresponding", "layer" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/progress.go#L131-L155
132,817
hashicorp/nomad
drivers/docker/progress.go
currentBytes
func (p *imageProgress) currentBytes() int64 { var b int64 for _, l := range p.layers { b += l.currentBytes } return b }
go
func (p *imageProgress) currentBytes() int64 { var b int64 for _, l := range p.layers { b += l.currentBytes } return b }
[ "func", "(", "p", "*", "imageProgress", ")", "currentBytes", "(", ")", "int64", "{", "var", "b", "int64", "\n", "for", "_", ",", "l", ":=", "range", "p", ".", "layers", "{", "b", "+=", "l", ".", "currentBytes", "\n", "}", "\n", "return", "b", "\n...
// currentBytes iterates through all image layers and sums the total of // current bytes. The caller is responsible for acquiring a read lock on the // imageProgress struct
[ "currentBytes", "iterates", "through", "all", "image", "layers", "and", "sums", "the", "total", "of", "current", "bytes", ".", "The", "caller", "is", "responsible", "for", "acquiring", "a", "read", "lock", "on", "the", "imageProgress", "struct" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/progress.go#L160-L166
132,818
hashicorp/nomad
drivers/docker/progress.go
totalBytes
func (p *imageProgress) totalBytes() int64 { var b int64 for _, l := range p.layers { b += l.totalBytes } return b }
go
func (p *imageProgress) totalBytes() int64 { var b int64 for _, l := range p.layers { b += l.totalBytes } return b }
[ "func", "(", "p", "*", "imageProgress", ")", "totalBytes", "(", ")", "int64", "{", "var", "b", "int64", "\n", "for", "_", ",", "l", ":=", "range", "p", ".", "layers", "{", "b", "+=", "l", ".", "totalBytes", "\n", "}", "\n", "return", "b", "\n", ...
// totalBytes iterates through all image layers and sums the total of // total bytes. The caller is responsible for acquiring a read lock on the // imageProgress struct
[ "totalBytes", "iterates", "through", "all", "image", "layers", "and", "sums", "the", "total", "of", "total", "bytes", ".", "The", "caller", "is", "responsible", "for", "acquiring", "a", "read", "lock", "on", "the", "imageProgress", "struct" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/progress.go#L171-L177
132,819
hashicorp/nomad
drivers/docker/progress.go
start
func (pm *imageProgressManager) start() { now := time.Now() pm.imageProgress.pullStart = now pm.lastSlowReport = now go func() { ticker := time.NewTicker(dockerImageProgressReportInterval) for { select { case <-ticker.C: msg, lastStatusTime := pm.imageProgress.get() t := time.Now() if t.Sub(la...
go
func (pm *imageProgressManager) start() { now := time.Now() pm.imageProgress.pullStart = now pm.lastSlowReport = now go func() { ticker := time.NewTicker(dockerImageProgressReportInterval) for { select { case <-ticker.C: msg, lastStatusTime := pm.imageProgress.get() t := time.Now() if t.Sub(la...
[ "func", "(", "pm", "*", "imageProgressManager", ")", "start", "(", ")", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "pm", ".", "imageProgress", ".", "pullStart", "=", "now", "\n", "pm", ".", "lastSlowReport", "=", "now", "\n", "go", "func",...
// start intiates the ticker to trigger the inactivity and reporter handlers
[ "start", "intiates", "the", "ticker", "to", "trigger", "the", "inactivity", "and", "reporter", "handlers" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/docker/progress.go#L229-L255
132,820
hashicorp/nomad
command/quota_apply.go
parseQuotaSpec
func parseQuotaSpec(input []byte) (*api.QuotaSpec, error) { root, err := hcl.ParseBytes(input) if err != nil { return nil, err } // Top-level item should be a list list, ok := root.Node.(*ast.ObjectList) if !ok { return nil, fmt.Errorf("error parsing: root should be an object") } var spec api.QuotaSpec i...
go
func parseQuotaSpec(input []byte) (*api.QuotaSpec, error) { root, err := hcl.ParseBytes(input) if err != nil { return nil, err } // Top-level item should be a list list, ok := root.Node.(*ast.ObjectList) if !ok { return nil, fmt.Errorf("error parsing: root should be an object") } var spec api.QuotaSpec i...
[ "func", "parseQuotaSpec", "(", "input", "[", "]", "byte", ")", "(", "*", "api", ".", "QuotaSpec", ",", "error", ")", "{", "root", ",", "err", ":=", "hcl", ".", "ParseBytes", "(", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// parseQuotaSpec is used to parse the quota specification from HCL
[ "parseQuotaSpec", "is", "used", "to", "parse", "the", "quota", "specification", "from", "HCL" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_apply.go#L135-L153
132,821
hashicorp/nomad
command/quota_apply.go
parseQuotaSpecImpl
func parseQuotaSpecImpl(result *api.QuotaSpec, list *ast.ObjectList) error { // Check for invalid keys valid := []string{ "name", "description", "limit", } if err := helper.CheckHCLKeys(list, valid); err != nil { return err } // Decode the full thing into a map[string]interface for ease var m map[string...
go
func parseQuotaSpecImpl(result *api.QuotaSpec, list *ast.ObjectList) error { // Check for invalid keys valid := []string{ "name", "description", "limit", } if err := helper.CheckHCLKeys(list, valid); err != nil { return err } // Decode the full thing into a map[string]interface for ease var m map[string...
[ "func", "parseQuotaSpecImpl", "(", "result", "*", "api", ".", "QuotaSpec", ",", "list", "*", "ast", ".", "ObjectList", ")", "error", "{", "// Check for invalid keys", "valid", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ...
// parseQuotaSpecImpl parses the quota spec taking as input the AST tree
[ "parseQuotaSpecImpl", "parses", "the", "quota", "spec", "taking", "as", "input", "the", "AST", "tree" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_apply.go#L156-L189
132,822
hashicorp/nomad
command/quota_apply.go
parseQuotaLimits
func parseQuotaLimits(result *[]*api.QuotaLimit, list *ast.ObjectList) error { for _, o := range list.Elem().Items { // Check for invalid keys valid := []string{ "region", "region_limit", } if err := helper.CheckHCLKeys(o.Val, valid); err != nil { return err } var m map[string]interface{} if er...
go
func parseQuotaLimits(result *[]*api.QuotaLimit, list *ast.ObjectList) error { for _, o := range list.Elem().Items { // Check for invalid keys valid := []string{ "region", "region_limit", } if err := helper.CheckHCLKeys(o.Val, valid); err != nil { return err } var m map[string]interface{} if er...
[ "func", "parseQuotaLimits", "(", "result", "*", "[", "]", "*", "api", ".", "QuotaLimit", ",", "list", "*", "ast", ".", "ObjectList", ")", "error", "{", "for", "_", ",", "o", ":=", "range", "list", ".", "Elem", "(", ")", ".", "Items", "{", "// Check...
// parseQuotaLimits parses the quota limits
[ "parseQuotaLimits", "parses", "the", "quota", "limits" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_apply.go#L192-L237
132,823
hashicorp/nomad
command/quota_apply.go
parseQuotaResource
func parseQuotaResource(result *api.Resources, list *ast.ObjectList) error { list = list.Elem() if len(list.Items) == 0 { return nil } if len(list.Items) > 1 { return fmt.Errorf("only one 'region_limit' block allowed per limit") } // Get our resource object o := list.Items[0] // We need this later var li...
go
func parseQuotaResource(result *api.Resources, list *ast.ObjectList) error { list = list.Elem() if len(list.Items) == 0 { return nil } if len(list.Items) > 1 { return fmt.Errorf("only one 'region_limit' block allowed per limit") } // Get our resource object o := list.Items[0] // We need this later var li...
[ "func", "parseQuotaResource", "(", "result", "*", "api", ".", "Resources", ",", "list", "*", "ast", ".", "ObjectList", ")", "error", "{", "list", "=", "list", ".", "Elem", "(", ")", "\n", "if", "len", "(", "list", ".", "Items", ")", "==", "0", "{",...
// parseQuotaResource parses the region_limit resources
[ "parseQuotaResource", "parses", "the", "region_limit", "resources" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_apply.go#L240-L279
132,824
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
Stop
func (tm *TaskTemplateManager) Stop() { tm.shutdownLock.Lock() defer tm.shutdownLock.Unlock() if tm.shutdown { return } close(tm.shutdownCh) tm.shutdown = true // Stop the consul-template runner if tm.runner != nil { tm.runner.Stop() } }
go
func (tm *TaskTemplateManager) Stop() { tm.shutdownLock.Lock() defer tm.shutdownLock.Unlock() if tm.shutdown { return } close(tm.shutdownCh) tm.shutdown = true // Stop the consul-template runner if tm.runner != nil { tm.runner.Stop() } }
[ "func", "(", "tm", "*", "TaskTemplateManager", ")", "Stop", "(", ")", "{", "tm", ".", "shutdownLock", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "shutdownLock", ".", "Unlock", "(", ")", "\n\n", "if", "tm", ".", "shutdown", "{", "return", "\n", ...
// Stop is used to stop the consul-template runner
[ "Stop", "is", "used", "to", "stop", "the", "consul", "-", "template", "runner" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L168-L183
132,825
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
run
func (tm *TaskTemplateManager) run() { // Runner is nil if there is no templates if tm.runner == nil { // Unblock the start if there is nothing to do close(tm.config.UnblockCh) return } // Start the runner go tm.runner.Start() // Block till all the templates have been rendered tm.handleFirstRender() //...
go
func (tm *TaskTemplateManager) run() { // Runner is nil if there is no templates if tm.runner == nil { // Unblock the start if there is nothing to do close(tm.config.UnblockCh) return } // Start the runner go tm.runner.Start() // Block till all the templates have been rendered tm.handleFirstRender() //...
[ "func", "(", "tm", "*", "TaskTemplateManager", ")", "run", "(", ")", "{", "// Runner is nil if there is no templates", "if", "tm", ".", "runner", "==", "nil", "{", "// Unblock the start if there is nothing to do", "close", "(", "tm", ".", "config", ".", "UnblockCh",...
// run is the long lived loop that handles errors and templates being rendered
[ "run", "is", "the", "long", "lived", "loop", "that", "handles", "errors", "and", "templates", "being", "rendered" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L186-L228
132,826
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
handleFirstRender
func (tm *TaskTemplateManager) handleFirstRender() { // missingDependencies is the set of missing dependencies. var missingDependencies map[string]struct{} // eventTimer is used to trigger the firing of an event showing the missing // dependencies. eventTimer := time.NewTimer(tm.config.MaxTemplateEventRate) if !...
go
func (tm *TaskTemplateManager) handleFirstRender() { // missingDependencies is the set of missing dependencies. var missingDependencies map[string]struct{} // eventTimer is used to trigger the firing of an event showing the missing // dependencies. eventTimer := time.NewTimer(tm.config.MaxTemplateEventRate) if !...
[ "func", "(", "tm", "*", "TaskTemplateManager", ")", "handleFirstRender", "(", ")", "{", "// missingDependencies is the set of missing dependencies.", "var", "missingDependencies", "map", "[", "string", "]", "struct", "{", "}", "\n\n", "// eventTimer is used to trigger the f...
// handleFirstRender blocks till all templates have been rendered
[ "handleFirstRender", "blocks", "till", "all", "templates", "have", "been", "rendered" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L231-L341
132,827
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
allTemplatesNoop
func (tm *TaskTemplateManager) allTemplatesNoop() bool { for _, tmpl := range tm.config.Templates { if tmpl.ChangeMode != structs.TemplateChangeModeNoop { return false } } return true }
go
func (tm *TaskTemplateManager) allTemplatesNoop() bool { for _, tmpl := range tm.config.Templates { if tmpl.ChangeMode != structs.TemplateChangeModeNoop { return false } } return true }
[ "func", "(", "tm", "*", "TaskTemplateManager", ")", "allTemplatesNoop", "(", ")", "bool", "{", "for", "_", ",", "tmpl", ":=", "range", "tm", ".", "config", ".", "Templates", "{", "if", "tmpl", ".", "ChangeMode", "!=", "structs", ".", "TemplateChangeModeNoo...
// allTemplatesNoop returns whether all the managed templates have change mode noop.
[ "allTemplatesNoop", "returns", "whether", "all", "the", "managed", "templates", "have", "change", "mode", "noop", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L474-L482
132,828
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
templateRunner
func templateRunner(config *TaskTemplateManagerConfig) ( *manager.Runner, map[string][]*structs.Template, error) { if len(config.Templates) == 0 { return nil, nil, nil } // Parse the templates ctmplMapping, err := parseTemplateConfigs(config) if err != nil { return nil, nil, err } // Create the runner co...
go
func templateRunner(config *TaskTemplateManagerConfig) ( *manager.Runner, map[string][]*structs.Template, error) { if len(config.Templates) == 0 { return nil, nil, nil } // Parse the templates ctmplMapping, err := parseTemplateConfigs(config) if err != nil { return nil, nil, err } // Create the runner co...
[ "func", "templateRunner", "(", "config", "*", "TaskTemplateManagerConfig", ")", "(", "*", "manager", ".", "Runner", ",", "map", "[", "string", "]", "[", "]", "*", "structs", ".", "Template", ",", "error", ")", "{", "if", "len", "(", "config", ".", "Tem...
// templateRunner returns a consul-template runner for the given templates and a // lookup by destination to the template. If no templates are in the config, a // nil template runner and lookup is returned.
[ "templateRunner", "returns", "a", "consul", "-", "template", "runner", "for", "the", "given", "templates", "and", "a", "lookup", "by", "destination", "to", "the", "template", ".", "If", "no", "templates", "are", "in", "the", "config", "a", "nil", "template",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L487-L526
132,829
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
parseTemplateConfigs
func parseTemplateConfigs(config *TaskTemplateManagerConfig) (map[ctconf.TemplateConfig]*structs.Template, error) { allowAbs := config.ClientConfig.ReadBoolDefault(hostSrcOption, true) taskEnv := config.EnvBuilder.Build() ctmpls := make(map[ctconf.TemplateConfig]*structs.Template, len(config.Templates)) for _, tmp...
go
func parseTemplateConfigs(config *TaskTemplateManagerConfig) (map[ctconf.TemplateConfig]*structs.Template, error) { allowAbs := config.ClientConfig.ReadBoolDefault(hostSrcOption, true) taskEnv := config.EnvBuilder.Build() ctmpls := make(map[ctconf.TemplateConfig]*structs.Template, len(config.Templates)) for _, tmp...
[ "func", "parseTemplateConfigs", "(", "config", "*", "TaskTemplateManagerConfig", ")", "(", "map", "[", "ctconf", ".", "TemplateConfig", "]", "*", "structs", ".", "Template", ",", "error", ")", "{", "allowAbs", ":=", "config", ".", "ClientConfig", ".", "ReadBoo...
// parseTemplateConfigs converts the tasks templates in the config into // consul-templates
[ "parseTemplateConfigs", "converts", "the", "tasks", "templates", "in", "the", "config", "into", "consul", "-", "templates" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L530-L574
132,830
hashicorp/nomad
client/allocrunner/taskrunner/template/template.go
loadTemplateEnv
func loadTemplateEnv(tmpls []*structs.Template, taskDir string, taskEnv *taskenv.TaskEnv) (map[string]string, error) { all := make(map[string]string, 50) for _, t := range tmpls { if !t.Envvars { continue } dest := filepath.Join(taskDir, taskEnv.ReplaceEnv(t.DestPath)) f, err := os.Open(dest) if err != ...
go
func loadTemplateEnv(tmpls []*structs.Template, taskDir string, taskEnv *taskenv.TaskEnv) (map[string]string, error) { all := make(map[string]string, 50) for _, t := range tmpls { if !t.Envvars { continue } dest := filepath.Join(taskDir, taskEnv.ReplaceEnv(t.DestPath)) f, err := os.Open(dest) if err != ...
[ "func", "loadTemplateEnv", "(", "tmpls", "[", "]", "*", "structs", ".", "Template", ",", "taskDir", "string", ",", "taskEnv", "*", "taskenv", ".", "TaskEnv", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "all", ":=", "make", ...
// loadTemplateEnv loads task environment variables from all templates.
[ "loadTemplateEnv", "loads", "task", "environment", "variables", "from", "all", "templates", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template/template.go#L682-L706
132,831
hashicorp/nomad
client/allocdir/fs_linux.go
linkDir
func linkDir(src, dst string) error { if err := os.MkdirAll(dst, 0777); err != nil { return err } return syscall.Mount(src, dst, "", syscall.MS_BIND, "") }
go
func linkDir(src, dst string) error { if err := os.MkdirAll(dst, 0777); err != nil { return err } return syscall.Mount(src, dst, "", syscall.MS_BIND, "") }
[ "func", "linkDir", "(", "src", ",", "dst", "string", ")", "error", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "dst", ",", "0777", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "syscall", ".", "Mount", "...
// linkDir bind mounts src to dst as Linux doesn't support hardlinking // directories.
[ "linkDir", "bind", "mounts", "src", "to", "dst", "as", "Linux", "doesn", "t", "support", "hardlinking", "directories", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_linux.go#L23-L29
132,832
hashicorp/nomad
client/allocdir/fs_linux.go
unlinkDir
func unlinkDir(dir string) error { if err := syscall.Unmount(dir, 0); err != nil { if err != syscall.EINVAL { return err } } return nil }
go
func unlinkDir(dir string) error { if err := syscall.Unmount(dir, 0); err != nil { if err != syscall.EINVAL { return err } } return nil }
[ "func", "unlinkDir", "(", "dir", "string", ")", "error", "{", "if", "err", ":=", "syscall", ".", "Unmount", "(", "dir", ",", "0", ")", ";", "err", "!=", "nil", "{", "if", "err", "!=", "syscall", ".", "EINVAL", "{", "return", "err", "\n", "}", "\n...
// unlinkDir unmounts a bind mounted directory as Linux doesn't support // hardlinking directories. If the dir is already unmounted no error is // returned.
[ "unlinkDir", "unmounts", "a", "bind", "mounted", "directory", "as", "Linux", "doesn", "t", "support", "hardlinking", "directories", ".", "If", "the", "dir", "is", "already", "unmounted", "no", "error", "is", "returned", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_linux.go#L34-L41
132,833
hashicorp/nomad
client/allocdir/fs_linux.go
createSecretDir
func createSecretDir(dir string) error { // Only mount the tmpfs if we are root if unix.Geteuid() == 0 { if err := os.MkdirAll(dir, 0777); err != nil { return err } // Check for marker file and skip mounting if it exists marker := filepath.Join(dir, secretMarker) if _, err := os.Stat(marker); err == nil...
go
func createSecretDir(dir string) error { // Only mount the tmpfs if we are root if unix.Geteuid() == 0 { if err := os.MkdirAll(dir, 0777); err != nil { return err } // Check for marker file and skip mounting if it exists marker := filepath.Join(dir, secretMarker) if _, err := os.Stat(marker); err == nil...
[ "func", "createSecretDir", "(", "dir", "string", ")", "error", "{", "// Only mount the tmpfs if we are root", "if", "unix", ".", "Geteuid", "(", ")", "==", "0", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "dir", ",", "0777", ")", ";", "err", "!="...
// createSecretDir creates the secrets dir folder at the given path using a // tmpfs
[ "createSecretDir", "creates", "the", "secrets", "dir", "folder", "at", "the", "given", "path", "using", "a", "tmpfs" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_linux.go#L45-L76
132,834
hashicorp/nomad
client/allocdir/fs_linux.go
removeSecretDir
func removeSecretDir(dir string) error { if unix.Geteuid() == 0 { if err := unlinkDir(dir); err != nil { // Ignore invalid path errors if err != syscall.ENOENT { return os.NewSyscallError("unmount", err) } } } return os.RemoveAll(dir) }
go
func removeSecretDir(dir string) error { if unix.Geteuid() == 0 { if err := unlinkDir(dir); err != nil { // Ignore invalid path errors if err != syscall.ENOENT { return os.NewSyscallError("unmount", err) } } } return os.RemoveAll(dir) }
[ "func", "removeSecretDir", "(", "dir", "string", ")", "error", "{", "if", "unix", ".", "Geteuid", "(", ")", "==", "0", "{", "if", "err", ":=", "unlinkDir", "(", "dir", ")", ";", "err", "!=", "nil", "{", "// Ignore invalid path errors", "if", "err", "!=...
// createSecretDir removes the secrets dir folder
[ "createSecretDir", "removes", "the", "secrets", "dir", "folder" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_linux.go#L79-L90
132,835
hashicorp/nomad
client/lib/fifo/fifo_windows.go
CreateAndRead
func CreateAndRead(path string) (func() (io.ReadCloser, error), error) { l, err := winio.ListenPipe(path, &winio.PipeConfig{ InputBufferSize: PipeBufferSize, OutputBufferSize: PipeBufferSize, }) if err != nil { return nil, err } openFn := func() (io.ReadCloser, error) { return &winFIFO{ listener: l, ...
go
func CreateAndRead(path string) (func() (io.ReadCloser, error), error) { l, err := winio.ListenPipe(path, &winio.PipeConfig{ InputBufferSize: PipeBufferSize, OutputBufferSize: PipeBufferSize, }) if err != nil { return nil, err } openFn := func() (io.ReadCloser, error) { return &winFIFO{ listener: l, ...
[ "func", "CreateAndRead", "(", "path", "string", ")", "(", "func", "(", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", ",", "error", ")", "{", "l", ",", "err", ":=", "winio", ".", "ListenPipe", "(", "path", ",", "&", "winio", ".", "PipeConfig...
// CreateAndRead creates a fifo at the given path and returns an io.ReadCloser open for it. // The fifo must not already exist
[ "CreateAndRead", "creates", "a", "fifo", "at", "the", "given", "path", "and", "returns", "an", "io", ".", "ReadCloser", "open", "for", "it", ".", "The", "fifo", "must", "not", "already", "exist" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/fifo/fifo_windows.go#L72-L88
132,836
hashicorp/nomad
client/lib/fifo/fifo_windows.go
OpenWriter
func OpenWriter(path string) (io.WriteCloser, error) { return winio.DialPipe(path, nil) }
go
func OpenWriter(path string) (io.WriteCloser, error) { return winio.DialPipe(path, nil) }
[ "func", "OpenWriter", "(", "path", "string", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "return", "winio", ".", "DialPipe", "(", "path", ",", "nil", ")", "\n", "}" ]
// OpenWriter opens a fifo that already exists and returns an io.WriteCloser for it
[ "OpenWriter", "opens", "a", "fifo", "that", "already", "exists", "and", "returns", "an", "io", ".", "WriteCloser", "for", "it" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/fifo/fifo_windows.go#L91-L93
132,837
hashicorp/nomad
client/lib/fifo/fifo_windows.go
Remove
func Remove(path string) error { dur := 500 * time.Millisecond conn, err := winio.DialPipe(path, &dur) if err == nil { return conn.Close() } os.Remove(path) return nil }
go
func Remove(path string) error { dur := 500 * time.Millisecond conn, err := winio.DialPipe(path, &dur) if err == nil { return conn.Close() } os.Remove(path) return nil }
[ "func", "Remove", "(", "path", "string", ")", "error", "{", "dur", ":=", "500", "*", "time", ".", "Millisecond", "\n", "conn", ",", "err", ":=", "winio", ".", "DialPipe", "(", "path", ",", "&", "dur", ")", "\n", "if", "err", "==", "nil", "{", "re...
// Remove a fifo that already exists at a given path
[ "Remove", "a", "fifo", "that", "already", "exists", "at", "a", "given", "path" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/fifo/fifo_windows.go#L96-L105
132,838
hashicorp/nomad
command/agent/helpers.go
rpcHandlerForAlloc
func (s *HTTPServer) rpcHandlerForAlloc(allocID string) (localClient, remoteClient, server bool) { c := s.agent.Client() srv := s.agent.Server() // See if the local client can handle the request. localAlloc := false if c != nil { // If there is an error it means that the client doesn't have the // allocation ...
go
func (s *HTTPServer) rpcHandlerForAlloc(allocID string) (localClient, remoteClient, server bool) { c := s.agent.Client() srv := s.agent.Server() // See if the local client can handle the request. localAlloc := false if c != nil { // If there is an error it means that the client doesn't have the // allocation ...
[ "func", "(", "s", "*", "HTTPServer", ")", "rpcHandlerForAlloc", "(", "allocID", "string", ")", "(", "localClient", ",", "remoteClient", ",", "server", "bool", ")", "{", "c", ":=", "s", ".", "agent", ".", "Client", "(", ")", "\n", "srv", ":=", "s", "....
// rpcHandlerForAlloc is a helper that given an allocation ID returns whether to // use the local clients RPC, the local clients remote RPC or the server on the // agent.
[ "rpcHandlerForAlloc", "is", "a", "helper", "that", "given", "an", "allocation", "ID", "returns", "whether", "to", "use", "the", "local", "clients", "RPC", "the", "local", "clients", "remote", "RPC", "or", "the", "server", "on", "the", "agent", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/helpers.go#L6-L29
132,839
hashicorp/nomad
command/agent/helpers.go
rpcHandlerForNode
func (s *HTTPServer) rpcHandlerForNode(nodeID string) (localClient, remoteClient, server bool) { c := s.agent.Client() srv := s.agent.Server() // See if the local client can handle the request. localClient = c != nil && // Must have a client (nodeID == "" || // If no node ID is given nodeID == c.NodeID()) // ...
go
func (s *HTTPServer) rpcHandlerForNode(nodeID string) (localClient, remoteClient, server bool) { c := s.agent.Client() srv := s.agent.Server() // See if the local client can handle the request. localClient = c != nil && // Must have a client (nodeID == "" || // If no node ID is given nodeID == c.NodeID()) // ...
[ "func", "(", "s", "*", "HTTPServer", ")", "rpcHandlerForNode", "(", "nodeID", "string", ")", "(", "localClient", ",", "remoteClient", ",", "server", "bool", ")", "{", "c", ":=", "s", ".", "agent", ".", "Client", "(", ")", "\n", "srv", ":=", "s", ".",...
// rpcHandlerForNode is a helper that given a node ID returns whether to // use the local clients RPC, the local clients remote RPC or the server on the // agent. If there is a local node and no node id is given, it is assumed the // local node is being targed.
[ "rpcHandlerForNode", "is", "a", "helper", "that", "given", "a", "node", "ID", "returns", "whether", "to", "use", "the", "local", "clients", "RPC", "the", "local", "clients", "remote", "RPC", "or", "the", "server", "on", "the", "agent", ".", "If", "there", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/helpers.go#L35-L52
132,840
hashicorp/nomad
client/devicemanager/utils.go
NewUnknownDeviceError
func NewUnknownDeviceError(err error, name, vendor, devType string, ids []string) *UnknownDeviceError { return &UnknownDeviceError{ Err: err, Name: name, Vendor: vendor, Type: devType, IDs: ids, } }
go
func NewUnknownDeviceError(err error, name, vendor, devType string, ids []string) *UnknownDeviceError { return &UnknownDeviceError{ Err: err, Name: name, Vendor: vendor, Type: devType, IDs: ids, } }
[ "func", "NewUnknownDeviceError", "(", "err", "error", ",", "name", ",", "vendor", ",", "devType", "string", ",", "ids", "[", "]", "string", ")", "*", "UnknownDeviceError", "{", "return", "&", "UnknownDeviceError", "{", "Err", ":", "err", ",", "Name", ":", ...
// NewUnknownDeviceError returns a new UnknownDeviceError for the given device.
[ "NewUnknownDeviceError", "returns", "a", "new", "UnknownDeviceError", "for", "the", "given", "device", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/utils.go#L23-L30
132,841
hashicorp/nomad
client/devicemanager/utils.go
Error
func (u *UnknownDeviceError) Error() string { return fmt.Sprintf("operation on unknown device(s) \"%s/%s/%s\" (%v): %v", u.Vendor, u.Type, u.Name, u.IDs, u.Err) }
go
func (u *UnknownDeviceError) Error() string { return fmt.Sprintf("operation on unknown device(s) \"%s/%s/%s\" (%v): %v", u.Vendor, u.Type, u.Name, u.IDs, u.Err) }
[ "func", "(", "u", "*", "UnknownDeviceError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "u", ".", "Vendor", ",", "u", ".", "Type", ",", "u", ".", "Name", ",", "u", ".", "IDs", "...
// Error returns an error formatting that reveals which unknown devices were // requested
[ "Error", "returns", "an", "error", "formatting", "that", "reveals", "which", "unknown", "devices", "were", "requested" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/utils.go#L34-L37
132,842
hashicorp/nomad
client/devicemanager/utils.go
UnknownDeviceErrFromAllocated
func UnknownDeviceErrFromAllocated(err string, d *structs.AllocatedDeviceResource) *UnknownDeviceError { return NewUnknownDeviceError(errors.New(err), d.Name, d.Vendor, d.Type, d.DeviceIDs) }
go
func UnknownDeviceErrFromAllocated(err string, d *structs.AllocatedDeviceResource) *UnknownDeviceError { return NewUnknownDeviceError(errors.New(err), d.Name, d.Vendor, d.Type, d.DeviceIDs) }
[ "func", "UnknownDeviceErrFromAllocated", "(", "err", "string", ",", "d", "*", "structs", ".", "AllocatedDeviceResource", ")", "*", "UnknownDeviceError", "{", "return", "NewUnknownDeviceError", "(", "errors", ".", "New", "(", "err", ")", ",", "d", ".", "Name", ...
// UnknownDeviceErrFromAllocated is a helper that returns an UnknownDeviceError // populating it via the AllocatedDeviceResource struct.
[ "UnknownDeviceErrFromAllocated", "is", "a", "helper", "that", "returns", "an", "UnknownDeviceError", "populating", "it", "via", "the", "AllocatedDeviceResource", "struct", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/utils.go#L41-L43
132,843
hashicorp/nomad
client/devicemanager/utils.go
convertDeviceGroup
func convertDeviceGroup(d *device.DeviceGroup) *structs.NodeDeviceResource { if d == nil { return nil } return &structs.NodeDeviceResource{ Vendor: d.Vendor, Type: d.Type, Name: d.Name, Instances: convertDevices(d.Devices), Attributes: psstructs.CopyMapStringAttribute(d.Attributes), } ...
go
func convertDeviceGroup(d *device.DeviceGroup) *structs.NodeDeviceResource { if d == nil { return nil } return &structs.NodeDeviceResource{ Vendor: d.Vendor, Type: d.Type, Name: d.Name, Instances: convertDevices(d.Devices), Attributes: psstructs.CopyMapStringAttribute(d.Attributes), } ...
[ "func", "convertDeviceGroup", "(", "d", "*", "device", ".", "DeviceGroup", ")", "*", "structs", ".", "NodeDeviceResource", "{", "if", "d", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "&", "structs", ".", "NodeDeviceResource", "{", "Vend...
// convertDeviceGroup converts a device group to a structs NodeDeviceResource
[ "convertDeviceGroup", "converts", "a", "device", "group", "to", "a", "structs", "NodeDeviceResource" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/utils.go#L46-L58
132,844
hashicorp/nomad
drivers/shared/executor/utils_unix.go
isolateCommand
func isolateCommand(cmd *exec.Cmd) { if cmd.SysProcAttr == nil { cmd.SysProcAttr = &syscall.SysProcAttr{} } cmd.SysProcAttr.Setsid = true }
go
func isolateCommand(cmd *exec.Cmd) { if cmd.SysProcAttr == nil { cmd.SysProcAttr = &syscall.SysProcAttr{} } cmd.SysProcAttr.Setsid = true }
[ "func", "isolateCommand", "(", "cmd", "*", "exec", ".", "Cmd", ")", "{", "if", "cmd", ".", "SysProcAttr", "==", "nil", "{", "cmd", ".", "SysProcAttr", "=", "&", "syscall", ".", "SysProcAttr", "{", "}", "\n", "}", "\n", "cmd", ".", "SysProcAttr", ".",...
// isolateCommand sets the setsid flag in exec.Cmd to true so that the process // becomes the process leader in a new session and doesn't receive signals that // are sent to the parent process.
[ "isolateCommand", "sets", "the", "setsid", "flag", "in", "exec", ".", "Cmd", "to", "true", "so", "that", "the", "process", "becomes", "the", "process", "leader", "in", "a", "new", "session", "and", "doesn", "t", "receive", "signals", "that", "are", "sent",...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/utils_unix.go#L13-L18
132,845
hashicorp/nomad
command/quota_status.go
quotaUsages
func quotaUsages(spec *api.QuotaSpec, client *api.Quotas) (usages map[string]*api.QuotaUsage, failures map[string]error) { // Determine the regions we have limits for regions := make(map[string]struct{}) for _, limit := range spec.Limits { regions[limit.Region] = struct{}{} } usages = make(map[string]*api.Quota...
go
func quotaUsages(spec *api.QuotaSpec, client *api.Quotas) (usages map[string]*api.QuotaUsage, failures map[string]error) { // Determine the regions we have limits for regions := make(map[string]struct{}) for _, limit := range spec.Limits { regions[limit.Region] = struct{}{} } usages = make(map[string]*api.Quota...
[ "func", "quotaUsages", "(", "spec", "*", "api", ".", "QuotaSpec", ",", "client", "*", "api", ".", "Quotas", ")", "(", "usages", "map", "[", "string", "]", "*", "api", ".", "QuotaUsage", ",", "failures", "map", "[", "string", "]", "error", ")", "{", ...
// quotaUsages returns the quota usages for the limits described by the spec. It // will make a request to each referenced Nomad region. If the region couldn't // be contacted, the error will be stored in the failures map
[ "quotaUsages", "returns", "the", "quota", "usages", "for", "the", "limits", "described", "by", "the", "spec", ".", "It", "will", "make", "a", "request", "to", "each", "referenced", "Nomad", "region", ".", "If", "the", "region", "couldn", "t", "be", "contac...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_status.go#L108-L132
132,846
hashicorp/nomad
command/quota_status.go
formatQuotaSpecBasics
func formatQuotaSpecBasics(spec *api.QuotaSpec) string { basic := []string{ fmt.Sprintf("Name|%s", spec.Name), fmt.Sprintf("Description|%s", spec.Description), fmt.Sprintf("Limits|%d", len(spec.Limits)), } return formatKV(basic) }
go
func formatQuotaSpecBasics(spec *api.QuotaSpec) string { basic := []string{ fmt.Sprintf("Name|%s", spec.Name), fmt.Sprintf("Description|%s", spec.Description), fmt.Sprintf("Limits|%d", len(spec.Limits)), } return formatKV(basic) }
[ "func", "formatQuotaSpecBasics", "(", "spec", "*", "api", ".", "QuotaSpec", ")", "string", "{", "basic", ":=", "[", "]", "string", "{", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "spec", ".", "Name", ")", ",", "fmt", ".", "Sprintf", "(", "\"", "\...
// formatQuotaSpecBasics formats the basic information of the quota // specification.
[ "formatQuotaSpecBasics", "formats", "the", "basic", "information", "of", "the", "quota", "specification", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_status.go#L136-L144
132,847
hashicorp/nomad
command/quota_status.go
formatQuotaLimits
func formatQuotaLimits(spec *api.QuotaSpec, usages map[string]*api.QuotaUsage) string { if len(spec.Limits) == 0 { return "No quota limits defined" } // Sort the limits sort.Sort(api.QuotaLimitSort(spec.Limits)) limits := make([]string, len(spec.Limits)+1) limits[0] = "Region|CPU Usage|Memory Usage" i := 0 ...
go
func formatQuotaLimits(spec *api.QuotaSpec, usages map[string]*api.QuotaUsage) string { if len(spec.Limits) == 0 { return "No quota limits defined" } // Sort the limits sort.Sort(api.QuotaLimitSort(spec.Limits)) limits := make([]string, len(spec.Limits)+1) limits[0] = "Region|CPU Usage|Memory Usage" i := 0 ...
[ "func", "formatQuotaLimits", "(", "spec", "*", "api", ".", "QuotaSpec", ",", "usages", "map", "[", "string", "]", "*", "api", ".", "QuotaUsage", ")", "string", "{", "if", "len", "(", "spec", ".", "Limits", ")", "==", "0", "{", "return", "\"", "\"", ...
// formatQuotaLimits formats the limits to display the quota usage versus the // limit per quota limit. It takes as input the specification as well as quota // usage by region. The formatter handles missing usages.
[ "formatQuotaLimits", "formats", "the", "limits", "to", "display", "the", "quota", "usage", "versus", "the", "limit", "per", "quota", "limit", ".", "It", "takes", "as", "input", "the", "specification", "as", "well", "as", "quota", "usage", "by", "region", "."...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_status.go#L149-L188
132,848
hashicorp/nomad
command/quota_status.go
formatQuotaLimitInt
func formatQuotaLimitInt(value *int) string { if value == nil { return "-" } v := *value if v < 0 { return "0" } else if v == 0 { return "inf" } return strconv.Itoa(v) }
go
func formatQuotaLimitInt(value *int) string { if value == nil { return "-" } v := *value if v < 0 { return "0" } else if v == 0 { return "inf" } return strconv.Itoa(v) }
[ "func", "formatQuotaLimitInt", "(", "value", "*", "int", ")", "string", "{", "if", "value", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "v", ":=", "*", "value", "\n", "if", "v", "<", "0", "{", "return", "\"", "\"", "\n", "}", "else...
// formatQuotaLimitInt takes a integer resource value and returns the // appropriate string for output.
[ "formatQuotaLimitInt", "takes", "a", "integer", "resource", "value", "and", "returns", "the", "appropriate", "string", "for", "output", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/quota_status.go#L192-L205
132,849
hashicorp/nomad
devices/gpu/nvidia/nvml/client.go
NewNvmlClient
func NewNvmlClient() (*nvmlClient, error) { driver := &nvmlDriver{} err := driver.Initialize() if err != nil { return nil, err } return &nvmlClient{ driver: driver, }, nil }
go
func NewNvmlClient() (*nvmlClient, error) { driver := &nvmlDriver{} err := driver.Initialize() if err != nil { return nil, err } return &nvmlClient{ driver: driver, }, nil }
[ "func", "NewNvmlClient", "(", ")", "(", "*", "nvmlClient", ",", "error", ")", "{", "driver", ":=", "&", "nvmlDriver", "{", "}", "\n", "err", ":=", "driver", ".", "Initialize", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "er...
// NewNvmlClient function creates new nvmlClient with real // NvmlDriver implementation. Also, this func initializes NvmlDriver
[ "NewNvmlClient", "function", "creates", "new", "nvmlClient", "with", "real", "NvmlDriver", "implementation", ".", "Also", "this", "func", "initializes", "NvmlDriver" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/nvml/client.go#L66-L75
132,850
hashicorp/nomad
devices/gpu/nvidia/nvml/client.go
GetFingerprintData
func (c *nvmlClient) GetFingerprintData() (*FingerprintData, error) { /* nvml fields to be fingerprinted # nvml_library_call 1 - Driver Version # nvmlSystemGetDriverVersion 2 - Product Name # nvmlDeviceGetName 3 - GPU UUID # nvmlDeviceGetUUID 4 - Total Memory ...
go
func (c *nvmlClient) GetFingerprintData() (*FingerprintData, error) { /* nvml fields to be fingerprinted # nvml_library_call 1 - Driver Version # nvmlSystemGetDriverVersion 2 - Product Name # nvmlDeviceGetName 3 - GPU UUID # nvmlDeviceGetUUID 4 - Total Memory ...
[ "func", "(", "c", "*", "nvmlClient", ")", "GetFingerprintData", "(", ")", "(", "*", "FingerprintData", ",", "error", ")", "{", "/*\n\t\tnvml fields to be fingerprinted # nvml_library_call\n\t\t1 - Driver Version # nvmlSystemGetDriverVersion\n\t\t2 - Product Name ...
// GetFingerprintData returns FingerprintData for available Nvidia devices
[ "GetFingerprintData", "returns", "FingerprintData", "for", "available", "Nvidia", "devices" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/nvml/client.go#L78-L136
132,851
hashicorp/nomad
devices/gpu/nvidia/nvml/client.go
GetStatsData
func (c *nvmlClient) GetStatsData() ([]*StatsData, error) { /* nvml fields to be reported to stats api # nvml_library_call 1 - Used Memory # nvmlDeviceGetMemoryInfo 2 - Utilization of GPU # nvmlDeviceGetUtilizationRates 3 - Utilization of Memory ...
go
func (c *nvmlClient) GetStatsData() ([]*StatsData, error) { /* nvml fields to be reported to stats api # nvml_library_call 1 - Used Memory # nvmlDeviceGetMemoryInfo 2 - Utilization of GPU # nvmlDeviceGetUtilizationRates 3 - Utilization of Memory ...
[ "func", "(", "c", "*", "nvmlClient", ")", "GetStatsData", "(", ")", "(", "[", "]", "*", "StatsData", ",", "error", ")", "{", "/*\n\t nvml fields to be reported to stats api # nvml_library_call\n\t 1 - Used Memory # nvmlDeviceGetMemoryInfo\n\t ...
// GetStatsData returns statistics data for all devices on this machine
[ "GetStatsData", "returns", "statistics", "data", "for", "all", "devices", "on", "this", "machine" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/devices/gpu/nvidia/nvml/client.go#L139-L194
132,852
hashicorp/nomad
helper/pluginutils/loader/util.go
configMap
func configMap(configs []*config.PluginConfig) map[string]*config.PluginConfig { pluginMapping := make(map[string]*config.PluginConfig, len(configs)) for _, c := range configs { pluginMapping[c.Name] = c } return pluginMapping }
go
func configMap(configs []*config.PluginConfig) map[string]*config.PluginConfig { pluginMapping := make(map[string]*config.PluginConfig, len(configs)) for _, c := range configs { pluginMapping[c.Name] = c } return pluginMapping }
[ "func", "configMap", "(", "configs", "[", "]", "*", "config", ".", "PluginConfig", ")", "map", "[", "string", "]", "*", "config", ".", "PluginConfig", "{", "pluginMapping", ":=", "make", "(", "map", "[", "string", "]", "*", "config", ".", "PluginConfig",...
// configMap returns a mapping of plugin binary name to config.
[ "configMap", "returns", "a", "mapping", "of", "plugin", "binary", "name", "to", "config", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/util.go#L10-L16
132,853
hashicorp/nomad
helper/pluginutils/loader/util.go
cleanPluginExecutable
func cleanPluginExecutable(name string) string { switch { case strings.HasSuffix(name, ".exe"): return strings.TrimSuffix(name, ".exe") default: return name } }
go
func cleanPluginExecutable(name string) string { switch { case strings.HasSuffix(name, ".exe"): return strings.TrimSuffix(name, ".exe") default: return name } }
[ "func", "cleanPluginExecutable", "(", "name", "string", ")", "string", "{", "switch", "{", "case", "strings", ".", "HasSuffix", "(", "name", ",", "\"", "\"", ")", ":", "return", "strings", ".", "TrimSuffix", "(", "name", ",", "\"", "\"", ")", "\n", "de...
// cleanPluginExecutable strips the executable name of common suffixes
[ "cleanPluginExecutable", "strips", "the", "executable", "name", "of", "common", "suffixes" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/loader/util.go#L19-L26
132,854
hashicorp/nomad
client/allocdir/fs_unix.go
dropDirPermissions
func dropDirPermissions(path string, desired os.FileMode) error { if err := os.Chmod(path, desired|0777); err != nil { return fmt.Errorf("Chmod(%v) failed: %v", path, err) } // Can't change owner if not root. if unix.Geteuid() != 0 { return nil } u, err := user.Lookup("nobody") if err != nil { return err...
go
func dropDirPermissions(path string, desired os.FileMode) error { if err := os.Chmod(path, desired|0777); err != nil { return fmt.Errorf("Chmod(%v) failed: %v", path, err) } // Can't change owner if not root. if unix.Geteuid() != 0 { return nil } u, err := user.Lookup("nobody") if err != nil { return err...
[ "func", "dropDirPermissions", "(", "path", "string", ",", "desired", "os", ".", "FileMode", ")", "error", "{", "if", "err", ":=", "os", ".", "Chmod", "(", "path", ",", "desired", "|", "0777", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", ...
// dropDirPermissions gives full access to a directory to all users and sets // the owner to nobody.
[ "dropDirPermissions", "gives", "full", "access", "to", "a", "directory", "to", "all", "users", "and", "sets", "the", "owner", "to", "nobody", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_unix.go#L32-L62
132,855
hashicorp/nomad
client/allocdir/fs_unix.go
getUid
func getUid(u *user.User) (int, error) { uid, err := strconv.Atoi(u.Uid) if err != nil { return 0, fmt.Errorf("Unable to convert Uid to an int: %v", err) } return uid, nil }
go
func getUid(u *user.User) (int, error) { uid, err := strconv.Atoi(u.Uid) if err != nil { return 0, fmt.Errorf("Unable to convert Uid to an int: %v", err) } return uid, nil }
[ "func", "getUid", "(", "u", "*", "user", ".", "User", ")", "(", "int", ",", "error", ")", "{", "uid", ",", "err", ":=", "strconv", ".", "Atoi", "(", "u", ".", "Uid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", ...
// getUid for a user
[ "getUid", "for", "a", "user" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_unix.go#L65-L72
132,856
hashicorp/nomad
client/allocdir/fs_unix.go
getGid
func getGid(u *user.User) (int, error) { gid, err := strconv.Atoi(u.Gid) if err != nil { return 0, fmt.Errorf("Unable to convert Gid to an int: %v", err) } return gid, nil }
go
func getGid(u *user.User) (int, error) { gid, err := strconv.Atoi(u.Gid) if err != nil { return 0, fmt.Errorf("Unable to convert Gid to an int: %v", err) } return gid, nil }
[ "func", "getGid", "(", "u", "*", "user", ".", "User", ")", "(", "int", ",", "error", ")", "{", "gid", ",", "err", ":=", "strconv", ".", "Atoi", "(", "u", ".", "Gid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", ...
// getGid for a user
[ "getGid", "for", "a", "user" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_unix.go#L75-L82
132,857
hashicorp/nomad
client/allocdir/fs_unix.go
linkOrCopy
func linkOrCopy(src, dst string, uid, gid int, perm os.FileMode) error { // Avoid link/copy if the file already exists in the chroot // TODO 0.6 clean this up. This was needed because chroot creation fails // when a process restarts. if fileInfo, _ := os.Stat(dst); fileInfo != nil { return nil } // Attempt to h...
go
func linkOrCopy(src, dst string, uid, gid int, perm os.FileMode) error { // Avoid link/copy if the file already exists in the chroot // TODO 0.6 clean this up. This was needed because chroot creation fails // when a process restarts. if fileInfo, _ := os.Stat(dst); fileInfo != nil { return nil } // Attempt to h...
[ "func", "linkOrCopy", "(", "src", ",", "dst", "string", ",", "uid", ",", "gid", "int", ",", "perm", "os", ".", "FileMode", ")", "error", "{", "// Avoid link/copy if the file already exists in the chroot", "// TODO 0.6 clean this up. This was needed because chroot creation f...
// linkOrCopy attempts to hardlink dst to src and fallsback to copying if the // hardlink fails.
[ "linkOrCopy", "attempts", "to", "hardlink", "dst", "to", "src", "and", "fallsback", "to", "copying", "if", "the", "hardlink", "fails", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/fs_unix.go#L86-L99
132,858
hashicorp/nomad
nomad/state/state_store_oss.go
namespaceExists
func (s *StateStore) namespaceExists(txn *memdb.Txn, namespace string) (bool, error) { return namespace == structs.DefaultNamespace, nil }
go
func (s *StateStore) namespaceExists(txn *memdb.Txn, namespace string) (bool, error) { return namespace == structs.DefaultNamespace, nil }
[ "func", "(", "s", "*", "StateStore", ")", "namespaceExists", "(", "txn", "*", "memdb", ".", "Txn", ",", "namespace", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "namespace", "==", "structs", ".", "DefaultNamespace", ",", "nil", "\n", ...
// namespaceExists returns whether a namespace exists
[ "namespaceExists", "returns", "whether", "a", "namespace", "exists" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store_oss.go#L11-L13
132,859
hashicorp/nomad
command/alloc_fs.go
followFile
func (f *AllocFSCommand) followFile(client *api.Client, alloc *api.Allocation, path, origin string, offset, numLines int64) (io.ReadCloser, error) { cancel := make(chan struct{}) frames, errCh := client.AllocFS().Stream(alloc, path, origin, offset, cancel, nil) select { case err := <-errCh: return nil, err def...
go
func (f *AllocFSCommand) followFile(client *api.Client, alloc *api.Allocation, path, origin string, offset, numLines int64) (io.ReadCloser, error) { cancel := make(chan struct{}) frames, errCh := client.AllocFS().Stream(alloc, path, origin, offset, cancel, nil) select { case err := <-errCh: return nil, err def...
[ "func", "(", "f", "*", "AllocFSCommand", ")", "followFile", "(", "client", "*", "api", ".", "Client", ",", "alloc", "*", "api", ".", "Allocation", ",", "path", ",", "origin", "string", ",", "offset", ",", "numLines", "int64", ")", "(", "io", ".", "Re...
// followFile outputs the contents of the file to stdout relative to the end of // the file. If numLines does not equal -1, then tail -n behavior is used.
[ "followFile", "outputs", "the", "contents", "of", "the", "file", "to", "stdout", "relative", "to", "the", "end", "of", "the", "file", ".", "If", "numLines", "does", "not", "equal", "-", "1", "then", "tail", "-", "n", "behavior", "is", "used", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_fs.go#L341-L373
132,860
hashicorp/nomad
command/alloc_fs.go
getRandomJobAlloc
func getRandomJobAlloc(client *api.Client, jobID string) (string, error) { var runningAllocs []*api.AllocationListStub allocs, _, err := client.Jobs().Allocations(jobID, false, nil) // Check that the job actually has allocations if len(allocs) == 0 { return "", fmt.Errorf("job %q doesn't exist or it has no alloc...
go
func getRandomJobAlloc(client *api.Client, jobID string) (string, error) { var runningAllocs []*api.AllocationListStub allocs, _, err := client.Jobs().Allocations(jobID, false, nil) // Check that the job actually has allocations if len(allocs) == 0 { return "", fmt.Errorf("job %q doesn't exist or it has no alloc...
[ "func", "getRandomJobAlloc", "(", "client", "*", "api", ".", "Client", ",", "jobID", "string", ")", "(", "string", ",", "error", ")", "{", "var", "runningAllocs", "[", "]", "*", "api", ".", "AllocationListStub", "\n", "allocs", ",", "_", ",", "err", ":...
// Get Random Allocation ID from a known jobID. Prefer to use a running allocation, // but use a dead allocation if no running allocations are found
[ "Get", "Random", "Allocation", "ID", "from", "a", "known", "jobID", ".", "Prefer", "to", "use", "a", "running", "allocation", "but", "use", "a", "dead", "allocation", "if", "no", "running", "allocations", "are", "found" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_fs.go#L377-L399
132,861
hashicorp/nomad
e2e/cli/command/environment.go
newEnv
func newEnv(envPath, provider, name, tfStatePath string, logger hclog.Logger) (*environment, error) { // Make sure terraform is on the PATH tf, err := exec.LookPath("terraform") if err != nil { return nil, fmt.Errorf("failed to lookup terraform binary: %v", err) } logger = logger.Named("provision").With("provid...
go
func newEnv(envPath, provider, name, tfStatePath string, logger hclog.Logger) (*environment, error) { // Make sure terraform is on the PATH tf, err := exec.LookPath("terraform") if err != nil { return nil, fmt.Errorf("failed to lookup terraform binary: %v", err) } logger = logger.Named("provision").With("provid...
[ "func", "newEnv", "(", "envPath", ",", "provider", ",", "name", ",", "tfStatePath", "string", ",", "logger", "hclog", ".", "Logger", ")", "(", "*", "environment", ",", "error", ")", "{", "// Make sure terraform is on the PATH", "tf", ",", "err", ":=", "exec"...
// newEnv takes a path to the environments directory, environment name and provider, // path to terraform state file and a logger and builds the environment stuct used // to initial terraform calls
[ "newEnv", "takes", "a", "path", "to", "the", "environments", "directory", "environment", "name", "and", "provider", "path", "to", "terraform", "state", "file", "and", "a", "logger", "and", "builds", "the", "environment", "stuct", "used", "to", "initial", "terr...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/cli/command/environment.go#L47-L75
132,862
hashicorp/nomad
e2e/cli/command/environment.go
provision
func (env *environment) provision(nomadPath string) (*envResults, error) { tfArgs := []string{"apply", "-auto-approve", "-input=false", "-no-color", "-state", env.tfState, "-var", fmt.Sprintf("nomad_binary=%s", path.Join(nomadPath, "nomad")), env.tfPath, } // Setup the 'terraform apply' command ctx := contex...
go
func (env *environment) provision(nomadPath string) (*envResults, error) { tfArgs := []string{"apply", "-auto-approve", "-input=false", "-no-color", "-state", env.tfState, "-var", fmt.Sprintf("nomad_binary=%s", path.Join(nomadPath, "nomad")), env.tfPath, } // Setup the 'terraform apply' command ctx := contex...
[ "func", "(", "env", "*", "environment", ")", "provision", "(", "nomadPath", "string", ")", "(", "*", "envResults", ",", "error", ")", "{", "tfArgs", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ","...
// provision calls terraform to setup the environment with the given nomad binary
[ "provision", "calls", "terraform", "to", "setup", "the", "environment", "with", "the", "given", "nomad", "binary" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/cli/command/environment.go#L103-L178
132,863
hashicorp/nomad
e2e/cli/command/environment.go
destroy
func (env *environment) destroy() error { tfArgs := []string{"destroy", "-auto-approve", "-no-color", "-state", env.tfState, "-var", "nomad_binary=", env.tfPath, } cmd := exec.Command(env.tf, tfArgs...) // Funnel the stdout/stderr to logging stderr, err := cmd.StderrPipe() if err != nil { return fmt.Erro...
go
func (env *environment) destroy() error { tfArgs := []string{"destroy", "-auto-approve", "-no-color", "-state", env.tfState, "-var", "nomad_binary=", env.tfPath, } cmd := exec.Command(env.tf, tfArgs...) // Funnel the stdout/stderr to logging stderr, err := cmd.StderrPipe() if err != nil { return fmt.Erro...
[ "func", "(", "env", "*", "environment", ")", "destroy", "(", ")", "error", "{", "tfArgs", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "env", ".", "tfState", ",", "\"", "\"", ",", "\"", "\...
// destroy calls terraform to destroy the environment
[ "destroy", "calls", "terraform", "to", "destroy", "the", "environment" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/cli/command/environment.go#L181-L210
132,864
hashicorp/nomad
client/allocrunner/taskrunner/logmon_hook.go
reattach
func (h *logmonHook) reattach(req *interfaces.TaskStopRequest) error { reattachConfig, err := reattachConfigFromHookData(req.ExistingState) if err != nil { return err } // Give up if there's no reattach config if reattachConfig == nil { return nil } return h.launchLogMon(reattachConfig) }
go
func (h *logmonHook) reattach(req *interfaces.TaskStopRequest) error { reattachConfig, err := reattachConfigFromHookData(req.ExistingState) if err != nil { return err } // Give up if there's no reattach config if reattachConfig == nil { return nil } return h.launchLogMon(reattachConfig) }
[ "func", "(", "h", "*", "logmonHook", ")", "reattach", "(", "req", "*", "interfaces", ".", "TaskStopRequest", ")", "error", "{", "reattachConfig", ",", "err", ":=", "reattachConfigFromHookData", "(", "req", ".", "ExistingState", ")", "\n", "if", "err", "!=", ...
// reattach to a running logmon if possible. Will not start a new logmon.
[ "reattach", "to", "a", "running", "logmon", "if", "possible", ".", "Will", "not", "start", "a", "new", "logmon", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/logmon_hook.go#L198-L210
132,865
hashicorp/nomad
client/gc.go
Run
func (a *AllocGarbageCollector) Run() { ticker := time.NewTicker(a.config.Interval) for { select { case <-a.triggerCh: case <-ticker.C: case <-a.shutdownCh: ticker.Stop() return } if err := a.keepUsageBelowThreshold(); err != nil { a.logger.Error("error garbage collecting allocations", "error", ...
go
func (a *AllocGarbageCollector) Run() { ticker := time.NewTicker(a.config.Interval) for { select { case <-a.triggerCh: case <-ticker.C: case <-a.shutdownCh: ticker.Stop() return } if err := a.keepUsageBelowThreshold(); err != nil { a.logger.Error("error garbage collecting allocations", "error", ...
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "Run", "(", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "a", ".", "config", ".", "Interval", ")", "\n", "for", "{", "select", "{", "case", "<-", "a", ".", "triggerCh", ":", "case", "...
// Run the periodic garbage collector.
[ "Run", "the", "periodic", "garbage", "collector", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L89-L104
132,866
hashicorp/nomad
client/gc.go
keepUsageBelowThreshold
func (a *AllocGarbageCollector) keepUsageBelowThreshold() error { for { select { case <-a.shutdownCh: return nil default: } // Check if we have enough free space if err := a.statsCollector.Collect(); err != nil { return err } // See if we are below thresholds for used disk space and inode usage...
go
func (a *AllocGarbageCollector) keepUsageBelowThreshold() error { for { select { case <-a.shutdownCh: return nil default: } // Check if we have enough free space if err := a.statsCollector.Collect(); err != nil { return err } // See if we are below thresholds for used disk space and inode usage...
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "keepUsageBelowThreshold", "(", ")", "error", "{", "for", "{", "select", "{", "case", "<-", "a", ".", "shutdownCh", ":", "return", "nil", "\n", "default", ":", "}", "\n\n", "// Check if we have enough free s...
// keepUsageBelowThreshold collects disk usage information and garbage collects // allocations to make disk space available.
[ "keepUsageBelowThreshold", "collects", "disk", "usage", "information", "and", "garbage", "collects", "allocations", "to", "make", "disk", "space", "available", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L117-L168
132,867
hashicorp/nomad
client/gc.go
destroyAllocRunner
func (a *AllocGarbageCollector) destroyAllocRunner(allocID string, ar AllocRunner, reason string) { a.logger.Info("garbage collecting allocation", "alloc_id", allocID, "reason", reason) // Acquire the destroy lock select { case <-a.shutdownCh: return case a.destroyCh <- struct{}{}: } ar.Destroy() select { ...
go
func (a *AllocGarbageCollector) destroyAllocRunner(allocID string, ar AllocRunner, reason string) { a.logger.Info("garbage collecting allocation", "alloc_id", allocID, "reason", reason) // Acquire the destroy lock select { case <-a.shutdownCh: return case a.destroyCh <- struct{}{}: } ar.Destroy() select { ...
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "destroyAllocRunner", "(", "allocID", "string", ",", "ar", "AllocRunner", ",", "reason", "string", ")", "{", "a", ".", "logger", ".", "Info", "(", "\"", "\"", ",", "\"", "\"", ",", "allocID", ",", "\...
// destroyAllocRunner is used to destroy an allocation runner. It will acquire a // lock to restrict parallelism and then destroy the alloc runner, returning // once the allocation has been destroyed.
[ "destroyAllocRunner", "is", "used", "to", "destroy", "an", "allocation", "runner", ".", "It", "will", "acquire", "a", "lock", "to", "restrict", "parallelism", "and", "then", "destroy", "the", "alloc", "runner", "returning", "once", "the", "allocation", "has", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L173-L194
132,868
hashicorp/nomad
client/gc.go
Collect
func (a *AllocGarbageCollector) Collect(allocID string) bool { gcAlloc := a.allocRunners.Remove(allocID) if gcAlloc == nil { a.logger.Debug("alloc was already garbage collected", "alloc_id", allocID) return false } a.destroyAllocRunner(allocID, gcAlloc.allocRunner, "forced collection") return true }
go
func (a *AllocGarbageCollector) Collect(allocID string) bool { gcAlloc := a.allocRunners.Remove(allocID) if gcAlloc == nil { a.logger.Debug("alloc was already garbage collected", "alloc_id", allocID) return false } a.destroyAllocRunner(allocID, gcAlloc.allocRunner, "forced collection") return true }
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "Collect", "(", "allocID", "string", ")", "bool", "{", "gcAlloc", ":=", "a", ".", "allocRunners", ".", "Remove", "(", "allocID", ")", "\n", "if", "gcAlloc", "==", "nil", "{", "a", ".", "logger", ".",...
// Collect garbage collects a single allocation on a node. Returns true if // alloc was found and garbage collected; otherwise false.
[ "Collect", "garbage", "collects", "a", "single", "allocation", "on", "a", "node", ".", "Returns", "true", "if", "alloc", "was", "found", "and", "garbage", "collected", ";", "otherwise", "false", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L202-L211
132,869
hashicorp/nomad
client/gc.go
CollectAll
func (a *AllocGarbageCollector) CollectAll() { for { select { case <-a.shutdownCh: return default: } gcAlloc := a.allocRunners.Pop() if gcAlloc == nil { return } go a.destroyAllocRunner(gcAlloc.allocID, gcAlloc.allocRunner, "forced full node collection") } }
go
func (a *AllocGarbageCollector) CollectAll() { for { select { case <-a.shutdownCh: return default: } gcAlloc := a.allocRunners.Pop() if gcAlloc == nil { return } go a.destroyAllocRunner(gcAlloc.allocID, gcAlloc.allocRunner, "forced full node collection") } }
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "CollectAll", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "a", ".", "shutdownCh", ":", "return", "\n", "default", ":", "}", "\n\n", "gcAlloc", ":=", "a", ".", "allocRunners", ".", "Pop", ...
// CollectAll garbage collects all terminated allocations on a node
[ "CollectAll", "garbage", "collects", "all", "terminated", "allocations", "on", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L214-L229
132,870
hashicorp/nomad
client/gc.go
MakeRoomFor
func (a *AllocGarbageCollector) MakeRoomFor(allocations []*structs.Allocation) error { if len(allocations) == 0 { // Nothing to make room for! return nil } // GC allocs until below the max limit + the new allocations max := a.config.MaxAllocs - len(allocations) for a.allocCounter.NumAllocs() > max { select ...
go
func (a *AllocGarbageCollector) MakeRoomFor(allocations []*structs.Allocation) error { if len(allocations) == 0 { // Nothing to make room for! return nil } // GC allocs until below the max limit + the new allocations max := a.config.MaxAllocs - len(allocations) for a.allocCounter.NumAllocs() > max { select ...
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "MakeRoomFor", "(", "allocations", "[", "]", "*", "structs", ".", "Allocation", ")", "error", "{", "if", "len", "(", "allocations", ")", "==", "0", "{", "// Nothing to make room for!", "return", "nil", "\n...
// MakeRoomFor garbage collects enough number of allocations in the terminal // state to make room for new allocations
[ "MakeRoomFor", "garbage", "collects", "enough", "number", "of", "allocations", "in", "the", "terminal", "state", "to", "make", "room", "for", "new", "allocations" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L233-L335
132,871
hashicorp/nomad
client/gc.go
MarkForCollection
func (a *AllocGarbageCollector) MarkForCollection(allocID string, ar AllocRunner) { if a.allocRunners.Push(allocID, ar) { a.logger.Info("marking allocation for GC", "alloc_id", allocID) } }
go
func (a *AllocGarbageCollector) MarkForCollection(allocID string, ar AllocRunner) { if a.allocRunners.Push(allocID, ar) { a.logger.Info("marking allocation for GC", "alloc_id", allocID) } }
[ "func", "(", "a", "*", "AllocGarbageCollector", ")", "MarkForCollection", "(", "allocID", "string", ",", "ar", "AllocRunner", ")", "{", "if", "a", ".", "allocRunners", ".", "Push", "(", "allocID", ",", "ar", ")", "{", "a", ".", "logger", ".", "Info", "...
// MarkForCollection starts tracking an allocation for Garbage Collection
[ "MarkForCollection", "starts", "tracking", "an", "allocation", "for", "Garbage", "Collection" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L338-L342
132,872
hashicorp/nomad
client/gc.go
Push
func (i *IndexedGCAllocPQ) Push(allocID string, ar AllocRunner) bool { i.pqLock.Lock() defer i.pqLock.Unlock() if _, ok := i.index[allocID]; ok { // No work to do return false } gcAlloc := &GCAlloc{ timeStamp: time.Now(), allocID: allocID, allocRunner: ar, } i.index[allocID] = gcAlloc heap.Push...
go
func (i *IndexedGCAllocPQ) Push(allocID string, ar AllocRunner) bool { i.pqLock.Lock() defer i.pqLock.Unlock() if _, ok := i.index[allocID]; ok { // No work to do return false } gcAlloc := &GCAlloc{ timeStamp: time.Now(), allocID: allocID, allocRunner: ar, } i.index[allocID] = gcAlloc heap.Push...
[ "func", "(", "i", "*", "IndexedGCAllocPQ", ")", "Push", "(", "allocID", "string", ",", "ar", "AllocRunner", ")", "bool", "{", "i", ".", "pqLock", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "pqLock", ".", "Unlock", "(", ")", "\n\n", "if", "_", ...
// Push an alloc runner into the GC queue. Returns true if alloc was added, // false if the alloc already existed.
[ "Push", "an", "alloc", "runner", "into", "the", "GC", "queue", ".", "Returns", "true", "if", "alloc", "was", "added", "false", "if", "the", "alloc", "already", "existed", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L403-L419
132,873
hashicorp/nomad
client/gc.go
Remove
func (i *IndexedGCAllocPQ) Remove(allocID string) *GCAlloc { i.pqLock.Lock() defer i.pqLock.Unlock() if gcAlloc, ok := i.index[allocID]; ok { heap.Remove(&i.heap, gcAlloc.index) delete(i.index, allocID) return gcAlloc } return nil }
go
func (i *IndexedGCAllocPQ) Remove(allocID string) *GCAlloc { i.pqLock.Lock() defer i.pqLock.Unlock() if gcAlloc, ok := i.index[allocID]; ok { heap.Remove(&i.heap, gcAlloc.index) delete(i.index, allocID) return gcAlloc } return nil }
[ "func", "(", "i", "*", "IndexedGCAllocPQ", ")", "Remove", "(", "allocID", "string", ")", "*", "GCAlloc", "{", "i", ".", "pqLock", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "pqLock", ".", "Unlock", "(", ")", "\n\n", "if", "gcAlloc", ",", "ok",...
// Remove alloc from GC. Returns nil if alloc doesn't exist.
[ "Remove", "alloc", "from", "GC", ".", "Returns", "nil", "if", "alloc", "doesn", "t", "exist", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/gc.go#L435-L446
132,874
hashicorp/nomad
command/alloc_status.go
futureEvalTimePretty
func futureEvalTimePretty(evalID string, client *api.Client) string { evaluation, _, err := client.Evaluations().Info(evalID, nil) // Eval time is not a critical output, // don't return it on errors, if its not set or already in the past if err != nil || evaluation.WaitUntil.IsZero() || time.Now().After(evaluation....
go
func futureEvalTimePretty(evalID string, client *api.Client) string { evaluation, _, err := client.Evaluations().Info(evalID, nil) // Eval time is not a critical output, // don't return it on errors, if its not set or already in the past if err != nil || evaluation.WaitUntil.IsZero() || time.Now().After(evaluation....
[ "func", "futureEvalTimePretty", "(", "evalID", "string", ",", "client", "*", "api", ".", "Client", ")", "string", "{", "evaluation", ",", "_", ",", "err", ":=", "client", ".", "Evaluations", "(", ")", ".", "Info", "(", "evalID", ",", "nil", ")", "\n", ...
// futureEvalTimePretty returns when the eval is eligible to reschedule // relative to current time, based on the WaitUntil field
[ "futureEvalTimePretty", "returns", "when", "the", "eval", "is", "eligible", "to", "reschedule", "relative", "to", "current", "time", "based", "on", "the", "WaitUntil", "field" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_status.go#L304-L312
132,875
hashicorp/nomad
command/alloc_status.go
outputTaskDetails
func (c *AllocStatusCommand) outputTaskDetails(alloc *api.Allocation, stats *api.AllocResourceUsage, displayStats bool) { for task := range c.sortedTaskStateIterator(alloc.TaskStates) { state := alloc.TaskStates[task] c.Ui.Output(c.Colorize().Color(fmt.Sprintf("\n[bold]Task %q is %q[reset]", task, state.State))) ...
go
func (c *AllocStatusCommand) outputTaskDetails(alloc *api.Allocation, stats *api.AllocResourceUsage, displayStats bool) { for task := range c.sortedTaskStateIterator(alloc.TaskStates) { state := alloc.TaskStates[task] c.Ui.Output(c.Colorize().Color(fmt.Sprintf("\n[bold]Task %q is %q[reset]", task, state.State))) ...
[ "func", "(", "c", "*", "AllocStatusCommand", ")", "outputTaskDetails", "(", "alloc", "*", "api", ".", "Allocation", ",", "stats", "*", "api", ".", "AllocResourceUsage", ",", "displayStats", "bool", ")", "{", "for", "task", ":=", "range", "c", ".", "sortedT...
// outputTaskDetails prints task details for each task in the allocation, // optionally printing verbose statistics if displayStats is set
[ "outputTaskDetails", "prints", "task", "details", "for", "each", "task", "in", "the", "allocation", "optionally", "printing", "verbose", "statistics", "if", "displayStats", "is", "set" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_status.go#L316-L324
132,876
hashicorp/nomad
command/alloc_status.go
outputTaskStatus
func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) { basic := []string{ fmt.Sprintf("Started At|%s", formatTaskTimes(state.StartedAt)), fmt.Sprintf("Finished At|%s", formatTaskTimes(state.FinishedAt)), fmt.Sprintf("Total Restarts|%d", state.Restarts), fmt.Sprintf("Last Restart|%s", formatTaskT...
go
func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) { basic := []string{ fmt.Sprintf("Started At|%s", formatTaskTimes(state.StartedAt)), fmt.Sprintf("Finished At|%s", formatTaskTimes(state.FinishedAt)), fmt.Sprintf("Total Restarts|%d", state.Restarts), fmt.Sprintf("Last Restart|%s", formatTaskT...
[ "func", "(", "c", "*", "AllocStatusCommand", ")", "outputTaskStatus", "(", "state", "*", "api", ".", "TaskState", ")", "{", "basic", ":=", "[", "]", "string", "{", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "formatTaskTimes", "(", "state", ".", "Star...
// outputTaskStatus prints out a list of the most recent events for the given // task state.
[ "outputTaskStatus", "prints", "out", "a", "list", "of", "the", "most", "recent", "events", "for", "the", "given", "task", "state", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_status.go#L336-L362
132,877
hashicorp/nomad
command/alloc_status.go
outputTaskResources
func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task string, stats *api.AllocResourceUsage, displayStats bool) { resource, ok := alloc.TaskResources[task] if !ok { return } c.Ui.Output("Task Resources") var addr []string for _, nw := range resource.Networks { ports := append(nw.Dynami...
go
func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task string, stats *api.AllocResourceUsage, displayStats bool) { resource, ok := alloc.TaskResources[task] if !ok { return } c.Ui.Output("Task Resources") var addr []string for _, nw := range resource.Networks { ports := append(nw.Dynami...
[ "func", "(", "c", "*", "AllocStatusCommand", ")", "outputTaskResources", "(", "alloc", "*", "api", ".", "Allocation", ",", "task", "string", ",", "stats", "*", "api", ".", "AllocResourceUsage", ",", "displayStats", "bool", ")", "{", "resource", ",", "ok", ...
// outputTaskResources prints the task resources for the passed task and if // displayStats is set, verbose resource usage statistics
[ "outputTaskResources", "prints", "the", "task", "resources", "for", "the", "passed", "task", "and", "if", "displayStats", "is", "set", "verbose", "resource", "usage", "statistics" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_status.go#L477-L537
132,878
hashicorp/nomad
command/alloc_status.go
shortTaskStatus
func (c *AllocStatusCommand) shortTaskStatus(alloc *api.Allocation) { tasks := make([]string, 0, len(alloc.TaskStates)+1) tasks = append(tasks, "Name|State|Last Event|Time") for task := range c.sortedTaskStateIterator(alloc.TaskStates) { state := alloc.TaskStates[task] lastState := state.State var lastEvent, l...
go
func (c *AllocStatusCommand) shortTaskStatus(alloc *api.Allocation) { tasks := make([]string, 0, len(alloc.TaskStates)+1) tasks = append(tasks, "Name|State|Last Event|Time") for task := range c.sortedTaskStateIterator(alloc.TaskStates) { state := alloc.TaskStates[task] lastState := state.State var lastEvent, l...
[ "func", "(", "c", "*", "AllocStatusCommand", ")", "shortTaskStatus", "(", "alloc", "*", "api", ".", "Allocation", ")", "{", "tasks", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "alloc", ".", "TaskStates", ")", "+", "1", ")", "...
// shortTaskStatus prints out the current state of each task.
[ "shortTaskStatus", "prints", "out", "the", "current", "state", "of", "each", "task", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_status.go#L619-L640
132,879
hashicorp/nomad
command/alloc_status.go
sortedTaskStateIterator
func (c *AllocStatusCommand) sortedTaskStateIterator(m map[string]*api.TaskState) <-chan string { output := make(chan string, len(m)) keys := make([]string, len(m)) i := 0 for k := range m { keys[i] = k i++ } sort.Strings(keys) for _, key := range keys { output <- key } close(output) return output }
go
func (c *AllocStatusCommand) sortedTaskStateIterator(m map[string]*api.TaskState) <-chan string { output := make(chan string, len(m)) keys := make([]string, len(m)) i := 0 for k := range m { keys[i] = k i++ } sort.Strings(keys) for _, key := range keys { output <- key } close(output) return output }
[ "func", "(", "c", "*", "AllocStatusCommand", ")", "sortedTaskStateIterator", "(", "m", "map", "[", "string", "]", "*", "api", ".", "TaskState", ")", "<-", "chan", "string", "{", "output", ":=", "make", "(", "chan", "string", ",", "len", "(", "m", ")", ...
// sortedTaskStateIterator is a helper that takes the task state map and returns a // channel that returns the keys in a sorted order.
[ "sortedTaskStateIterator", "is", "a", "helper", "that", "takes", "the", "task", "state", "map", "and", "returns", "a", "channel", "that", "returns", "the", "keys", "in", "a", "sorted", "order", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/alloc_status.go#L644-L660
132,880
hashicorp/nomad
client/pluginmanager/drivermanager/manager.go
New
func New(c *Config) *manager { ctx, cancel := context.WithCancel(context.Background()) return &manager{ logger: c.Logger.Named("driver_mgr"), state: c.State, ctx: ctx, cancel: cancel, loader: c.Loader, pluginConfig: c.PluginConfig...
go
func New(c *Config) *manager { ctx, cancel := context.WithCancel(context.Background()) return &manager{ logger: c.Logger.Named("driver_mgr"), state: c.State, ctx: ctx, cancel: cancel, loader: c.Loader, pluginConfig: c.PluginConfig...
[ "func", "New", "(", "c", "*", "Config", ")", "*", "manager", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "return", "&", "manager", "{", "logger", ":", "c", ".", "Logger", "....
// New returns a new driver manager
[ "New", "returns", "a", "new", "driver", "manager" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/manager.go#L132-L149
132,881
hashicorp/nomad
client/pluginmanager/drivermanager/manager.go
Run
func (m *manager) Run() { // Load any previous plugin reattach configuration if err := m.loadReattachConfigs(); err != nil { m.logger.Warn("unable to load driver plugin reattach configs, a driver process may have been leaked", "error", err) } // Get driver plugins driversPlugins := m.loader.Catalog()[base.Pl...
go
func (m *manager) Run() { // Load any previous plugin reattach configuration if err := m.loadReattachConfigs(); err != nil { m.logger.Warn("unable to load driver plugin reattach configs, a driver process may have been leaked", "error", err) } // Get driver plugins driversPlugins := m.loader.Catalog()[base.Pl...
[ "func", "(", "m", "*", "manager", ")", "Run", "(", ")", "{", "// Load any previous plugin reattach configuration", "if", "err", ":=", "m", ".", "loadReattachConfigs", "(", ")", ";", "err", "!=", "nil", "{", "m", ".", "logger", ".", "Warn", "(", "\"", "\"...
// Run starts the manager, initializes driver plugins and blocks until Shutdown // is called.
[ "Run", "starts", "the", "manager", "initializes", "driver", "plugins", "and", "blocks", "until", "Shutdown", "is", "called", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/manager.go#L156-L209
132,882
hashicorp/nomad
client/pluginmanager/drivermanager/manager.go
fetchPluginReattachConfig
func (m *manager) fetchPluginReattachConfig(id loader.PluginID) (*plugin.ReattachConfig, bool) { m.reattachConfigLock.Lock() defer m.reattachConfigLock.Unlock() if cfg, ok := m.reattachConfigs[id]; ok { c, err := pstructs.ReattachConfigToGoPlugin(cfg) if err != nil { m.logger.Warn("failed to read plugin reat...
go
func (m *manager) fetchPluginReattachConfig(id loader.PluginID) (*plugin.ReattachConfig, bool) { m.reattachConfigLock.Lock() defer m.reattachConfigLock.Unlock() if cfg, ok := m.reattachConfigs[id]; ok { c, err := pstructs.ReattachConfigToGoPlugin(cfg) if err != nil { m.logger.Warn("failed to read plugin reat...
[ "func", "(", "m", "*", "manager", ")", "fetchPluginReattachConfig", "(", "id", "loader", ".", "PluginID", ")", "(", "*", "plugin", ".", "ReattachConfig", ",", "bool", ")", "{", "m", ".", "reattachConfigLock", ".", "Lock", "(", ")", "\n", "defer", "m", ...
// fetchPluginReattachConfig is used as a callback to the instance managers and // retrieves the plugin reattach config. If it has not been stored it will // return nil
[ "fetchPluginReattachConfig", "is", "used", "as", "a", "callback", "to", "the", "instance", "managers", "and", "retrieves", "the", "plugin", "reattach", "config", ".", "If", "it", "has", "not", "been", "stored", "it", "will", "return", "nil" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/pluginmanager/drivermanager/manager.go#L352-L366
132,883
hashicorp/nomad
client/lib/fifo/fifo_unix.go
CreateAndRead
func CreateAndRead(path string) (func() (io.ReadCloser, error), error) { // create first if err := mkfifo(path, 0600); err != nil && !os.IsExist(err) { return nil, fmt.Errorf("error creating fifo %v: %v", path, err) } openFn := func() (io.ReadCloser, error) { return os.OpenFile(path, unix.O_RDONLY, os.ModeName...
go
func CreateAndRead(path string) (func() (io.ReadCloser, error), error) { // create first if err := mkfifo(path, 0600); err != nil && !os.IsExist(err) { return nil, fmt.Errorf("error creating fifo %v: %v", path, err) } openFn := func() (io.ReadCloser, error) { return os.OpenFile(path, unix.O_RDONLY, os.ModeName...
[ "func", "CreateAndRead", "(", "path", "string", ")", "(", "func", "(", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", ",", "error", ")", "{", "// create first", "if", "err", ":=", "mkfifo", "(", "path", ",", "0600", ")", ";", "err", "!=", "n...
// CreateAndRead creates a fifo at the given path, and returns an open function for reading. // The fifo must not exist already, or that it's already a fifo file // // It returns a reader open function that may block until a writer opens // so it's advised to run it in a goroutine different from reader goroutine
[ "CreateAndRead", "creates", "a", "fifo", "at", "the", "given", "path", "and", "returns", "an", "open", "function", "for", "reading", ".", "The", "fifo", "must", "not", "exist", "already", "or", "that", "it", "s", "already", "a", "fifo", "file", "It", "re...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/fifo/fifo_unix.go#L18-L29
132,884
hashicorp/nomad
client/lib/fifo/fifo_unix.go
OpenWriter
func OpenWriter(path string) (io.WriteCloser, error) { return os.OpenFile(path, unix.O_WRONLY, os.ModeNamedPipe) }
go
func OpenWriter(path string) (io.WriteCloser, error) { return os.OpenFile(path, unix.O_WRONLY, os.ModeNamedPipe) }
[ "func", "OpenWriter", "(", "path", "string", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "return", "os", ".", "OpenFile", "(", "path", ",", "unix", ".", "O_WRONLY", ",", "os", ".", "ModeNamedPipe", ")", "\n", "}" ]
// OpenWriter opens a fifo file for writer, assuming it already exists, returns io.WriteCloser
[ "OpenWriter", "opens", "a", "fifo", "file", "for", "writer", "assuming", "it", "already", "exists", "returns", "io", ".", "WriteCloser" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/lib/fifo/fifo_unix.go#L32-L34
132,885
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
setAlloc
func (tr *TaskRunner) setAlloc(updated *structs.Allocation, task *structs.Task) { tr.allocLock.Lock() defer tr.allocLock.Unlock() tr.taskLock.Lock() defer tr.taskLock.Unlock() tr.alloc = updated tr.task = task }
go
func (tr *TaskRunner) setAlloc(updated *structs.Allocation, task *structs.Task) { tr.allocLock.Lock() defer tr.allocLock.Unlock() tr.taskLock.Lock() defer tr.taskLock.Unlock() tr.alloc = updated tr.task = task }
[ "func", "(", "tr", "*", "TaskRunner", ")", "setAlloc", "(", "updated", "*", "structs", ".", "Allocation", ",", "task", "*", "structs", ".", "Task", ")", "{", "tr", ".", "allocLock", ".", "Lock", "(", ")", "\n", "defer", "tr", ".", "allocLock", ".", ...
// setAlloc and task on TaskRunner
[ "setAlloc", "and", "task", "on", "TaskRunner" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L15-L24
132,886
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
setVaultToken
func (tr *TaskRunner) setVaultToken(token string) { tr.vaultTokenLock.Lock() defer tr.vaultTokenLock.Unlock() // Update the Vault token on the runner tr.vaultToken = token // Update the task's environment tr.envBuilder.SetVaultToken(token, tr.clientConfig.VaultConfig.Namespace, tr.task.Vault.Env) }
go
func (tr *TaskRunner) setVaultToken(token string) { tr.vaultTokenLock.Lock() defer tr.vaultTokenLock.Unlock() // Update the Vault token on the runner tr.vaultToken = token // Update the task's environment tr.envBuilder.SetVaultToken(token, tr.clientConfig.VaultConfig.Namespace, tr.task.Vault.Env) }
[ "func", "(", "tr", "*", "TaskRunner", ")", "setVaultToken", "(", "token", "string", ")", "{", "tr", ".", "vaultTokenLock", ".", "Lock", "(", ")", "\n", "defer", "tr", ".", "vaultTokenLock", ".", "Unlock", "(", ")", "\n\n", "// Update the Vault token on the r...
// setVaultToken updates the vault token on the task runner as well as in the // task's environment. These two places must be set atomically to avoid a task // seeing a different token on the task runner and in its environment.
[ "setVaultToken", "updates", "the", "vault", "token", "on", "the", "task", "runner", "as", "well", "as", "in", "the", "task", "s", "environment", ".", "These", "two", "places", "must", "be", "set", "atomically", "to", "avoid", "a", "task", "seeing", "a", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L52-L61
132,887
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
getDriverHandle
func (tr *TaskRunner) getDriverHandle() *DriverHandle { tr.handleLock.Lock() defer tr.handleLock.Unlock() return tr.handle }
go
func (tr *TaskRunner) getDriverHandle() *DriverHandle { tr.handleLock.Lock() defer tr.handleLock.Unlock() return tr.handle }
[ "func", "(", "tr", "*", "TaskRunner", ")", "getDriverHandle", "(", ")", "*", "DriverHandle", "{", "tr", ".", "handleLock", ".", "Lock", "(", ")", "\n", "defer", "tr", ".", "handleLock", ".", "Unlock", "(", ")", "\n", "return", "tr", ".", "handle", "\...
// getDriverHandle returns a driver handle.
[ "getDriverHandle", "returns", "a", "driver", "handle", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L64-L68
132,888
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
setDriverHandle
func (tr *TaskRunner) setDriverHandle(handle *DriverHandle) { tr.handleLock.Lock() defer tr.handleLock.Unlock() tr.handle = handle // Update the environment's driver network tr.envBuilder.SetDriverNetwork(handle.net) }
go
func (tr *TaskRunner) setDriverHandle(handle *DriverHandle) { tr.handleLock.Lock() defer tr.handleLock.Unlock() tr.handle = handle // Update the environment's driver network tr.envBuilder.SetDriverNetwork(handle.net) }
[ "func", "(", "tr", "*", "TaskRunner", ")", "setDriverHandle", "(", "handle", "*", "DriverHandle", ")", "{", "tr", ".", "handleLock", ".", "Lock", "(", ")", "\n", "defer", "tr", ".", "handleLock", ".", "Unlock", "(", ")", "\n", "tr", ".", "handle", "=...
// setDriverHandle sets the driver handle and updates the driver network in the // task's environment.
[ "setDriverHandle", "sets", "the", "driver", "handle", "and", "updates", "the", "driver", "network", "in", "the", "task", "s", "environment", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L72-L79
132,889
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
setKillErr
func (tr *TaskRunner) setKillErr(err error) { tr.killErrLock.Lock() defer tr.killErrLock.Unlock() tr.killErr = err }
go
func (tr *TaskRunner) setKillErr(err error) { tr.killErrLock.Lock() defer tr.killErrLock.Unlock() tr.killErr = err }
[ "func", "(", "tr", "*", "TaskRunner", ")", "setKillErr", "(", "err", "error", ")", "{", "tr", ".", "killErrLock", ".", "Lock", "(", ")", "\n", "defer", "tr", ".", "killErrLock", ".", "Unlock", "(", ")", "\n", "tr", ".", "killErr", "=", "err", "\n",...
// setKillErr stores any error that arouse while killing the task
[ "setKillErr", "stores", "any", "error", "that", "arouse", "while", "killing", "the", "task" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L91-L95
132,890
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
getKillErr
func (tr *TaskRunner) getKillErr() error { tr.killErrLock.Lock() defer tr.killErrLock.Unlock() return tr.killErr }
go
func (tr *TaskRunner) getKillErr() error { tr.killErrLock.Lock() defer tr.killErrLock.Unlock() return tr.killErr }
[ "func", "(", "tr", "*", "TaskRunner", ")", "getKillErr", "(", ")", "error", "{", "tr", ".", "killErrLock", ".", "Lock", "(", ")", "\n", "defer", "tr", ".", "killErrLock", ".", "Unlock", "(", ")", "\n", "return", "tr", ".", "killErr", "\n", "}" ]
// getKillErr returns any error that arouse while killing the task
[ "getKillErr", "returns", "any", "error", "that", "arouse", "while", "killing", "the", "task" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L98-L102
132,891
hashicorp/nomad
client/allocrunner/taskrunner/task_runner_getters.go
hookState
func (tr *TaskRunner) hookState(name string) *state.HookState { tr.stateLock.RLock() defer tr.stateLock.RUnlock() var s *state.HookState if tr.localState.Hooks != nil { s = tr.localState.Hooks[name].Copy() } return s }
go
func (tr *TaskRunner) hookState(name string) *state.HookState { tr.stateLock.RLock() defer tr.stateLock.RUnlock() var s *state.HookState if tr.localState.Hooks != nil { s = tr.localState.Hooks[name].Copy() } return s }
[ "func", "(", "tr", "*", "TaskRunner", ")", "hookState", "(", "name", "string", ")", "*", "state", ".", "HookState", "{", "tr", ".", "stateLock", ".", "RLock", "(", ")", "\n", "defer", "tr", ".", "stateLock", ".", "RUnlock", "(", ")", "\n\n", "var", ...
// hookState returns the state for the given hook or nil if no state is // persisted for the hook.
[ "hookState", "returns", "the", "state", "for", "the", "given", "hook", "or", "nil", "if", "no", "state", "is", "persisted", "for", "the", "hook", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/task_runner_getters.go#L106-L115
132,892
hashicorp/nomad
drivers/qemu/driver.go
getMonitorPath
func (d *Driver) getMonitorPath(dir string, fingerPrint *drivers.Fingerprint) (string, error) { var longPathSupport bool currentQemuVer := fingerPrint.Attributes[driverVersionAttr] currentQemuSemver := semver.New(currentQemuVer.GoString()) if currentQemuSemver.LessThan(*qemuVersionLongSocketPathFix) { longPathSup...
go
func (d *Driver) getMonitorPath(dir string, fingerPrint *drivers.Fingerprint) (string, error) { var longPathSupport bool currentQemuVer := fingerPrint.Attributes[driverVersionAttr] currentQemuSemver := semver.New(currentQemuVer.GoString()) if currentQemuSemver.LessThan(*qemuVersionLongSocketPathFix) { longPathSup...
[ "func", "(", "d", "*", "Driver", ")", "getMonitorPath", "(", "dir", "string", ",", "fingerPrint", "*", "drivers", ".", "Fingerprint", ")", "(", "string", ",", "error", ")", "{", "var", "longPathSupport", "bool", "\n", "currentQemuVer", ":=", "fingerPrint", ...
// getMonitorPath is used to determine whether a qemu monitor socket can be // safely created and accessed in the task directory by the version of qemu // present on the host. If it is safe to use, the socket's full path is // returned along with a nil error. Otherwise, an empty string is returned // along with a descr...
[ "getMonitorPath", "is", "used", "to", "determine", "whether", "a", "qemu", "monitor", "socket", "can", "be", "safely", "created", "and", "accessed", "in", "the", "task", "directory", "by", "the", "version", "of", "qemu", "present", "on", "the", "host", ".", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/qemu/driver.go#L615-L631
132,893
hashicorp/nomad
drivers/qemu/driver.go
sendQemuShutdown
func sendQemuShutdown(logger hclog.Logger, monitorPath string, userPid int) error { if monitorPath == "" { return errors.New("monitorPath not set") } monitorSocket, err := net.Dial("unix", monitorPath) if err != nil { logger.Warn("could not connect to qemu monitor", "pid", userPid, "monitorPath", monitorPath, "...
go
func sendQemuShutdown(logger hclog.Logger, monitorPath string, userPid int) error { if monitorPath == "" { return errors.New("monitorPath not set") } monitorSocket, err := net.Dial("unix", monitorPath) if err != nil { logger.Warn("could not connect to qemu monitor", "pid", userPid, "monitorPath", monitorPath, "...
[ "func", "sendQemuShutdown", "(", "logger", "hclog", ".", "Logger", ",", "monitorPath", "string", ",", "userPid", "int", ")", "error", "{", "if", "monitorPath", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n"...
// sendQemuShutdown attempts to issue an ACPI power-off command via the qemu // monitor
[ "sendQemuShutdown", "attempts", "to", "issue", "an", "ACPI", "power", "-", "off", "command", "via", "the", "qemu", "monitor" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/qemu/driver.go#L635-L651
132,894
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
NewAllocWatcher
func NewAllocWatcher(c Config) (PrevAllocWatcher, PrevAllocMigrator) { if c.Alloc.PreviousAllocation == "" && c.PreemptedRunners == nil { return NoopPrevAlloc{}, NoopPrevAlloc{} } var prevAllocWatchers []PrevAllocWatcher var prevAllocMigrator PrevAllocMigrator = NoopPrevAlloc{} // We have a previous allocation...
go
func NewAllocWatcher(c Config) (PrevAllocWatcher, PrevAllocMigrator) { if c.Alloc.PreviousAllocation == "" && c.PreemptedRunners == nil { return NoopPrevAlloc{}, NoopPrevAlloc{} } var prevAllocWatchers []PrevAllocWatcher var prevAllocMigrator PrevAllocMigrator = NoopPrevAlloc{} // We have a previous allocation...
[ "func", "NewAllocWatcher", "(", "c", "Config", ")", "(", "PrevAllocWatcher", ",", "PrevAllocMigrator", ")", "{", "if", "c", ".", "Alloc", ".", "PreviousAllocation", "==", "\"", "\"", "&&", "c", ".", "PreemptedRunners", "==", "nil", "{", "return", "NoopPrevAl...
// NewAllocWatcher creates a PrevAllocWatcher appropriate for whether this // alloc's previous allocation was local or remote. If this alloc has no // previous alloc then a noop implementation is returned.
[ "NewAllocWatcher", "creates", "a", "PrevAllocWatcher", "appropriate", "for", "whether", "this", "alloc", "s", "previous", "allocation", "was", "local", "or", "remote", ".", "If", "this", "alloc", "has", "no", "previous", "alloc", "then", "a", "noop", "implementa...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L158-L188
132,895
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
IsWaiting
func (p *localPrevAlloc) IsWaiting() bool { p.waitingLock.RLock() b := p.waiting p.waitingLock.RUnlock() return b }
go
func (p *localPrevAlloc) IsWaiting() bool { p.waitingLock.RLock() b := p.waiting p.waitingLock.RUnlock() return b }
[ "func", "(", "p", "*", "localPrevAlloc", ")", "IsWaiting", "(", ")", "bool", "{", "p", ".", "waitingLock", ".", "RLock", "(", ")", "\n", "b", ":=", "p", ".", "waiting", "\n", "p", ".", "waitingLock", ".", "RUnlock", "(", ")", "\n", "return", "b", ...
// IsWaiting returns true if there's a concurrent call inside Wait
[ "IsWaiting", "returns", "true", "if", "there", "s", "a", "concurrent", "call", "inside", "Wait" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L226-L231
132,896
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
Wait
func (p *localPrevAlloc) Wait(ctx context.Context) error { p.waitingLock.Lock() p.waiting = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.waiting = false p.waitingLock.Unlock() }() defer p.prevListener.Close() // Don't bother blocking for updates from the previous alloc if it has // ...
go
func (p *localPrevAlloc) Wait(ctx context.Context) error { p.waitingLock.Lock() p.waiting = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.waiting = false p.waitingLock.Unlock() }() defer p.prevListener.Close() // Don't bother blocking for updates from the previous alloc if it has // ...
[ "func", "(", "p", "*", "localPrevAlloc", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "error", "{", "p", ".", "waitingLock", ".", "Lock", "(", ")", "\n", "p", ".", "waiting", "=", "true", "\n", "p", ".", "waitingLock", ".", "Unlock", "(...
// Wait on a local alloc to become terminal, exit, or the context to be done.
[ "Wait", "on", "a", "local", "alloc", "to", "become", "terminal", "exit", "or", "the", "context", "to", "be", "done", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L242-L273
132,897
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
Migrate
func (p *localPrevAlloc) Migrate(ctx context.Context, dest *allocdir.AllocDir) error { if !p.sticky { // Not a sticky volume, nothing to migrate return nil } p.waitingLock.Lock() p.migrating = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.migrating = false p.waitingLock.Unlock() }(...
go
func (p *localPrevAlloc) Migrate(ctx context.Context, dest *allocdir.AllocDir) error { if !p.sticky { // Not a sticky volume, nothing to migrate return nil } p.waitingLock.Lock() p.migrating = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.migrating = false p.waitingLock.Unlock() }(...
[ "func", "(", "p", "*", "localPrevAlloc", ")", "Migrate", "(", "ctx", "context", ".", "Context", ",", "dest", "*", "allocdir", ".", "AllocDir", ")", "error", "{", "if", "!", "p", ".", "sticky", "{", "// Not a sticky volume, nothing to migrate", "return", "nil...
// Migrate from previous local alloc dir to destination alloc dir.
[ "Migrate", "from", "previous", "local", "alloc", "dir", "to", "destination", "alloc", "dir", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L276-L302
132,898
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
IsMigrating
func (p *remotePrevAlloc) IsMigrating() bool { p.waitingLock.RLock() b := p.migrating p.waitingLock.RUnlock() return b }
go
func (p *remotePrevAlloc) IsMigrating() bool { p.waitingLock.RLock() b := p.migrating p.waitingLock.RUnlock() return b }
[ "func", "(", "p", "*", "remotePrevAlloc", ")", "IsMigrating", "(", ")", "bool", "{", "p", ".", "waitingLock", ".", "RLock", "(", ")", "\n", "b", ":=", "p", ".", "migrating", "\n", "p", ".", "waitingLock", ".", "RUnlock", "(", ")", "\n", "return", "...
// IsMigrating returns true if there's a concurrent call inside Migrate
[ "IsMigrating", "returns", "true", "if", "there", "s", "a", "concurrent", "call", "inside", "Migrate" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L353-L358
132,899
hashicorp/nomad
client/allocwatcher/alloc_watcher.go
Wait
func (p *remotePrevAlloc) Wait(ctx context.Context) error { p.waitingLock.Lock() p.waiting = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.waiting = false p.waitingLock.Unlock() }() p.logger.Debug("waiting for remote previous alloc to terminate") req := structs.AllocSpecificRequest{ ...
go
func (p *remotePrevAlloc) Wait(ctx context.Context) error { p.waitingLock.Lock() p.waiting = true p.waitingLock.Unlock() defer func() { p.waitingLock.Lock() p.waiting = false p.waitingLock.Unlock() }() p.logger.Debug("waiting for remote previous alloc to terminate") req := structs.AllocSpecificRequest{ ...
[ "func", "(", "p", "*", "remotePrevAlloc", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "error", "{", "p", ".", "waitingLock", ".", "Lock", "(", ")", "\n", "p", ".", "waiting", "=", "true", "\n", "p", ".", "waitingLock", ".", "Unlock", "...
// Wait until the remote previous allocation has terminated.
[ "Wait", "until", "the", "remote", "previous", "allocation", "has", "terminated", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocwatcher/alloc_watcher.go#L361-L420