id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
133,000
hashicorp/nomad
nomad/state/state_store.go
UpsertJob
func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.upsertJobImpl(index, job, false, txn); err != nil { return err } txn.Commit() return nil }
go
func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.upsertJobImpl(index, job, false, txn); err != nil { return err } txn.Commit() return nil }
[ "func", "(", "s", "*", "StateStore", ")", "UpsertJob", "(", "index", "uint64", ",", "job", "*", "structs", ".", "Job", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", ")", "...
// UpsertJob is used to register a job or update a job definition
[ "UpsertJob", "is", "used", "to", "register", "a", "job", "or", "update", "a", "job", "definition" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L936-L944
133,001
hashicorp/nomad
nomad/state/state_store.go
UpsertJobTxn
func (s *StateStore) UpsertJobTxn(index uint64, job *structs.Job, txn Txn) error { return s.upsertJobImpl(index, job, false, txn) }
go
func (s *StateStore) UpsertJobTxn(index uint64, job *structs.Job, txn Txn) error { return s.upsertJobImpl(index, job, false, txn) }
[ "func", "(", "s", "*", "StateStore", ")", "UpsertJobTxn", "(", "index", "uint64", ",", "job", "*", "structs", ".", "Job", ",", "txn", "Txn", ")", "error", "{", "return", "s", ".", "upsertJobImpl", "(", "index", ",", "job", ",", "false", ",", "txn", ...
// UpsertJobTxn is used to register a job or update a job definition, like UpsertJob, // but in a transaction. Useful for when making multiple modifications atomically
[ "UpsertJobTxn", "is", "used", "to", "register", "a", "job", "or", "update", "a", "job", "definition", "like", "UpsertJob", "but", "in", "a", "transaction", ".", "Useful", "for", "when", "making", "multiple", "modifications", "atomically" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L948-L950
133,002
hashicorp/nomad
nomad/state/state_store.go
upsertJobImpl
func (s *StateStore) upsertJobImpl(index uint64, job *structs.Job, keepVersion bool, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } // Assert the namespace exists if exists, err := s.namespaceExists(txn, ...
go
func (s *StateStore) upsertJobImpl(index uint64, job *structs.Job, keepVersion bool, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } // Assert the namespace exists if exists, err := s.namespaceExists(txn, ...
[ "func", "(", "s", "*", "StateStore", ")", "upsertJobImpl", "(", "index", "uint64", ",", "job", "*", "structs", ".", "Job", ",", "keepVersion", "bool", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// COMPAT 0.7: Upgrade old objects that do not have...
// upsertJobImpl is the implementation for registering a job or updating a job definition
[ "upsertJobImpl", "is", "the", "implementation", "for", "registering", "a", "job", "or", "updating", "a", "job", "definition" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L953-L1028
133,003
hashicorp/nomad
nomad/state/state_store.go
DeleteJobTxn
func (s *StateStore) DeleteJobTxn(index uint64, namespace, jobID string, txn Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Lookup the node existing, err := txn.First("jobs", "id", namespace, jobID) if err != nil { re...
go
func (s *StateStore) DeleteJobTxn(index uint64, namespace, jobID string, txn Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Lookup the node existing, err := txn.First("jobs", "id", namespace, jobID) if err != nil { re...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteJobTxn", "(", "index", "uint64", ",", "namespace", ",", "jobID", "string", ",", "txn", "Txn", ")", "error", "{", "// COMPAT 0.7: Upgrade old objects that do not have namespaces", "if", "namespace", "==", "\"", "\"",...
// DeleteJobTxn is used to deregister a job, like DeleteJob, // but in a transaction. Useful for when making multiple modifications atomically
[ "DeleteJobTxn", "is", "used", "to", "deregister", "a", "job", "like", "DeleteJob", "but", "in", "a", "transaction", ".", "Useful", "for", "when", "making", "multiple", "modifications", "atomically" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1044-L1132
133,004
hashicorp/nomad
nomad/state/state_store.go
deleteJobVersions
func (s *StateStore) deleteJobVersions(index uint64, job *structs.Job, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } iter, err := txn.Get("job_version", "id_prefix", job.Namespace, job.ID) if err != nil ...
go
func (s *StateStore) deleteJobVersions(index uint64, job *structs.Job, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } iter, err := txn.Get("job_version", "id_prefix", job.Namespace, job.ID) if err != nil ...
[ "func", "(", "s", "*", "StateStore", ")", "deleteJobVersions", "(", "index", "uint64", ",", "job", "*", "structs", ".", "Job", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// COMPAT 0.7: Upgrade old objects that do not have namespaces", "if", "job",...
// deleteJobVersions deletes all versions of the given job.
[ "deleteJobVersions", "deletes", "all", "versions", "of", "the", "given", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1135-L1176
133,005
hashicorp/nomad
nomad/state/state_store.go
upsertJobVersion
func (s *StateStore) upsertJobVersion(index uint64, job *structs.Job, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } // Insert the job if err := txn.Insert("job_version", job); err != nil { return fmt.E...
go
func (s *StateStore) upsertJobVersion(index uint64, job *structs.Job, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } // Insert the job if err := txn.Insert("job_version", job); err != nil { return fmt.E...
[ "func", "(", "s", "*", "StateStore", ")", "upsertJobVersion", "(", "index", "uint64", ",", "job", "*", "structs", ".", "Job", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// COMPAT 0.7: Upgrade old objects that do not have namespaces", "if", "job", ...
// upsertJobVersion inserts a job into its historic version table and limits the // number of job versions that are tracked.
[ "upsertJobVersion", "inserts", "a", "job", "into", "its", "historic", "version", "table", "and", "limits", "the", "number", "of", "job", "versions", "that", "are", "tracked", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1180-L1230
133,006
hashicorp/nomad
nomad/state/state_store.go
JobByIDTxn
func (s *StateStore) JobByIDTxn(ws memdb.WatchSet, namespace, id string, txn Txn) (*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("jobs", "id", namespace, id) if err != nil...
go
func (s *StateStore) JobByIDTxn(ws memdb.WatchSet, namespace, id string, txn Txn) (*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("jobs", "id", namespace, id) if err != nil...
[ "func", "(", "s", "*", "StateStore", ")", "JobByIDTxn", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ",", "txn", "Txn", ")", "(", "*", "structs", ".", "Job", ",", "error", ")", "{", "// COMPAT 0.7: Upgrade old objects that do...
// JobByIDTxn is used to lookup a job by its ID, like JobByID. JobByID returns the job version // accessible through in the transaction
[ "JobByIDTxn", "is", "used", "to", "lookup", "a", "job", "by", "its", "ID", "like", "JobByID", ".", "JobByID", "returns", "the", "job", "version", "accessible", "through", "in", "the", "transaction" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1241-L1257
133,007
hashicorp/nomad
nomad/state/state_store.go
JobVersionsByID
func (s *StateStore) JobVersionsByID(ws memdb.WatchSet, namespace, id string) ([]*structs.Job, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } return s.jobVersionByID(txn, &ws, namespace, id) }
go
func (s *StateStore) JobVersionsByID(ws memdb.WatchSet, namespace, id string) ([]*structs.Job, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } return s.jobVersionByID(txn, &ws, namespace, id) }
[ "func", "(", "s", "*", "StateStore", ")", "JobVersionsByID", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ")", "(", "[", "]", "*", "structs", ".", "Job", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Tx...
// JobVersionsByID returns all the tracked versions of a job.
[ "JobVersionsByID", "returns", "all", "the", "tracked", "versions", "of", "a", "job", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1279-L1288
133,008
hashicorp/nomad
nomad/state/state_store.go
jobVersionByID
func (s *StateStore) jobVersionByID(txn *memdb.Txn, ws *memdb.WatchSet, namespace, id string) ([]*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get all the historic jobs for this ID iter, err := txn.Get("job_ve...
go
func (s *StateStore) jobVersionByID(txn *memdb.Txn, ws *memdb.WatchSet, namespace, id string) ([]*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get all the historic jobs for this ID iter, err := txn.Get("job_ve...
[ "func", "(", "s", "*", "StateStore", ")", "jobVersionByID", "(", "txn", "*", "memdb", ".", "Txn", ",", "ws", "*", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ")", "(", "[", "]", "*", "structs", ".", "Job", ",", "error", ")", ...
// jobVersionByID is the underlying implementation for retrieving all tracked // versions of a job and is called under an existing transaction. A watch set // can optionally be passed in to add the job histories to the watch set.
[ "jobVersionByID", "is", "the", "underlying", "implementation", "for", "retrieving", "all", "tracked", "versions", "of", "a", "job", "and", "is", "called", "under", "an", "existing", "transaction", ".", "A", "watch", "set", "can", "optionally", "be", "passed", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1293-L1331
133,009
hashicorp/nomad
nomad/state/state_store.go
JobByIDAndVersion
func (s *StateStore) JobByIDAndVersion(ws memdb.WatchSet, namespace, id string, version uint64) (*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } txn := s.db.Txn(false) return s.jobByIDAndVersionImpl(ws, namespace, i...
go
func (s *StateStore) JobByIDAndVersion(ws memdb.WatchSet, namespace, id string, version uint64) (*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } txn := s.db.Txn(false) return s.jobByIDAndVersionImpl(ws, namespace, i...
[ "func", "(", "s", "*", "StateStore", ")", "JobByIDAndVersion", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ",", "version", "uint64", ")", "(", "*", "structs", ".", "Job", ",", "error", ")", "{", "// COMPAT 0.7: Upgrade old o...
// JobByIDAndVersion returns the job identified by its ID and Version. The // passed watchset may be nil.
[ "JobByIDAndVersion", "returns", "the", "job", "identified", "by", "its", "ID", "and", "Version", ".", "The", "passed", "watchset", "may", "be", "nil", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1335-L1342
133,010
hashicorp/nomad
nomad/state/state_store.go
jobByIDAndVersionImpl
func (s *StateStore) jobByIDAndVersionImpl(ws memdb.WatchSet, namespace, id string, version uint64, txn *memdb.Txn) (*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("job_ver...
go
func (s *StateStore) jobByIDAndVersionImpl(ws memdb.WatchSet, namespace, id string, version uint64, txn *memdb.Txn) (*structs.Job, error) { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("job_ver...
[ "func", "(", "s", "*", "StateStore", ")", "jobByIDAndVersionImpl", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ",", "version", "uint64", ",", "txn", "*", "memdb", ".", "Txn", ")", "(", "*", "structs", ".", "Job", ",", ...
// jobByIDAndVersionImpl returns the job identified by its ID and Version. The // passed watchset may be nil.
[ "jobByIDAndVersionImpl", "returns", "the", "job", "identified", "by", "its", "ID", "and", "Version", ".", "The", "passed", "watchset", "may", "be", "nil", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1346-L1368
133,011
hashicorp/nomad
nomad/state/state_store.go
JobsByNamespace
func (s *StateStore) JobsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) return s.jobsByNamespaceImpl(ws, namespace, txn) }
go
func (s *StateStore) JobsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) return s.jobsByNamespaceImpl(ws, namespace, txn) }
[ "func", "(", "s", "*", "StateStore", ")", "JobsByNamespace", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", "string", ")", "(", "memdb", ".", "ResultIterator", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")"...
// JobsByNamespace returns an iterator over all the jobs for the given namespace
[ "JobsByNamespace", "returns", "an", "iterator", "over", "all", "the", "jobs", "for", "the", "given", "namespace" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1399-L1402
133,012
hashicorp/nomad
nomad/state/state_store.go
JobSummaryByID
func (s *StateStore) JobSummaryByID(ws memdb.WatchSet, namespace, jobID string) (*structs.JobSummary, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("job_summary"...
go
func (s *StateStore) JobSummaryByID(ws memdb.WatchSet, namespace, jobID string) (*structs.JobSummary, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("job_summary"...
[ "func", "(", "s", "*", "StateStore", ")", "JobSummaryByID", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "jobID", "string", ")", "(", "*", "structs", ".", "JobSummary", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", ...
// JobSummary returns a job summary object which matches a specific id.
[ "JobSummary", "returns", "a", "job", "summary", "object", "which", "matches", "a", "specific", "id", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1463-L1484
133,013
hashicorp/nomad
nomad/state/state_store.go
UpsertPeriodicLaunch
func (s *StateStore) UpsertPeriodicLaunch(index uint64, launch *structs.PeriodicLaunch) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if launch.Namespace == "" { launch.Namespace = structs.DefaultNamespace } // Check if the job already exists e...
go
func (s *StateStore) UpsertPeriodicLaunch(index uint64, launch *structs.PeriodicLaunch) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if launch.Namespace == "" { launch.Namespace = structs.DefaultNamespace } // Check if the job already exists e...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertPeriodicLaunch", "(", "index", "uint64", ",", "launch", "*", "structs", ".", "PeriodicLaunch", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "...
// UpsertPeriodicLaunch is used to register a launch or update it.
[ "UpsertPeriodicLaunch", "is", "used", "to", "register", "a", "launch", "or", "update", "it", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1521-L1555
133,014
hashicorp/nomad
nomad/state/state_store.go
DeletePeriodicLaunch
func (s *StateStore) DeletePeriodicLaunch(index uint64, namespace, jobID string) error { txn := s.db.Txn(true) defer txn.Abort() err := s.DeletePeriodicLaunchTxn(index, namespace, jobID, txn) if err == nil { txn.Commit() } return err }
go
func (s *StateStore) DeletePeriodicLaunch(index uint64, namespace, jobID string) error { txn := s.db.Txn(true) defer txn.Abort() err := s.DeletePeriodicLaunchTxn(index, namespace, jobID, txn) if err == nil { txn.Commit() } return err }
[ "func", "(", "s", "*", "StateStore", ")", "DeletePeriodicLaunch", "(", "index", "uint64", ",", "namespace", ",", "jobID", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(",...
// DeletePeriodicLaunch is used to delete the periodic launch
[ "DeletePeriodicLaunch", "is", "used", "to", "delete", "the", "periodic", "launch" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1558-L1567
133,015
hashicorp/nomad
nomad/state/state_store.go
DeletePeriodicLaunchTxn
func (s *StateStore) DeletePeriodicLaunchTxn(index uint64, namespace, jobID string, txn Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Lookup the launch existing, err := txn.First("periodic_launch", "id", namespace, jobI...
go
func (s *StateStore) DeletePeriodicLaunchTxn(index uint64, namespace, jobID string, txn Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Lookup the launch existing, err := txn.First("periodic_launch", "id", namespace, jobI...
[ "func", "(", "s", "*", "StateStore", ")", "DeletePeriodicLaunchTxn", "(", "index", "uint64", ",", "namespace", ",", "jobID", "string", ",", "txn", "Txn", ")", "error", "{", "// COMPAT 0.7: Upgrade old objects that do not have namespaces", "if", "namespace", "==", "\...
// DeletePeriodicLaunchTxn is used to delete the periodic launch, like DeletePeriodicLaunch // but in a transaction. Useful for when making multiple modifications atomically
[ "DeletePeriodicLaunchTxn", "is", "used", "to", "delete", "the", "periodic", "launch", "like", "DeletePeriodicLaunch", "but", "in", "a", "transaction", ".", "Useful", "for", "when", "making", "multiple", "modifications", "atomically" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1571-L1595
133,016
hashicorp/nomad
nomad/state/state_store.go
PeriodicLaunchByID
func (s *StateStore) PeriodicLaunchByID(ws memdb.WatchSet, namespace, id string) (*structs.PeriodicLaunch, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("periodi...
go
func (s *StateStore) PeriodicLaunchByID(ws memdb.WatchSet, namespace, id string) (*structs.PeriodicLaunch, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } watchCh, existing, err := txn.FirstWatch("periodi...
[ "func", "(", "s", "*", "StateStore", ")", "PeriodicLaunchByID", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ")", "(", "*", "structs", ".", "PeriodicLaunch", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Tx...
// PeriodicLaunchByID is used to lookup a periodic launch by the periodic job // ID.
[ "PeriodicLaunchByID", "is", "used", "to", "lookup", "a", "periodic", "launch", "by", "the", "periodic", "job", "ID", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1599-L1618
133,017
hashicorp/nomad
nomad/state/state_store.go
UpsertEvals
func (s *StateStore) UpsertEvals(index uint64, evals []*structs.Evaluation) error { txn := s.db.Txn(true) defer txn.Abort() err := s.UpsertEvalsTxn(index, evals, txn) if err == nil { txn.Commit() } return err }
go
func (s *StateStore) UpsertEvals(index uint64, evals []*structs.Evaluation) error { txn := s.db.Txn(true) defer txn.Abort() err := s.UpsertEvalsTxn(index, evals, txn) if err == nil { txn.Commit() } return err }
[ "func", "(", "s", "*", "StateStore", ")", "UpsertEvals", "(", "index", "uint64", ",", "evals", "[", "]", "*", "structs", ".", "Evaluation", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "...
// UpsertEvals is used to upsert a set of evaluations
[ "UpsertEvals", "is", "used", "to", "upsert", "a", "set", "of", "evaluations" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1636-L1645
133,018
hashicorp/nomad
nomad/state/state_store.go
UpsertEvalsTxn
func (s *StateStore) UpsertEvalsTxn(index uint64, evals []*structs.Evaluation, txn Txn) error { // Do a nested upsert jobs := make(map[structs.NamespacedID]string, len(evals)) for _, eval := range evals { if err := s.nestedUpsertEval(txn, index, eval); err != nil { return err } tuple := structs.NamespacedI...
go
func (s *StateStore) UpsertEvalsTxn(index uint64, evals []*structs.Evaluation, txn Txn) error { // Do a nested upsert jobs := make(map[structs.NamespacedID]string, len(evals)) for _, eval := range evals { if err := s.nestedUpsertEval(txn, index, eval); err != nil { return err } tuple := structs.NamespacedI...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertEvalsTxn", "(", "index", "uint64", ",", "evals", "[", "]", "*", "structs", ".", "Evaluation", ",", "txn", "Txn", ")", "error", "{", "// Do a nested upsert", "jobs", ":=", "make", "(", "map", "[", "structs"...
// UpsertEvals is used to upsert a set of evaluations, like UpsertEvals // but in a transaction. Useful for when making multiple modifications atomically
[ "UpsertEvals", "is", "used", "to", "upsert", "a", "set", "of", "evaluations", "like", "UpsertEvals", "but", "in", "a", "transaction", ".", "Useful", "for", "when", "making", "multiple", "modifications", "atomically" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1649-L1670
133,019
hashicorp/nomad
nomad/state/state_store.go
updateEvalModifyIndex
func (s *StateStore) updateEvalModifyIndex(txn *memdb.Txn, index uint64, evalID string) error { // Lookup the evaluation existing, err := txn.First("evals", "id", evalID) if err != nil { return fmt.Errorf("eval lookup failed: %v", err) } if existing == nil { s.logger.Error("unable to find eval", "eval_id", eva...
go
func (s *StateStore) updateEvalModifyIndex(txn *memdb.Txn, index uint64, evalID string) error { // Lookup the evaluation existing, err := txn.First("evals", "id", evalID) if err != nil { return fmt.Errorf("eval lookup failed: %v", err) } if existing == nil { s.logger.Error("unable to find eval", "eval_id", eva...
[ "func", "(", "s", "*", "StateStore", ")", "updateEvalModifyIndex", "(", "txn", "*", "memdb", ".", "Txn", ",", "index", "uint64", ",", "evalID", "string", ")", "error", "{", "// Lookup the evaluation", "existing", ",", "err", ":=", "txn", ".", "First", "(",...
// updateEvalModifyIndex is used to update the modify index of an evaluation that has been // through a scheduler pass. This is done as part of plan apply. It ensures that when a subsequent // scheduler workers process a re-queued evaluation it sees any partial updates from the plan apply.
[ "updateEvalModifyIndex", "is", "used", "to", "update", "the", "modify", "index", "of", "an", "evaluation", "that", "has", "been", "through", "a", "scheduler", "pass", ".", "This", "is", "done", "as", "part", "of", "plan", "apply", ".", "It", "ensures", "th...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1779-L1801
133,020
hashicorp/nomad
nomad/state/state_store.go
DeleteEval
func (s *StateStore) DeleteEval(index uint64, evals []string, allocs []string) error { txn := s.db.Txn(true) defer txn.Abort() jobs := make(map[structs.NamespacedID]string, len(evals)) for _, eval := range evals { existing, err := txn.First("evals", "id", eval) if err != nil { return fmt.Errorf("eval lookup...
go
func (s *StateStore) DeleteEval(index uint64, evals []string, allocs []string) error { txn := s.db.Txn(true) defer txn.Abort() jobs := make(map[structs.NamespacedID]string, len(evals)) for _, eval := range evals { existing, err := txn.First("evals", "id", eval) if err != nil { return fmt.Errorf("eval lookup...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteEval", "(", "index", "uint64", ",", "evals", "[", "]", "string", ",", "allocs", "[", "]", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn...
// DeleteEval is used to delete an evaluation
[ "DeleteEval", "is", "used", "to", "delete", "an", "evaluation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1804-L1857
133,021
hashicorp/nomad
nomad/state/state_store.go
evalNamespaceFilter
func evalNamespaceFilter(namespace string) func(interface{}) bool { return func(raw interface{}) bool { eval, ok := raw.(*structs.Evaluation) if !ok { return true } return eval.Namespace != namespace } }
go
func evalNamespaceFilter(namespace string) func(interface{}) bool { return func(raw interface{}) bool { eval, ok := raw.(*structs.Evaluation) if !ok { return true } return eval.Namespace != namespace } }
[ "func", "evalNamespaceFilter", "(", "namespace", "string", ")", "func", "(", "interface", "{", "}", ")", "bool", "{", "return", "func", "(", "raw", "interface", "{", "}", ")", "bool", "{", "eval", ",", "ok", ":=", "raw", ".", "(", "*", "structs", "."...
// evalNamespaceFilter returns a filter function that filters all evaluations // not in the given namespace.
[ "evalNamespaceFilter", "returns", "a", "filter", "function", "that", "filters", "all", "evaluations", "not", "in", "the", "given", "namespace", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1901-L1910
133,022
hashicorp/nomad
nomad/state/state_store.go
EvalsByJob
func (s *StateStore) EvalsByJob(ws memdb.WatchSet, namespace, jobID string) ([]*structs.Evaluation, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get an iterator over the node allocations iter, err ...
go
func (s *StateStore) EvalsByJob(ws memdb.WatchSet, namespace, jobID string) ([]*structs.Evaluation, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get an iterator over the node allocations iter, err ...
[ "func", "(", "s", "*", "StateStore", ")", "EvalsByJob", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "jobID", "string", ")", "(", "[", "]", "*", "structs", ".", "Evaluation", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", ...
// EvalsByJob returns all the evaluations by job id
[ "EvalsByJob", "returns", "all", "the", "evaluations", "by", "job", "id" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1913-L1946
133,023
hashicorp/nomad
nomad/state/state_store.go
UpdateAllocsFromClient
func (s *StateStore) UpdateAllocsFromClient(index uint64, allocs []*structs.Allocation) error { txn := s.db.Txn(true) defer txn.Abort() // Handle each of the updated allocations for _, alloc := range allocs { if err := s.nestedUpdateAllocFromClient(txn, index, alloc); err != nil { return err } } // Updat...
go
func (s *StateStore) UpdateAllocsFromClient(index uint64, allocs []*structs.Allocation) error { txn := s.db.Txn(true) defer txn.Abort() // Handle each of the updated allocations for _, alloc := range allocs { if err := s.nestedUpdateAllocFromClient(txn, index, alloc); err != nil { return err } } // Updat...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateAllocsFromClient", "(", "index", "uint64", ",", "allocs", "[", "]", "*", "structs", ".", "Allocation", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn"...
// UpdateAllocsFromClient is used to update an allocation based on input // from a client. While the schedulers are the authority on the allocation for // most things, some updates are authoritative from the client. Specifically, // the desired state comes from the schedulers, while the actual state comes // from clien...
[ "UpdateAllocsFromClient", "is", "used", "to", "update", "an", "allocation", "based", "on", "input", "from", "a", "client", ".", "While", "the", "schedulers", "are", "the", "authority", "on", "the", "allocation", "for", "most", "things", "some", "updates", "are...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L1984-L2002
133,024
hashicorp/nomad
nomad/state/state_store.go
nestedUpdateAllocFromClient
func (s *StateStore) nestedUpdateAllocFromClient(txn *memdb.Txn, index uint64, alloc *structs.Allocation) error { // Look for existing alloc existing, err := txn.First("allocs", "id", alloc.ID) if err != nil { return fmt.Errorf("alloc lookup failed: %v", err) } // Nothing to do if this does not exist if existi...
go
func (s *StateStore) nestedUpdateAllocFromClient(txn *memdb.Txn, index uint64, alloc *structs.Allocation) error { // Look for existing alloc existing, err := txn.First("allocs", "id", alloc.ID) if err != nil { return fmt.Errorf("alloc lookup failed: %v", err) } // Nothing to do if this does not exist if existi...
[ "func", "(", "s", "*", "StateStore", ")", "nestedUpdateAllocFromClient", "(", "txn", "*", "memdb", ".", "Txn", ",", "index", "uint64", ",", "alloc", "*", "structs", ".", "Allocation", ")", "error", "{", "// Look for existing alloc", "existing", ",", "err", "...
// nestedUpdateAllocFromClient is used to nest an update of an allocation with client status
[ "nestedUpdateAllocFromClient", "is", "used", "to", "nest", "an", "update", "of", "an", "allocation", "with", "client", "status" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2005-L2090
133,025
hashicorp/nomad
nomad/state/state_store.go
UpsertAllocs
func (s *StateStore) UpsertAllocs(index uint64, allocs []*structs.Allocation) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.upsertAllocsImpl(index, allocs, txn); err != nil { return err } txn.Commit() return nil }
go
func (s *StateStore) UpsertAllocs(index uint64, allocs []*structs.Allocation) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.upsertAllocsImpl(index, allocs, txn); err != nil { return err } txn.Commit() return nil }
[ "func", "(", "s", "*", "StateStore", ")", "UpsertAllocs", "(", "index", "uint64", ",", "allocs", "[", "]", "*", "structs", ".", "Allocation", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", ...
// UpsertAllocs is used to evict a set of allocations and allocate new ones at // the same time.
[ "UpsertAllocs", "is", "used", "to", "evict", "a", "set", "of", "allocations", "and", "allocate", "new", "ones", "at", "the", "same", "time", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2094-L2102
133,026
hashicorp/nomad
nomad/state/state_store.go
UpdateAllocsDesiredTransitions
func (s *StateStore) UpdateAllocsDesiredTransitions(index uint64, allocs map[string]*structs.DesiredTransition, evals []*structs.Evaluation) error { txn := s.db.Txn(true) defer txn.Abort() // Handle each of the updated allocations for id, transition := range allocs { if err := s.nestedUpdateAllocDesiredTransit...
go
func (s *StateStore) UpdateAllocsDesiredTransitions(index uint64, allocs map[string]*structs.DesiredTransition, evals []*structs.Evaluation) error { txn := s.db.Txn(true) defer txn.Abort() // Handle each of the updated allocations for id, transition := range allocs { if err := s.nestedUpdateAllocDesiredTransit...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateAllocsDesiredTransitions", "(", "index", "uint64", ",", "allocs", "map", "[", "string", "]", "*", "structs", ".", "DesiredTransition", ",", "evals", "[", "]", "*", "structs", ".", "Evaluation", ")", "error", ...
// UpdateAllocsDesiredTransitions is used to update a set of allocations // desired transitions.
[ "UpdateAllocsDesiredTransitions", "is", "used", "to", "update", "a", "set", "of", "allocations", "desired", "transitions", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2228-L2254
133,027
hashicorp/nomad
nomad/state/state_store.go
nestedUpdateAllocDesiredTransition
func (s *StateStore) nestedUpdateAllocDesiredTransition( txn *memdb.Txn, index uint64, allocID string, transition *structs.DesiredTransition) error { // Look for existing alloc existing, err := txn.First("allocs", "id", allocID) if err != nil { return fmt.Errorf("alloc lookup failed: %v", err) } // Nothing t...
go
func (s *StateStore) nestedUpdateAllocDesiredTransition( txn *memdb.Txn, index uint64, allocID string, transition *structs.DesiredTransition) error { // Look for existing alloc existing, err := txn.First("allocs", "id", allocID) if err != nil { return fmt.Errorf("alloc lookup failed: %v", err) } // Nothing t...
[ "func", "(", "s", "*", "StateStore", ")", "nestedUpdateAllocDesiredTransition", "(", "txn", "*", "memdb", ".", "Txn", ",", "index", "uint64", ",", "allocID", "string", ",", "transition", "*", "structs", ".", "DesiredTransition", ")", "error", "{", "// Look for...
// nestedUpdateAllocDesiredTransition is used to nest an update of an // allocations desired transition
[ "nestedUpdateAllocDesiredTransition", "is", "used", "to", "nest", "an", "update", "of", "an", "allocations", "desired", "transition" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2258-L2289
133,028
hashicorp/nomad
nomad/state/state_store.go
AllocsByIDPrefix
func (s *StateStore) AllocsByIDPrefix(ws memdb.WatchSet, namespace, id string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) iter, err := txn.Get("allocs", "id_prefix", id) if err != nil { return nil, fmt.Errorf("alloc lookup failed: %v", err) } ws.Add(iter.WatchCh()) // Wrap the iterator in a filte...
go
func (s *StateStore) AllocsByIDPrefix(ws memdb.WatchSet, namespace, id string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) iter, err := txn.Get("allocs", "id_prefix", id) if err != nil { return nil, fmt.Errorf("alloc lookup failed: %v", err) } ws.Add(iter.WatchCh()) // Wrap the iterator in a filte...
[ "func", "(", "s", "*", "StateStore", ")", "AllocsByIDPrefix", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "id", "string", ")", "(", "memdb", ".", "ResultIterator", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", ...
// AllocsByIDPrefix is used to lookup allocs by prefix
[ "AllocsByIDPrefix", "is", "used", "to", "lookup", "allocs", "by", "prefix" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2309-L2322
133,029
hashicorp/nomad
nomad/state/state_store.go
allocNamespaceFilter
func allocNamespaceFilter(namespace string) func(interface{}) bool { return func(raw interface{}) bool { alloc, ok := raw.(*structs.Allocation) if !ok { return true } return alloc.Namespace != namespace } }
go
func allocNamespaceFilter(namespace string) func(interface{}) bool { return func(raw interface{}) bool { alloc, ok := raw.(*structs.Allocation) if !ok { return true } return alloc.Namespace != namespace } }
[ "func", "allocNamespaceFilter", "(", "namespace", "string", ")", "func", "(", "interface", "{", "}", ")", "bool", "{", "return", "func", "(", "raw", "interface", "{", "}", ")", "bool", "{", "alloc", ",", "ok", ":=", "raw", ".", "(", "*", "structs", "...
// allocNamespaceFilter returns a filter function that filters all allocations // not in the given namespace.
[ "allocNamespaceFilter", "returns", "a", "filter", "function", "that", "filters", "all", "allocations", "not", "in", "the", "given", "namespace", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2326-L2335
133,030
hashicorp/nomad
nomad/state/state_store.go
AllocsByNode
func (s *StateStore) AllocsByNode(ws memdb.WatchSet, node string) ([]*structs.Allocation, error) { txn := s.db.Txn(false) // Get an iterator over the node allocations, using only the // node prefix which ignores the terminal status iter, err := txn.Get("allocs", "node_prefix", node) if err != nil { return nil, ...
go
func (s *StateStore) AllocsByNode(ws memdb.WatchSet, node string) ([]*structs.Allocation, error) { txn := s.db.Txn(false) // Get an iterator over the node allocations, using only the // node prefix which ignores the terminal status iter, err := txn.Get("allocs", "node_prefix", node) if err != nil { return nil, ...
[ "func", "(", "s", "*", "StateStore", ")", "AllocsByNode", "(", "ws", "memdb", ".", "WatchSet", ",", "node", "string", ")", "(", "[", "]", "*", "structs", ".", "Allocation", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "fa...
// AllocsByNode returns all the allocations by node
[ "AllocsByNode", "returns", "all", "the", "allocations", "by", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2338-L2359
133,031
hashicorp/nomad
nomad/state/state_store.go
AllocsByJob
func (s *StateStore) AllocsByJob(ws memdb.WatchSet, namespace, jobID string, all bool) ([]*structs.Allocation, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get the job var job *structs.Job rawJob,...
go
func (s *StateStore) AllocsByJob(ws memdb.WatchSet, namespace, jobID string, all bool) ([]*structs.Allocation, error) { txn := s.db.Txn(false) // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get the job var job *structs.Job rawJob,...
[ "func", "(", "s", "*", "StateStore", ")", "AllocsByJob", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", ",", "jobID", "string", ",", "all", "bool", ")", "(", "[", "]", "*", "structs", ".", "Allocation", ",", "error", ")", "{", "txn", ":=", ...
// AllocsByJob returns all the allocations by job id
[ "AllocsByJob", "returns", "all", "the", "allocations", "by", "job", "id" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2385-L2428
133,032
hashicorp/nomad
nomad/state/state_store.go
Allocs
func (s *StateStore) Allocs(ws memdb.WatchSet) (memdb.ResultIterator, error) { txn := s.db.Txn(false) // Walk the entire table iter, err := txn.Get("allocs", "id") if err != nil { return nil, err } ws.Add(iter.WatchCh()) return iter, nil }
go
func (s *StateStore) Allocs(ws memdb.WatchSet) (memdb.ResultIterator, error) { txn := s.db.Txn(false) // Walk the entire table iter, err := txn.Get("allocs", "id") if err != nil { return nil, err } ws.Add(iter.WatchCh()) return iter, nil }
[ "func", "(", "s", "*", "StateStore", ")", "Allocs", "(", "ws", "memdb", ".", "WatchSet", ")", "(", "memdb", ".", "ResultIterator", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")", "\n\n", "// Walk the entire table", ...
// Allocs returns an iterator over all the evaluations
[ "Allocs", "returns", "an", "iterator", "over", "all", "the", "evaluations" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2477-L2489
133,033
hashicorp/nomad
nomad/state/state_store.go
AllocsByNamespace
func (s *StateStore) AllocsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) return s.allocsByNamespaceImpl(ws, txn, namespace) }
go
func (s *StateStore) AllocsByNamespace(ws memdb.WatchSet, namespace string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) return s.allocsByNamespaceImpl(ws, txn, namespace) }
[ "func", "(", "s", "*", "StateStore", ")", "AllocsByNamespace", "(", "ws", "memdb", ".", "WatchSet", ",", "namespace", "string", ")", "(", "memdb", ".", "ResultIterator", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", "...
// AllocsByNamespace returns an iterator over all the allocations in the // namespace
[ "AllocsByNamespace", "returns", "an", "iterator", "over", "all", "the", "allocations", "in", "the", "namespace" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2493-L2496
133,034
hashicorp/nomad
nomad/state/state_store.go
UpsertVaultAccessor
func (s *StateStore) UpsertVaultAccessor(index uint64, accessors []*structs.VaultAccessor) error { txn := s.db.Txn(true) defer txn.Abort() for _, accessor := range accessors { // Set the create index accessor.CreateIndex = index // Insert the accessor if err := txn.Insert("vault_accessors", accessor); err ...
go
func (s *StateStore) UpsertVaultAccessor(index uint64, accessors []*structs.VaultAccessor) error { txn := s.db.Txn(true) defer txn.Abort() for _, accessor := range accessors { // Set the create index accessor.CreateIndex = index // Insert the accessor if err := txn.Insert("vault_accessors", accessor); err ...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertVaultAccessor", "(", "index", "uint64", ",", "accessors", "[", "]", "*", "structs", ".", "VaultAccessor", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "t...
// UpsertVaultAccessors is used to register a set of Vault Accessors
[ "UpsertVaultAccessors", "is", "used", "to", "register", "a", "set", "of", "Vault", "Accessors" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2513-L2533
133,035
hashicorp/nomad
nomad/state/state_store.go
VaultAccessorsByAlloc
func (s *StateStore) VaultAccessorsByAlloc(ws memdb.WatchSet, allocID string) ([]*structs.VaultAccessor, error) { txn := s.db.Txn(false) // Get an iterator over the accessors iter, err := txn.Get("vault_accessors", "alloc_id", allocID) if err != nil { return nil, err } ws.Add(iter.WatchCh()) var out []*stru...
go
func (s *StateStore) VaultAccessorsByAlloc(ws memdb.WatchSet, allocID string) ([]*structs.VaultAccessor, error) { txn := s.db.Txn(false) // Get an iterator over the accessors iter, err := txn.Get("vault_accessors", "alloc_id", allocID) if err != nil { return nil, err } ws.Add(iter.WatchCh()) var out []*stru...
[ "func", "(", "s", "*", "StateStore", ")", "VaultAccessorsByAlloc", "(", "ws", "memdb", ".", "WatchSet", ",", "allocID", "string", ")", "(", "[", "]", "*", "structs", ".", "VaultAccessor", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn...
// VaultAccessorsByAlloc returns all the Vault accessors by alloc id
[ "VaultAccessorsByAlloc", "returns", "all", "the", "Vault", "accessors", "by", "alloc", "id" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2589-L2609
133,036
hashicorp/nomad
nomad/state/state_store.go
UpdateDeploymentStatus
func (s *StateStore) UpdateDeploymentStatus(index uint64, req *structs.DeploymentStatusUpdateRequest) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.updateDeploymentStatusImpl(index, req.DeploymentUpdate, txn); err != nil { return err } // Upsert the job if necessary if req.Job != nil { if err ...
go
func (s *StateStore) UpdateDeploymentStatus(index uint64, req *structs.DeploymentStatusUpdateRequest) error { txn := s.db.Txn(true) defer txn.Abort() if err := s.updateDeploymentStatusImpl(index, req.DeploymentUpdate, txn); err != nil { return err } // Upsert the job if necessary if req.Job != nil { if err ...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateDeploymentStatus", "(", "index", "uint64", ",", "req", "*", "structs", ".", "DeploymentStatusUpdateRequest", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "tx...
// UpdateDeploymentStatus is used to make deployment status updates and // potentially make a evaluation
[ "UpdateDeploymentStatus", "is", "used", "to", "make", "deployment", "status", "updates", "and", "potentially", "make", "a", "evaluation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2636-L2660
133,037
hashicorp/nomad
nomad/state/state_store.go
updateDeploymentStatusImpl
func (s *StateStore) updateDeploymentStatusImpl(index uint64, u *structs.DeploymentStatusUpdate, txn *memdb.Txn) error { // Retrieve deployment ws := memdb.NewWatchSet() deployment, err := s.deploymentByIDImpl(ws, u.DeploymentID, txn) if err != nil { return err } else if deployment == nil { return fmt.Errorf("...
go
func (s *StateStore) updateDeploymentStatusImpl(index uint64, u *structs.DeploymentStatusUpdate, txn *memdb.Txn) error { // Retrieve deployment ws := memdb.NewWatchSet() deployment, err := s.deploymentByIDImpl(ws, u.DeploymentID, txn) if err != nil { return err } else if deployment == nil { return fmt.Errorf("...
[ "func", "(", "s", "*", "StateStore", ")", "updateDeploymentStatusImpl", "(", "index", "uint64", ",", "u", "*", "structs", ".", "DeploymentStatusUpdate", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// Retrieve deployment", "ws", ":=", "memdb", "...
// updateDeploymentStatusImpl is used to make deployment status updates
[ "updateDeploymentStatusImpl", "is", "used", "to", "make", "deployment", "status", "updates" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2663-L2704
133,038
hashicorp/nomad
nomad/state/state_store.go
UpdateJobStability
func (s *StateStore) UpdateJobStability(index uint64, namespace, jobID string, jobVersion uint64, stable bool) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } if err := s.updateJobStabili...
go
func (s *StateStore) UpdateJobStability(index uint64, namespace, jobID string, jobVersion uint64, stable bool) error { txn := s.db.Txn(true) defer txn.Abort() // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } if err := s.updateJobStabili...
[ "func", "(", "s", "*", "StateStore", ")", "UpdateJobStability", "(", "index", "uint64", ",", "namespace", ",", "jobID", "string", ",", "jobVersion", "uint64", ",", "stable", "bool", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true...
// UpdateJobStability updates the stability of the given job and version to the // desired status.
[ "UpdateJobStability", "updates", "the", "stability", "of", "the", "given", "job", "and", "version", "to", "the", "desired", "status", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2708-L2723
133,039
hashicorp/nomad
nomad/state/state_store.go
updateJobStabilityImpl
func (s *StateStore) updateJobStabilityImpl(index uint64, namespace, jobID string, jobVersion uint64, stable bool, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get the job that is referenced job, err := s.jo...
go
func (s *StateStore) updateJobStabilityImpl(index uint64, namespace, jobID string, jobVersion uint64, stable bool, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if namespace == "" { namespace = structs.DefaultNamespace } // Get the job that is referenced job, err := s.jo...
[ "func", "(", "s", "*", "StateStore", ")", "updateJobStabilityImpl", "(", "index", "uint64", ",", "namespace", ",", "jobID", "string", ",", "jobVersion", "uint64", ",", "stable", "bool", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// COMPAT 0....
// updateJobStabilityImpl updates the stability of the given job and version
[ "updateJobStabilityImpl", "updates", "the", "stability", "of", "the", "given", "job", "and", "version" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L2726-L2751
133,040
hashicorp/nomad
nomad/state/state_store.go
Index
func (s *StateStore) Index(name string) (uint64, error) { txn := s.db.Txn(false) // Lookup the first matching index out, err := txn.First("index", "id", name) if err != nil { return 0, err } if out == nil { return 0, nil } return out.(*IndexEntry).Value, nil }
go
func (s *StateStore) Index(name string) (uint64, error) { txn := s.db.Txn(false) // Lookup the first matching index out, err := txn.First("index", "id", name) if err != nil { return 0, err } if out == nil { return 0, nil } return out.(*IndexEntry).Value, nil }
[ "func", "(", "s", "*", "StateStore", ")", "Index", "(", "name", "string", ")", "(", "uint64", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")", "\n\n", "// Lookup the first matching index", "out", ",", "err", ":=", "...
// Index finds the matching index value
[ "Index", "finds", "the", "matching", "index", "value" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3019-L3031
133,041
hashicorp/nomad
nomad/state/state_store.go
RemoveIndex
func (s *StateStore) RemoveIndex(name string) error { txn := s.db.Txn(true) defer txn.Abort() if _, err := txn.DeleteAll("index", "id", name); err != nil { return err } txn.Commit() return nil }
go
func (s *StateStore) RemoveIndex(name string) error { txn := s.db.Txn(true) defer txn.Abort() if _, err := txn.DeleteAll("index", "id", name); err != nil { return err } txn.Commit() return nil }
[ "func", "(", "s", "*", "StateStore", ")", "RemoveIndex", "(", "name", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", ")", "\n\n", "if", "_", ",", "err", ":=", "tx...
// RemoveIndex is a helper method to remove an index for testing purposes
[ "RemoveIndex", "is", "a", "helper", "method", "to", "remove", "an", "index", "for", "testing", "purposes" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3034-L3044
133,042
hashicorp/nomad
nomad/state/state_store.go
Indexes
func (s *StateStore) Indexes() (memdb.ResultIterator, error) { txn := s.db.Txn(false) // Walk the entire nodes table iter, err := txn.Get("index", "id") if err != nil { return nil, err } return iter, nil }
go
func (s *StateStore) Indexes() (memdb.ResultIterator, error) { txn := s.db.Txn(false) // Walk the entire nodes table iter, err := txn.Get("index", "id") if err != nil { return nil, err } return iter, nil }
[ "func", "(", "s", "*", "StateStore", ")", "Indexes", "(", ")", "(", "memdb", ".", "ResultIterator", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")", "\n\n", "// Walk the entire nodes table", "iter", ",", "err", ":=", ...
// Indexes returns an iterator over all the indexes
[ "Indexes", "returns", "an", "iterator", "over", "all", "the", "indexes" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3047-L3056
133,043
hashicorp/nomad
nomad/state/state_store.go
setJobStatuses
func (s *StateStore) setJobStatuses(index uint64, txn *memdb.Txn, jobs map[structs.NamespacedID]string, evalDelete bool) error { for tuple, forceStatus := range jobs { // COMPAT 0.7: Upgrade old objects that do not have namespaces if tuple.Namespace == "" { tuple.Namespace = structs.DefaultNamespace } exi...
go
func (s *StateStore) setJobStatuses(index uint64, txn *memdb.Txn, jobs map[structs.NamespacedID]string, evalDelete bool) error { for tuple, forceStatus := range jobs { // COMPAT 0.7: Upgrade old objects that do not have namespaces if tuple.Namespace == "" { tuple.Namespace = structs.DefaultNamespace } exi...
[ "func", "(", "s", "*", "StateStore", ")", "setJobStatuses", "(", "index", "uint64", ",", "txn", "*", "memdb", ".", "Txn", ",", "jobs", "map", "[", "structs", ".", "NamespacedID", "]", "string", ",", "evalDelete", "bool", ")", "error", "{", "for", "tupl...
// setJobStatuses is a helper for calling setJobStatus on multiple jobs by ID. // It takes a map of job IDs to an optional forceStatus string. It returns an // error if the job doesn't exist or setJobStatus fails.
[ "setJobStatuses", "is", "a", "helper", "for", "calling", "setJobStatus", "on", "multiple", "jobs", "by", "ID", ".", "It", "takes", "a", "map", "of", "job", "IDs", "to", "an", "optional", "forceStatus", "string", ".", "It", "returns", "an", "error", "if", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3225-L3248
133,044
hashicorp/nomad
nomad/state/state_store.go
updateSummaryWithJob
func (s *StateStore) updateSummaryWithJob(index uint64, job *structs.Job, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } // Update the job summary summaryRaw, err := txn.First("job_summary", "id", job.N...
go
func (s *StateStore) updateSummaryWithJob(index uint64, job *structs.Job, txn *memdb.Txn) error { // COMPAT 0.7: Upgrade old objects that do not have namespaces if job.Namespace == "" { job.Namespace = structs.DefaultNamespace } // Update the job summary summaryRaw, err := txn.First("job_summary", "id", job.N...
[ "func", "(", "s", "*", "StateStore", ")", "updateSummaryWithJob", "(", "index", "uint64", ",", "job", "*", "structs", ".", "Job", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// COMPAT 0.7: Upgrade old objects that do not have namespaces", "if", "jo...
// updateSummaryWithJob creates or updates job summaries when new jobs are // upserted or existing ones are updated
[ "updateSummaryWithJob", "creates", "or", "updates", "job", "summaries", "when", "new", "jobs", "are", "upserted", "or", "existing", "ones", "are", "updated" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3425-L3487
133,045
hashicorp/nomad
nomad/state/state_store.go
updateDeploymentWithAlloc
func (s *StateStore) updateDeploymentWithAlloc(index uint64, alloc, existing *structs.Allocation, txn *memdb.Txn) error { // Nothing to do if the allocation is not associated with a deployment if alloc.DeploymentID == "" { return nil } // Get the deployment ws := memdb.NewWatchSet() deployment, err := s.deploy...
go
func (s *StateStore) updateDeploymentWithAlloc(index uint64, alloc, existing *structs.Allocation, txn *memdb.Txn) error { // Nothing to do if the allocation is not associated with a deployment if alloc.DeploymentID == "" { return nil } // Get the deployment ws := memdb.NewWatchSet() deployment, err := s.deploy...
[ "func", "(", "s", "*", "StateStore", ")", "updateDeploymentWithAlloc", "(", "index", "uint64", ",", "alloc", ",", "existing", "*", "structs", ".", "Allocation", ",", "txn", "*", "memdb", ".", "Txn", ")", "error", "{", "// Nothing to do if the allocation is not a...
// updateDeploymentWithAlloc is used to update the deployment state associated // with the given allocation. The passed alloc may be updated if the deployment // status has changed to capture the modify index at which it has changed.
[ "updateDeploymentWithAlloc", "is", "used", "to", "update", "the", "deployment", "state", "associated", "with", "the", "given", "allocation", ".", "The", "passed", "alloc", "may", "be", "updated", "if", "the", "deployment", "status", "has", "changed", "to", "capt...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3492-L3580
133,046
hashicorp/nomad
nomad/state/state_store.go
UpsertACLPolicies
func (s *StateStore) UpsertACLPolicies(index uint64, policies []*structs.ACLPolicy) error { txn := s.db.Txn(true) defer txn.Abort() for _, policy := range policies { // Ensure the policy hash is non-nil. This should be done outside the state store // for performance reasons, but we check here for defense in dep...
go
func (s *StateStore) UpsertACLPolicies(index uint64, policies []*structs.ACLPolicy) error { txn := s.db.Txn(true) defer txn.Abort() for _, policy := range policies { // Ensure the policy hash is non-nil. This should be done outside the state store // for performance reasons, but we check here for defense in dep...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertACLPolicies", "(", "index", "uint64", ",", "policies", "[", "]", "*", "structs", ".", "ACLPolicy", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ...
// UpsertACLPolicies is used to create or update a set of ACL policies
[ "UpsertACLPolicies", "is", "used", "to", "create", "or", "update", "a", "set", "of", "ACL", "policies" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3728-L3767
133,047
hashicorp/nomad
nomad/state/state_store.go
DeleteACLPolicies
func (s *StateStore) DeleteACLPolicies(index uint64, names []string) error { txn := s.db.Txn(true) defer txn.Abort() // Delete the policy for _, name := range names { if _, err := txn.DeleteAll("acl_policy", "id", name); err != nil { return fmt.Errorf("deleting acl policy failed: %v", err) } } if err := t...
go
func (s *StateStore) DeleteACLPolicies(index uint64, names []string) error { txn := s.db.Txn(true) defer txn.Abort() // Delete the policy for _, name := range names { if _, err := txn.DeleteAll("acl_policy", "id", name); err != nil { return fmt.Errorf("deleting acl policy failed: %v", err) } } if err := t...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteACLPolicies", "(", "index", "uint64", ",", "names", "[", "]", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", ")", "...
// DeleteACLPolicies deletes the policies with the given names
[ "DeleteACLPolicies", "deletes", "the", "policies", "with", "the", "given", "names" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3770-L3785
133,048
hashicorp/nomad
nomad/state/state_store.go
ACLPolicyByName
func (s *StateStore) ACLPolicyByName(ws memdb.WatchSet, name string) (*structs.ACLPolicy, error) { txn := s.db.Txn(false) watchCh, existing, err := txn.FirstWatch("acl_policy", "id", name) if err != nil { return nil, fmt.Errorf("acl policy lookup failed: %v", err) } ws.Add(watchCh) if existing != nil { retu...
go
func (s *StateStore) ACLPolicyByName(ws memdb.WatchSet, name string) (*structs.ACLPolicy, error) { txn := s.db.Txn(false) watchCh, existing, err := txn.FirstWatch("acl_policy", "id", name) if err != nil { return nil, fmt.Errorf("acl policy lookup failed: %v", err) } ws.Add(watchCh) if existing != nil { retu...
[ "func", "(", "s", "*", "StateStore", ")", "ACLPolicyByName", "(", "ws", "memdb", ".", "WatchSet", ",", "name", "string", ")", "(", "*", "structs", ".", "ACLPolicy", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")",...
// ACLPolicyByName is used to lookup a policy by name
[ "ACLPolicyByName", "is", "used", "to", "lookup", "a", "policy", "by", "name" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3788-L3801
133,049
hashicorp/nomad
nomad/state/state_store.go
UpsertACLTokens
func (s *StateStore) UpsertACLTokens(index uint64, tokens []*structs.ACLToken) error { txn := s.db.Txn(true) defer txn.Abort() for _, token := range tokens { // Ensure the policy hash is non-nil. This should be done outside the state store // for performance reasons, but we check here for defense in depth. if...
go
func (s *StateStore) UpsertACLTokens(index uint64, tokens []*structs.ACLToken) error { txn := s.db.Txn(true) defer txn.Abort() for _, token := range tokens { // Ensure the policy hash is non-nil. This should be done outside the state store // for performance reasons, but we check here for defense in depth. if...
[ "func", "(", "s", "*", "StateStore", ")", "UpsertACLTokens", "(", "index", "uint64", ",", "tokens", "[", "]", "*", "structs", ".", "ACLToken", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", ...
// UpsertACLTokens is used to create or update a set of ACL tokens
[ "UpsertACLTokens", "is", "used", "to", "create", "or", "update", "a", "set", "of", "ACL", "tokens" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3830-L3874
133,050
hashicorp/nomad
nomad/state/state_store.go
DeleteACLTokens
func (s *StateStore) DeleteACLTokens(index uint64, ids []string) error { txn := s.db.Txn(true) defer txn.Abort() // Delete the tokens for _, id := range ids { if _, err := txn.DeleteAll("acl_token", "id", id); err != nil { return fmt.Errorf("deleting acl token failed: %v", err) } } if err := txn.Insert("i...
go
func (s *StateStore) DeleteACLTokens(index uint64, ids []string) error { txn := s.db.Txn(true) defer txn.Abort() // Delete the tokens for _, id := range ids { if _, err := txn.DeleteAll("acl_token", "id", id); err != nil { return fmt.Errorf("deleting acl token failed: %v", err) } } if err := txn.Insert("i...
[ "func", "(", "s", "*", "StateStore", ")", "DeleteACLTokens", "(", "index", "uint64", ",", "ids", "[", "]", "string", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "txn", ".", "Abort", "(", ")", "\n\n...
// DeleteACLTokens deletes the tokens with the given accessor ids
[ "DeleteACLTokens", "deletes", "the", "tokens", "with", "the", "given", "accessor", "ids" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3877-L3892
133,051
hashicorp/nomad
nomad/state/state_store.go
ACLTokenByAccessorIDPrefix
func (s *StateStore) ACLTokenByAccessorIDPrefix(ws memdb.WatchSet, prefix string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) iter, err := txn.Get("acl_token", "id_prefix", prefix) if err != nil { return nil, fmt.Errorf("acl token lookup failed: %v", err) } ws.Add(iter.WatchCh()) return iter, nil }
go
func (s *StateStore) ACLTokenByAccessorIDPrefix(ws memdb.WatchSet, prefix string) (memdb.ResultIterator, error) { txn := s.db.Txn(false) iter, err := txn.Get("acl_token", "id_prefix", prefix) if err != nil { return nil, fmt.Errorf("acl token lookup failed: %v", err) } ws.Add(iter.WatchCh()) return iter, nil }
[ "func", "(", "s", "*", "StateStore", ")", "ACLTokenByAccessorIDPrefix", "(", "ws", "memdb", ".", "WatchSet", ",", "prefix", "string", ")", "(", "memdb", ".", "ResultIterator", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false...
// ACLTokenByAccessorIDPrefix is used to lookup tokens by prefix
[ "ACLTokenByAccessorIDPrefix", "is", "used", "to", "lookup", "tokens", "by", "prefix" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3927-L3936
133,052
hashicorp/nomad
nomad/state/state_store.go
CanBootstrapACLToken
func (s *StateStore) CanBootstrapACLToken() (bool, uint64, error) { txn := s.db.Txn(false) // Lookup the bootstrap sentinel out, err := txn.First("index", "id", "acl_token_bootstrap") if err != nil { return false, 0, err } // No entry, we haven't bootstrapped yet if out == nil { return true, 0, nil } //...
go
func (s *StateStore) CanBootstrapACLToken() (bool, uint64, error) { txn := s.db.Txn(false) // Lookup the bootstrap sentinel out, err := txn.First("index", "id", "acl_token_bootstrap") if err != nil { return false, 0, err } // No entry, we haven't bootstrapped yet if out == nil { return true, 0, nil } //...
[ "func", "(", "s", "*", "StateStore", ")", "CanBootstrapACLToken", "(", ")", "(", "bool", ",", "uint64", ",", "error", ")", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")", "\n\n", "// Lookup the bootstrap sentinel", "out", ",", "err", "...
// CanBootstrapACLToken checks if bootstrapping is possible and returns the reset index
[ "CanBootstrapACLToken", "checks", "if", "bootstrapping", "is", "possible", "and", "returns", "the", "reset", "index" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3965-L3981
133,053
hashicorp/nomad
nomad/state/state_store.go
BootstrapACLTokens
func (s *StateStore) BootstrapACLTokens(index, resetIndex uint64, token *structs.ACLToken) error { txn := s.db.Txn(true) defer txn.Abort() // Check if we have already done a bootstrap existing, err := txn.First("index", "id", "acl_token_bootstrap") if err != nil { return fmt.Errorf("bootstrap check failed: %v",...
go
func (s *StateStore) BootstrapACLTokens(index, resetIndex uint64, token *structs.ACLToken) error { txn := s.db.Txn(true) defer txn.Abort() // Check if we have already done a bootstrap existing, err := txn.First("index", "id", "acl_token_bootstrap") if err != nil { return fmt.Errorf("bootstrap check failed: %v",...
[ "func", "(", "s", "*", "StateStore", ")", "BootstrapACLTokens", "(", "index", ",", "resetIndex", "uint64", ",", "token", "*", "structs", ".", "ACLToken", ")", "error", "{", "txn", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "tx...
// BootstrapACLToken is used to create an initial ACL token
[ "BootstrapACLToken", "is", "used", "to", "create", "an", "initial", "ACL", "token" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L3984-L4019
133,054
hashicorp/nomad
nomad/state/state_store.go
SchedulerConfig
func (s *StateStore) SchedulerConfig() (uint64, *structs.SchedulerConfiguration, error) { tx := s.db.Txn(false) defer tx.Abort() // Get the scheduler config c, err := tx.First("scheduler_config", "id") if err != nil { return 0, nil, fmt.Errorf("failed scheduler config lookup: %s", err) } config, ok := c.(*st...
go
func (s *StateStore) SchedulerConfig() (uint64, *structs.SchedulerConfiguration, error) { tx := s.db.Txn(false) defer tx.Abort() // Get the scheduler config c, err := tx.First("scheduler_config", "id") if err != nil { return 0, nil, fmt.Errorf("failed scheduler config lookup: %s", err) } config, ok := c.(*st...
[ "func", "(", "s", "*", "StateStore", ")", "SchedulerConfig", "(", ")", "(", "uint64", ",", "*", "structs", ".", "SchedulerConfiguration", ",", "error", ")", "{", "tx", ":=", "s", ".", "db", ".", "Txn", "(", "false", ")", "\n", "defer", "tx", ".", "...
// SchedulerConfig is used to get the current Scheduler configuration.
[ "SchedulerConfig", "is", "used", "to", "get", "the", "current", "Scheduler", "configuration", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4022-L4038
133,055
hashicorp/nomad
nomad/state/state_store.go
SchedulerSetConfig
func (s *StateStore) SchedulerSetConfig(idx uint64, config *structs.SchedulerConfiguration) error { tx := s.db.Txn(true) defer tx.Abort() s.schedulerSetConfigTxn(idx, tx, config) tx.Commit() return nil }
go
func (s *StateStore) SchedulerSetConfig(idx uint64, config *structs.SchedulerConfiguration) error { tx := s.db.Txn(true) defer tx.Abort() s.schedulerSetConfigTxn(idx, tx, config) tx.Commit() return nil }
[ "func", "(", "s", "*", "StateStore", ")", "SchedulerSetConfig", "(", "idx", "uint64", ",", "config", "*", "structs", ".", "SchedulerConfiguration", ")", "error", "{", "tx", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "tx", ".", ...
// SchedulerSetConfig is used to set the current Scheduler configuration.
[ "SchedulerSetConfig", "is", "used", "to", "set", "the", "current", "Scheduler", "configuration", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4041-L4049
133,056
hashicorp/nomad
nomad/state/state_store.go
WithWriteTransaction
func (s *StateStore) WithWriteTransaction(fn func(Txn) error) error { tx := s.db.Txn(true) defer tx.Abort() err := fn(tx) if err == nil { tx.Commit() } return err }
go
func (s *StateStore) WithWriteTransaction(fn func(Txn) error) error { tx := s.db.Txn(true) defer tx.Abort() err := fn(tx) if err == nil { tx.Commit() } return err }
[ "func", "(", "s", "*", "StateStore", ")", "WithWriteTransaction", "(", "fn", "func", "(", "Txn", ")", "error", ")", "error", "{", "tx", ":=", "s", ".", "db", ".", "Txn", "(", "true", ")", "\n", "defer", "tx", ".", "Abort", "(", ")", "\n\n", "err"...
// WithWriteTransaction executes the passed function within a write transaction, // and returns its result. If the invocation returns no error, the transaction // is committed; otherwise, it's aborted.
[ "WithWriteTransaction", "executes", "the", "passed", "function", "within", "a", "write", "transaction", "and", "returns", "its", "result", ".", "If", "the", "invocation", "returns", "no", "error", "the", "transaction", "is", "committed", ";", "otherwise", "it", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4054-L4063
133,057
hashicorp/nomad
nomad/state/state_store.go
DenormalizeAllocationsMap
func (s *StateSnapshot) DenormalizeAllocationsMap(nodeAllocations map[string][]*structs.Allocation, job *structs.Job) error { for nodeID, allocs := range nodeAllocations { denormalizedAllocs, err := s.DenormalizeAllocationSlice(allocs, job) if err != nil { return err } nodeAllocations[nodeID] = denormalize...
go
func (s *StateSnapshot) DenormalizeAllocationsMap(nodeAllocations map[string][]*structs.Allocation, job *structs.Job) error { for nodeID, allocs := range nodeAllocations { denormalizedAllocs, err := s.DenormalizeAllocationSlice(allocs, job) if err != nil { return err } nodeAllocations[nodeID] = denormalize...
[ "func", "(", "s", "*", "StateSnapshot", ")", "DenormalizeAllocationsMap", "(", "nodeAllocations", "map", "[", "string", "]", "[", "]", "*", "structs", ".", "Allocation", ",", "job", "*", "structs", ".", "Job", ")", "error", "{", "for", "nodeID", ",", "al...
// DenormalizeAllocationsMap takes in a map of nodes to allocations, and queries the // Allocation for each of the Allocation diffs and merges the updated attributes with // the existing Allocation, and attaches the Job provided
[ "DenormalizeAllocationsMap", "takes", "in", "a", "map", "of", "nodes", "to", "allocations", "and", "queries", "the", "Allocation", "for", "each", "of", "the", "Allocation", "diffs", "and", "merges", "the", "updated", "attributes", "with", "the", "existing", "All...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4121-L4131
133,058
hashicorp/nomad
nomad/state/state_store.go
DenormalizeAllocationSlice
func (s *StateSnapshot) DenormalizeAllocationSlice(allocs []*structs.Allocation, job *structs.Job) ([]*structs.Allocation, error) { allocDiffs := make([]*structs.AllocationDiff, len(allocs)) for i, alloc := range allocs { allocDiffs[i] = alloc.AllocationDiff() } return s.DenormalizeAllocationDiffSlice(allocDiffs...
go
func (s *StateSnapshot) DenormalizeAllocationSlice(allocs []*structs.Allocation, job *structs.Job) ([]*structs.Allocation, error) { allocDiffs := make([]*structs.AllocationDiff, len(allocs)) for i, alloc := range allocs { allocDiffs[i] = alloc.AllocationDiff() } return s.DenormalizeAllocationDiffSlice(allocDiffs...
[ "func", "(", "s", "*", "StateSnapshot", ")", "DenormalizeAllocationSlice", "(", "allocs", "[", "]", "*", "structs", ".", "Allocation", ",", "job", "*", "structs", ".", "Job", ")", "(", "[", "]", "*", "structs", ".", "Allocation", ",", "error", ")", "{"...
// DenormalizeAllocationSlice queries the Allocation for each allocation diff // represented as an Allocation and merges the updated attributes with the existing // Allocation, and attaches the Job provided.
[ "DenormalizeAllocationSlice", "queries", "the", "Allocation", "for", "each", "allocation", "diff", "represented", "as", "an", "Allocation", "and", "merges", "the", "updated", "attributes", "with", "the", "existing", "Allocation", "and", "attaches", "the", "Job", "pr...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4136-L4143
133,059
hashicorp/nomad
nomad/state/state_store.go
DenormalizeAllocationDiffSlice
func (s *StateSnapshot) DenormalizeAllocationDiffSlice(allocDiffs []*structs.AllocationDiff, job *structs.Job) ([]*structs.Allocation, error) { // Output index for denormalized Allocations j := 0 denormalizedAllocs := make([]*structs.Allocation, len(allocDiffs)) for _, allocDiff := range allocDiffs { alloc, err ...
go
func (s *StateSnapshot) DenormalizeAllocationDiffSlice(allocDiffs []*structs.AllocationDiff, job *structs.Job) ([]*structs.Allocation, error) { // Output index for denormalized Allocations j := 0 denormalizedAllocs := make([]*structs.Allocation, len(allocDiffs)) for _, allocDiff := range allocDiffs { alloc, err ...
[ "func", "(", "s", "*", "StateSnapshot", ")", "DenormalizeAllocationDiffSlice", "(", "allocDiffs", "[", "]", "*", "structs", ".", "AllocationDiff", ",", "job", "*", "structs", ".", "Job", ")", "(", "[", "]", "*", "structs", ".", "Allocation", ",", "error", ...
// DenormalizeAllocationDiffSlice queries the Allocation for each AllocationDiff and merges // the updated attributes with the existing Allocation, and attaches the Job provided
[ "DenormalizeAllocationDiffSlice", "queries", "the", "Allocation", "for", "each", "AllocationDiff", "and", "merges", "the", "updated", "attributes", "with", "the", "existing", "Allocation", "and", "attaches", "the", "Job", "provided" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4147-L4189
133,060
hashicorp/nomad
nomad/state/state_store.go
NodeRestore
func (r *StateRestore) NodeRestore(node *structs.Node) error { if err := r.txn.Insert("nodes", node); err != nil { return fmt.Errorf("node insert failed: %v", err) } return nil }
go
func (r *StateRestore) NodeRestore(node *structs.Node) error { if err := r.txn.Insert("nodes", node); err != nil { return fmt.Errorf("node insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "NodeRestore", "(", "node", "*", "structs", ".", "Node", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "node", ")", ";", "err", "!=", "nil", "{", "return", ...
// NodeRestore is used to restore a node
[ "NodeRestore", "is", "used", "to", "restore", "a", "node" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4213-L4218
133,061
hashicorp/nomad
nomad/state/state_store.go
JobRestore
func (r *StateRestore) JobRestore(job *structs.Job) error { if err := r.txn.Insert("jobs", job); err != nil { return fmt.Errorf("job insert failed: %v", err) } return nil }
go
func (r *StateRestore) JobRestore(job *structs.Job) error { if err := r.txn.Insert("jobs", job); err != nil { return fmt.Errorf("job insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "JobRestore", "(", "job", "*", "structs", ".", "Job", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "job", ")", ";", "err", "!=", "nil", "{", "return", "f...
// JobRestore is used to restore a job
[ "JobRestore", "is", "used", "to", "restore", "a", "job" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4221-L4226
133,062
hashicorp/nomad
nomad/state/state_store.go
EvalRestore
func (r *StateRestore) EvalRestore(eval *structs.Evaluation) error { if err := r.txn.Insert("evals", eval); err != nil { return fmt.Errorf("eval insert failed: %v", err) } return nil }
go
func (r *StateRestore) EvalRestore(eval *structs.Evaluation) error { if err := r.txn.Insert("evals", eval); err != nil { return fmt.Errorf("eval insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "EvalRestore", "(", "eval", "*", "structs", ".", "Evaluation", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "eval", ")", ";", "err", "!=", "nil", "{", "ret...
// EvalRestore is used to restore an evaluation
[ "EvalRestore", "is", "used", "to", "restore", "an", "evaluation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4229-L4234
133,063
hashicorp/nomad
nomad/state/state_store.go
AllocRestore
func (r *StateRestore) AllocRestore(alloc *structs.Allocation) error { if err := r.txn.Insert("allocs", alloc); err != nil { return fmt.Errorf("alloc insert failed: %v", err) } return nil }
go
func (r *StateRestore) AllocRestore(alloc *structs.Allocation) error { if err := r.txn.Insert("allocs", alloc); err != nil { return fmt.Errorf("alloc insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "AllocRestore", "(", "alloc", "*", "structs", ".", "Allocation", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "alloc", ")", ";", "err", "!=", "nil", "{", "...
// AllocRestore is used to restore an allocation
[ "AllocRestore", "is", "used", "to", "restore", "an", "allocation" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4237-L4242
133,064
hashicorp/nomad
nomad/state/state_store.go
PeriodicLaunchRestore
func (r *StateRestore) PeriodicLaunchRestore(launch *structs.PeriodicLaunch) error { if err := r.txn.Insert("periodic_launch", launch); err != nil { return fmt.Errorf("periodic launch insert failed: %v", err) } return nil }
go
func (r *StateRestore) PeriodicLaunchRestore(launch *structs.PeriodicLaunch) error { if err := r.txn.Insert("periodic_launch", launch); err != nil { return fmt.Errorf("periodic launch insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "PeriodicLaunchRestore", "(", "launch", "*", "structs", ".", "PeriodicLaunch", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "launch", ")", ";", "err", "!=", "n...
// PeriodicLaunchRestore is used to restore a periodic launch.
[ "PeriodicLaunchRestore", "is", "used", "to", "restore", "a", "periodic", "launch", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4253-L4258
133,065
hashicorp/nomad
nomad/state/state_store.go
JobSummaryRestore
func (r *StateRestore) JobSummaryRestore(jobSummary *structs.JobSummary) error { if err := r.txn.Insert("job_summary", jobSummary); err != nil { return fmt.Errorf("job summary insert failed: %v", err) } return nil }
go
func (r *StateRestore) JobSummaryRestore(jobSummary *structs.JobSummary) error { if err := r.txn.Insert("job_summary", jobSummary); err != nil { return fmt.Errorf("job summary insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "JobSummaryRestore", "(", "jobSummary", "*", "structs", ".", "JobSummary", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "jobSummary", ")", ";", "err", "!=", "n...
// JobSummaryRestore is used to restore a job summary
[ "JobSummaryRestore", "is", "used", "to", "restore", "a", "job", "summary" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4261-L4266
133,066
hashicorp/nomad
nomad/state/state_store.go
JobVersionRestore
func (r *StateRestore) JobVersionRestore(version *structs.Job) error { if err := r.txn.Insert("job_version", version); err != nil { return fmt.Errorf("job version insert failed: %v", err) } return nil }
go
func (r *StateRestore) JobVersionRestore(version *structs.Job) error { if err := r.txn.Insert("job_version", version); err != nil { return fmt.Errorf("job version insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "JobVersionRestore", "(", "version", "*", "structs", ".", "Job", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "version", ")", ";", "err", "!=", "nil", "{", ...
// JobVersionRestore is used to restore a job version
[ "JobVersionRestore", "is", "used", "to", "restore", "a", "job", "version" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4269-L4274
133,067
hashicorp/nomad
nomad/state/state_store.go
DeploymentRestore
func (r *StateRestore) DeploymentRestore(deployment *structs.Deployment) error { if err := r.txn.Insert("deployment", deployment); err != nil { return fmt.Errorf("deployment insert failed: %v", err) } return nil }
go
func (r *StateRestore) DeploymentRestore(deployment *structs.Deployment) error { if err := r.txn.Insert("deployment", deployment); err != nil { return fmt.Errorf("deployment insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "DeploymentRestore", "(", "deployment", "*", "structs", ".", "Deployment", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "deployment", ")", ";", "err", "!=", "n...
// DeploymentRestore is used to restore a deployment
[ "DeploymentRestore", "is", "used", "to", "restore", "a", "deployment" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4277-L4282
133,068
hashicorp/nomad
nomad/state/state_store.go
VaultAccessorRestore
func (r *StateRestore) VaultAccessorRestore(accessor *structs.VaultAccessor) error { if err := r.txn.Insert("vault_accessors", accessor); err != nil { return fmt.Errorf("vault accessor insert failed: %v", err) } return nil }
go
func (r *StateRestore) VaultAccessorRestore(accessor *structs.VaultAccessor) error { if err := r.txn.Insert("vault_accessors", accessor); err != nil { return fmt.Errorf("vault accessor insert failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "VaultAccessorRestore", "(", "accessor", "*", "structs", ".", "VaultAccessor", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "accessor", ")", ";", "err", "!=", ...
// VaultAccessorRestore is used to restore a vault accessor
[ "VaultAccessorRestore", "is", "used", "to", "restore", "a", "vault", "accessor" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4285-L4290
133,069
hashicorp/nomad
nomad/state/state_store.go
ACLPolicyRestore
func (r *StateRestore) ACLPolicyRestore(policy *structs.ACLPolicy) error { if err := r.txn.Insert("acl_policy", policy); err != nil { return fmt.Errorf("inserting acl policy failed: %v", err) } return nil }
go
func (r *StateRestore) ACLPolicyRestore(policy *structs.ACLPolicy) error { if err := r.txn.Insert("acl_policy", policy); err != nil { return fmt.Errorf("inserting acl policy failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "ACLPolicyRestore", "(", "policy", "*", "structs", ".", "ACLPolicy", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "policy", ")", ";", "err", "!=", "nil", "{"...
// ACLPolicyRestore is used to restore an ACL policy
[ "ACLPolicyRestore", "is", "used", "to", "restore", "an", "ACL", "policy" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4293-L4298
133,070
hashicorp/nomad
nomad/state/state_store.go
ACLTokenRestore
func (r *StateRestore) ACLTokenRestore(token *structs.ACLToken) error { if err := r.txn.Insert("acl_token", token); err != nil { return fmt.Errorf("inserting acl token failed: %v", err) } return nil }
go
func (r *StateRestore) ACLTokenRestore(token *structs.ACLToken) error { if err := r.txn.Insert("acl_token", token); err != nil { return fmt.Errorf("inserting acl token failed: %v", err) } return nil }
[ "func", "(", "r", "*", "StateRestore", ")", "ACLTokenRestore", "(", "token", "*", "structs", ".", "ACLToken", ")", "error", "{", "if", "err", ":=", "r", ".", "txn", ".", "Insert", "(", "\"", "\"", ",", "token", ")", ";", "err", "!=", "nil", "{", ...
// ACLTokenRestore is used to restore an ACL token
[ "ACLTokenRestore", "is", "used", "to", "restore", "an", "ACL", "token" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/state/state_store.go#L4301-L4306
133,071
hashicorp/nomad
client/allochealth/tracker.go
NewTracker
func NewTracker(parentCtx context.Context, logger hclog.Logger, alloc *structs.Allocation, allocUpdates *cstructs.AllocListener, consulClient cconsul.ConsulServiceAPI, minHealthyTime time.Duration, useChecks bool) *Tracker { // Do not create a named sub-logger as the hook controlling // this struct should pass in ...
go
func NewTracker(parentCtx context.Context, logger hclog.Logger, alloc *structs.Allocation, allocUpdates *cstructs.AllocListener, consulClient cconsul.ConsulServiceAPI, minHealthyTime time.Duration, useChecks bool) *Tracker { // Do not create a named sub-logger as the hook controlling // this struct should pass in ...
[ "func", "NewTracker", "(", "parentCtx", "context", ".", "Context", ",", "logger", "hclog", ".", "Logger", ",", "alloc", "*", "structs", ".", "Allocation", ",", "allocUpdates", "*", "cstructs", ".", "AllocListener", ",", "consulClient", "cconsul", ".", "ConsulS...
// NewTracker returns a health tracker for the given allocation. An alloc // listener and consul API object are given so that the watcher can detect // health changes.
[ "NewTracker", "returns", "a", "health", "tracker", "for", "the", "given", "allocation", ".", "An", "alloc", "listener", "and", "consul", "API", "object", "are", "given", "so", "that", "the", "watcher", "can", "detect", "health", "changes", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L87-L119
133,072
hashicorp/nomad
client/allochealth/tracker.go
TaskEvents
func (t *Tracker) TaskEvents() map[string]*structs.TaskEvent { t.l.Lock() defer t.l.Unlock() // Nothing to do since the failure wasn't task related if t.allocFailed { return nil } deadline, _ := t.ctx.Deadline() events := make(map[string]*structs.TaskEvent, len(t.tg.Tasks)) // Go through are task informati...
go
func (t *Tracker) TaskEvents() map[string]*structs.TaskEvent { t.l.Lock() defer t.l.Unlock() // Nothing to do since the failure wasn't task related if t.allocFailed { return nil } deadline, _ := t.ctx.Deadline() events := make(map[string]*structs.TaskEvent, len(t.tg.Tasks)) // Go through are task informati...
[ "func", "(", "t", "*", "Tracker", ")", "TaskEvents", "(", ")", "map", "[", "string", "]", "*", "structs", ".", "TaskEvent", "{", "t", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "l", ".", "Unlock", "(", ")", "\n\n", "// Nothing to d...
// TaskEvents returns a map of events by task. This should only be called after // health has been determined. Only tasks that have contributed to the // allocation being unhealthy will have an event.
[ "TaskEvents", "returns", "a", "map", "of", "events", "by", "task", ".", "This", "should", "only", "be", "called", "after", "health", "has", "been", "determined", ".", "Only", "tasks", "that", "have", "contributed", "to", "the", "allocation", "being", "unheal...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L144-L165
133,073
hashicorp/nomad
client/allochealth/tracker.go
setTaskHealth
func (t *Tracker) setTaskHealth(healthy, terminal bool) { t.l.Lock() defer t.l.Unlock() t.tasksHealthy = healthy // If we are marked healthy but we also require Consul to be healthy and it // isn't yet, return, unless the task is terminal requireConsul := t.useChecks && t.consulCheckCount > 0 if !terminal && he...
go
func (t *Tracker) setTaskHealth(healthy, terminal bool) { t.l.Lock() defer t.l.Unlock() t.tasksHealthy = healthy // If we are marked healthy but we also require Consul to be healthy and it // isn't yet, return, unless the task is terminal requireConsul := t.useChecks && t.consulCheckCount > 0 if !terminal && he...
[ "func", "(", "t", "*", "Tracker", ")", "setTaskHealth", "(", "healthy", ",", "terminal", "bool", ")", "{", "t", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "l", ".", "Unlock", "(", ")", "\n", "t", ".", "tasksHealthy", "=", "healthy"...
// setTaskHealth is used to set the tasks health as healthy or unhealthy. If the // allocation is terminal, health is immediately broadcasted.
[ "setTaskHealth", "is", "used", "to", "set", "the", "tasks", "health", "as", "healthy", "or", "unhealthy", ".", "If", "the", "allocation", "is", "terminal", "health", "is", "immediately", "broadcasted", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L169-L188
133,074
hashicorp/nomad
client/allochealth/tracker.go
setCheckHealth
func (t *Tracker) setCheckHealth(healthy bool) { t.l.Lock() defer t.l.Unlock() t.checksHealthy = healthy // Only signal if we are healthy and so is the tasks if !healthy || !t.tasksHealthy { return } select { case t.healthy <- healthy: default: } // Shutdown the tracker t.cancelFn() }
go
func (t *Tracker) setCheckHealth(healthy bool) { t.l.Lock() defer t.l.Unlock() t.checksHealthy = healthy // Only signal if we are healthy and so is the tasks if !healthy || !t.tasksHealthy { return } select { case t.healthy <- healthy: default: } // Shutdown the tracker t.cancelFn() }
[ "func", "(", "t", "*", "Tracker", ")", "setCheckHealth", "(", "healthy", "bool", ")", "{", "t", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "l", ".", "Unlock", "(", ")", "\n", "t", ".", "checksHealthy", "=", "healthy", "\n\n", "// O...
// setCheckHealth is used to mark the checks as either healthy or unhealthy.
[ "setCheckHealth", "is", "used", "to", "mark", "the", "checks", "as", "either", "healthy", "or", "unhealthy", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L191-L208
133,075
hashicorp/nomad
client/allochealth/tracker.go
watchTaskEvents
func (t *Tracker) watchTaskEvents() { alloc := t.alloc allStartedTime := time.Time{} healthyTimer := time.NewTimer(0) if !healthyTimer.Stop() { select { case <-healthyTimer.C: default: } } for { // If the alloc is being stopped by the server just exit switch alloc.DesiredStatus { case structs.Alloc...
go
func (t *Tracker) watchTaskEvents() { alloc := t.alloc allStartedTime := time.Time{} healthyTimer := time.NewTimer(0) if !healthyTimer.Stop() { select { case <-healthyTimer.C: default: } } for { // If the alloc is being stopped by the server just exit switch alloc.DesiredStatus { case structs.Alloc...
[ "func", "(", "t", "*", "Tracker", ")", "watchTaskEvents", "(", ")", "{", "alloc", ":=", "t", ".", "alloc", "\n", "allStartedTime", ":=", "time", ".", "Time", "{", "}", "\n", "healthyTimer", ":=", "time", ".", "NewTimer", "(", "0", ")", "\n", "if", ...
// watchTaskEvents is a long lived watcher that watches for the health of the // allocation's tasks.
[ "watchTaskEvents", "is", "a", "long", "lived", "watcher", "that", "watches", "for", "the", "health", "of", "the", "allocation", "s", "tasks", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L218-L301
133,076
hashicorp/nomad
client/allochealth/tracker.go
watchConsulEvents
func (t *Tracker) watchConsulEvents() { // checkTicker is the ticker that triggers us to look at the checks in // Consul checkTicker := time.NewTicker(consulCheckLookupInterval) defer checkTicker.Stop() // healthyTimer fires when the checks have been healthy for the // MinHealthyTime healthyTimer := time.NewTim...
go
func (t *Tracker) watchConsulEvents() { // checkTicker is the ticker that triggers us to look at the checks in // Consul checkTicker := time.NewTicker(consulCheckLookupInterval) defer checkTicker.Stop() // healthyTimer fires when the checks have been healthy for the // MinHealthyTime healthyTimer := time.NewTim...
[ "func", "(", "t", "*", "Tracker", ")", "watchConsulEvents", "(", ")", "{", "// checkTicker is the ticker that triggers us to look at the checks in", "// Consul", "checkTicker", ":=", "time", ".", "NewTicker", "(", "consulCheckLookupInterval", ")", "\n", "defer", "checkTic...
// watchConsulEvents is a long lived watcher for the health of the allocation's // Consul checks.
[ "watchConsulEvents", "is", "a", "long", "lived", "watcher", "for", "the", "health", "of", "the", "allocation", "s", "Consul", "checks", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L305-L404
133,077
hashicorp/nomad
client/allochealth/tracker.go
event
func (t *taskHealthState) event(deadline time.Time, minHealthyTime time.Duration, useChecks bool) (string, bool) { requireChecks := false desiredChecks := 0 for _, s := range t.task.Services { if nc := len(s.Checks); nc > 0 { requireChecks = true desiredChecks += nc } } requireChecks = requireChecks && u...
go
func (t *taskHealthState) event(deadline time.Time, minHealthyTime time.Duration, useChecks bool) (string, bool) { requireChecks := false desiredChecks := 0 for _, s := range t.task.Services { if nc := len(s.Checks); nc > 0 { requireChecks = true desiredChecks += nc } } requireChecks = requireChecks && u...
[ "func", "(", "t", "*", "taskHealthState", ")", "event", "(", "deadline", "time", ".", "Time", ",", "minHealthyTime", "time", ".", "Duration", ",", "useChecks", "bool", ")", "(", "string", ",", "bool", ")", "{", "requireChecks", ":=", "false", "\n", "desi...
// event takes the deadline time for the allocation to be healthy and the update // strategy of the group. It returns true if the task has contributed to the // allocation being unhealthy and if so, an event description of why.
[ "event", "takes", "the", "deadline", "time", "for", "the", "allocation", "to", "be", "healthy", "and", "the", "update", "strategy", "of", "the", "group", ".", "It", "returns", "true", "if", "the", "task", "has", "contributed", "to", "the", "allocation", "b...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allochealth/tracker.go#L418-L472
133,078
hashicorp/nomad
client/state/upgrade.go
NeedsUpgrade
func NeedsUpgrade(bdb *bolt.DB) (bool, error) { needsUpgrade := true err := bdb.View(func(tx *bolt.Tx) error { b := tx.Bucket(metaBucketName) if b == nil { // No meta bucket; upgrade return nil } v := b.Get(metaVersionKey) if len(v) == 0 { // No version; upgrade return nil } if !bytes.Equa...
go
func NeedsUpgrade(bdb *bolt.DB) (bool, error) { needsUpgrade := true err := bdb.View(func(tx *bolt.Tx) error { b := tx.Bucket(metaBucketName) if b == nil { // No meta bucket; upgrade return nil } v := b.Get(metaVersionKey) if len(v) == 0 { // No version; upgrade return nil } if !bytes.Equa...
[ "func", "NeedsUpgrade", "(", "bdb", "*", "bolt", ".", "DB", ")", "(", "bool", ",", "error", ")", "{", "needsUpgrade", ":=", "true", "\n", "err", ":=", "bdb", ".", "View", "(", "func", "(", "tx", "*", "bolt", ".", "Tx", ")", "error", "{", "b", "...
// NeedsUpgrade returns true if the BoltDB needs upgrading or false if it is // already up to date.
[ "NeedsUpgrade", "returns", "true", "if", "the", "BoltDB", "needs", "upgrading", "or", "false", "if", "it", "is", "already", "up", "to", "date", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/upgrade.go#L17-L44
133,079
hashicorp/nomad
client/state/upgrade.go
addMeta
func addMeta(tx *bolt.Tx) error { // Create the meta bucket if it doesn't exist bkt, err := tx.CreateBucketIfNotExists(metaBucketName) if err != nil { return err } return bkt.Put(metaVersionKey, metaVersion) }
go
func addMeta(tx *bolt.Tx) error { // Create the meta bucket if it doesn't exist bkt, err := tx.CreateBucketIfNotExists(metaBucketName) if err != nil { return err } return bkt.Put(metaVersionKey, metaVersion) }
[ "func", "addMeta", "(", "tx", "*", "bolt", ".", "Tx", ")", "error", "{", "// Create the meta bucket if it doesn't exist", "bkt", ",", "err", ":=", "tx", ".", "CreateBucketIfNotExists", "(", "metaBucketName", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// addMeta adds version metadata to BoltDB to mark it as upgraded and // should be run at the end of the upgrade transaction.
[ "addMeta", "adds", "version", "metadata", "to", "BoltDB", "to", "mark", "it", "as", "upgraded", "and", "should", "be", "run", "at", "the", "end", "of", "the", "upgrade", "transaction", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/upgrade.go#L48-L56
133,080
hashicorp/nomad
client/state/upgrade.go
backupDB
func backupDB(bdb *bolt.DB, dst string) error { fd, err := os.Create(dst) if err != nil { return err } return bdb.View(func(tx *bolt.Tx) error { if _, err := tx.WriteTo(fd); err != nil { fd.Close() return err } return fd.Close() }) }
go
func backupDB(bdb *bolt.DB, dst string) error { fd, err := os.Create(dst) if err != nil { return err } return bdb.View(func(tx *bolt.Tx) error { if _, err := tx.WriteTo(fd); err != nil { fd.Close() return err } return fd.Close() }) }
[ "func", "backupDB", "(", "bdb", "*", "bolt", ".", "DB", ",", "dst", "string", ")", "error", "{", "fd", ",", "err", ":=", "os", ".", "Create", "(", "dst", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "b...
// backupDB backs up the existing state database prior to upgrade overwriting // previous backups.
[ "backupDB", "backs", "up", "the", "existing", "state", "database", "prior", "to", "upgrade", "overwriting", "previous", "backups", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/upgrade.go#L60-L74
133,081
hashicorp/nomad
client/state/upgrade.go
upgradeAllocBucket
func upgradeAllocBucket(logger hclog.Logger, tx *boltdd.Tx, bkt *bolt.Bucket, allocID string) error { allocFound := false taskBuckets := [][]byte{} cur := bkt.Cursor() for k, v := cur.First(); k != nil; k, v = cur.Next() { switch string(k) { case "alloc": // Alloc has not changed; leave it be allocFound =...
go
func upgradeAllocBucket(logger hclog.Logger, tx *boltdd.Tx, bkt *bolt.Bucket, allocID string) error { allocFound := false taskBuckets := [][]byte{} cur := bkt.Cursor() for k, v := cur.First(); k != nil; k, v = cur.Next() { switch string(k) { case "alloc": // Alloc has not changed; leave it be allocFound =...
[ "func", "upgradeAllocBucket", "(", "logger", "hclog", ".", "Logger", ",", "tx", "*", "boltdd", ".", "Tx", ",", "bkt", "*", "bolt", ".", "Bucket", ",", "allocID", "string", ")", "error", "{", "allocFound", ":=", "false", "\n", "taskBuckets", ":=", "[", ...
// upgradeAllocBucket upgrades an alloc bucket.
[ "upgradeAllocBucket", "upgrades", "an", "alloc", "bucket", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/upgrade.go#L141-L245
133,082
hashicorp/nomad
client/state/upgrade.go
upgradeTaskBucket
func upgradeTaskBucket(logger hclog.Logger, bkt *bolt.Bucket) (*taskRunnerState08, error) { simpleFound := false var trState taskRunnerState08 cur := bkt.Cursor() for k, v := cur.First(); k != nil; k, v = cur.Next() { if v == nil { // value is nil: delete unexpected bucket logger.Warn("deleting unexpected ...
go
func upgradeTaskBucket(logger hclog.Logger, bkt *bolt.Bucket) (*taskRunnerState08, error) { simpleFound := false var trState taskRunnerState08 cur := bkt.Cursor() for k, v := cur.First(); k != nil; k, v = cur.Next() { if v == nil { // value is nil: delete unexpected bucket logger.Warn("deleting unexpected ...
[ "func", "upgradeTaskBucket", "(", "logger", "hclog", ".", "Logger", ",", "bkt", "*", "bolt", ".", "Bucket", ")", "(", "*", "taskRunnerState08", ",", "error", ")", "{", "simpleFound", ":=", "false", "\n", "var", "trState", "taskRunnerState08", "\n\n", "cur", ...
// upgradeTaskBucket iterates over keys in a task bucket, deleting invalid keys // and returning the 0.8 version of the state.
[ "upgradeTaskBucket", "iterates", "over", "keys", "in", "a", "task", "bucket", "deleting", "invalid", "keys", "and", "returning", "the", "0", ".", "8", "version", "of", "the", "state", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/upgrade.go#L249-L291
133,083
hashicorp/nomad
client/state/upgrade.go
upgradeOldAllocMutable
func upgradeOldAllocMutable(tx *boltdd.Tx, allocID string, oldBytes []byte) error { var oldMutable allocRunnerMutableState08 err := codec.NewDecoderBytes(oldBytes, structs.MsgpackHandle).Decode(&oldMutable) if err != nil { return err } // Upgrade Deployment Status if err := putDeploymentStatusImpl(tx, allocID,...
go
func upgradeOldAllocMutable(tx *boltdd.Tx, allocID string, oldBytes []byte) error { var oldMutable allocRunnerMutableState08 err := codec.NewDecoderBytes(oldBytes, structs.MsgpackHandle).Decode(&oldMutable) if err != nil { return err } // Upgrade Deployment Status if err := putDeploymentStatusImpl(tx, allocID,...
[ "func", "upgradeOldAllocMutable", "(", "tx", "*", "boltdd", ".", "Tx", ",", "allocID", "string", ",", "oldBytes", "[", "]", "byte", ")", "error", "{", "var", "oldMutable", "allocRunnerMutableState08", "\n", "err", ":=", "codec", ".", "NewDecoderBytes", "(", ...
// upgradeOldAllocMutable upgrades Nomad 0.8 alloc runner state.
[ "upgradeOldAllocMutable", "upgrades", "Nomad", "0", ".", "8", "alloc", "runner", "state", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/state/upgrade.go#L294-L314
133,084
hashicorp/nomad
nomad/structs/devices.go
NewDeviceAccounter
func NewDeviceAccounter(n *Node) *DeviceAccounter { numDevices := 0 var devices []*NodeDeviceResource // COMPAT(0.11): Remove in 0.11 if n.NodeResources != nil { numDevices = len(n.NodeResources.Devices) devices = n.NodeResources.Devices } d := &DeviceAccounter{ Devices: make(map[DeviceIdTuple]*DeviceAcco...
go
func NewDeviceAccounter(n *Node) *DeviceAccounter { numDevices := 0 var devices []*NodeDeviceResource // COMPAT(0.11): Remove in 0.11 if n.NodeResources != nil { numDevices = len(n.NodeResources.Devices) devices = n.NodeResources.Devices } d := &DeviceAccounter{ Devices: make(map[DeviceIdTuple]*DeviceAcco...
[ "func", "NewDeviceAccounter", "(", "n", "*", "Node", ")", "*", "DeviceAccounter", "{", "numDevices", ":=", "0", "\n", "var", "devices", "[", "]", "*", "NodeDeviceResource", "\n\n", "// COMPAT(0.11): Remove in 0.11", "if", "n", ".", "NodeResources", "!=", "nil", ...
// NewDeviceAccounter returns a new device accounter. The node is used to // populate the set of available devices based on what healthy device instances // exist on the node.
[ "NewDeviceAccounter", "returns", "a", "new", "device", "accounter", ".", "The", "node", "is", "used", "to", "populate", "the", "set", "of", "available", "devices", "based", "on", "what", "healthy", "device", "instances", "exist", "on", "the", "node", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/devices.go#L25-L56
133,085
hashicorp/nomad
nomad/structs/devices.go
AddAllocs
func (d *DeviceAccounter) AddAllocs(allocs []*Allocation) (collision bool) { for _, a := range allocs { // Filter any terminal allocation if a.TerminalStatus() { continue } // COMPAT(0.11): Remove in 0.11 // If the alloc doesn't have the new style resources, it can't have // devices if a.AllocatedRes...
go
func (d *DeviceAccounter) AddAllocs(allocs []*Allocation) (collision bool) { for _, a := range allocs { // Filter any terminal allocation if a.TerminalStatus() { continue } // COMPAT(0.11): Remove in 0.11 // If the alloc doesn't have the new style resources, it can't have // devices if a.AllocatedRes...
[ "func", "(", "d", "*", "DeviceAccounter", ")", "AddAllocs", "(", "allocs", "[", "]", "*", "Allocation", ")", "(", "collision", "bool", ")", "{", "for", "_", ",", "a", ":=", "range", "allocs", "{", "// Filter any terminal allocation", "if", "a", ".", "Ter...
// AddAllocs takes a set of allocations and internally marks which devices are // used. If a device is used more than once by the set of passed allocations, // the collision will be returned as true.
[ "AddAllocs", "takes", "a", "set", "of", "allocations", "and", "internally", "marks", "which", "devices", "are", "used", ".", "If", "a", "device", "is", "used", "more", "than", "once", "by", "the", "set", "of", "passed", "allocations", "the", "collision", "...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/devices.go#L61-L104
133,086
hashicorp/nomad
nomad/structs/devices.go
AddReserved
func (d *DeviceAccounter) AddReserved(res *AllocatedDeviceResource) (collision bool) { // Lookup the device. devInst, ok := d.Devices[*res.ID()] if !ok { return false } // For each reserved instance, mark it as used for _, id := range res.DeviceIDs { cur, ok := devInst.Instances[id] if !ok { continue ...
go
func (d *DeviceAccounter) AddReserved(res *AllocatedDeviceResource) (collision bool) { // Lookup the device. devInst, ok := d.Devices[*res.ID()] if !ok { return false } // For each reserved instance, mark it as used for _, id := range res.DeviceIDs { cur, ok := devInst.Instances[id] if !ok { continue ...
[ "func", "(", "d", "*", "DeviceAccounter", ")", "AddReserved", "(", "res", "*", "AllocatedDeviceResource", ")", "(", "collision", "bool", ")", "{", "// Lookup the device.", "devInst", ",", "ok", ":=", "d", ".", "Devices", "[", "*", "res", ".", "ID", "(", ...
// AddReserved marks the device instances in the passed device reservation as // used and returns if there is a collision.
[ "AddReserved", "marks", "the", "device", "instances", "in", "the", "passed", "device", "reservation", "as", "used", "and", "returns", "if", "there", "is", "a", "collision", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/devices.go#L108-L131
133,087
hashicorp/nomad
nomad/structs/devices.go
FreeCount
func (i *DeviceAccounterInstance) FreeCount() int { count := 0 for _, c := range i.Instances { if c == 0 { count++ } } return count }
go
func (i *DeviceAccounterInstance) FreeCount() int { count := 0 for _, c := range i.Instances { if c == 0 { count++ } } return count }
[ "func", "(", "i", "*", "DeviceAccounterInstance", ")", "FreeCount", "(", ")", "int", "{", "count", ":=", "0", "\n", "for", "_", ",", "c", ":=", "range", "i", ".", "Instances", "{", "if", "c", "==", "0", "{", "count", "++", "\n", "}", "\n", "}", ...
// FreeCount returns the number of free device instances
[ "FreeCount", "returns", "the", "number", "of", "free", "device", "instances" ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/devices.go#L134-L142
133,088
hashicorp/nomad
client/taskenv/env.go
NewTaskEnv
func NewTaskEnv(env, deviceEnv, node map[string]string) *TaskEnv { return &TaskEnv{ NodeAttrs: node, deviceEnv: deviceEnv, EnvMap: env, } }
go
func NewTaskEnv(env, deviceEnv, node map[string]string) *TaskEnv { return &TaskEnv{ NodeAttrs: node, deviceEnv: deviceEnv, EnvMap: env, } }
[ "func", "NewTaskEnv", "(", "env", ",", "deviceEnv", ",", "node", "map", "[", "string", "]", "string", ")", "*", "TaskEnv", "{", "return", "&", "TaskEnv", "{", "NodeAttrs", ":", "node", ",", "deviceEnv", ":", "deviceEnv", ",", "EnvMap", ":", "env", ",",...
// NewTaskEnv creates a new task environment with the given environment, device // environment and node attribute maps.
[ "NewTaskEnv", "creates", "a", "new", "task", "environment", "with", "the", "given", "environment", "device", "environment", "and", "node", "attribute", "maps", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L124-L130
133,089
hashicorp/nomad
client/taskenv/env.go
NewEmptyTaskEnv
func NewEmptyTaskEnv() *TaskEnv { return &TaskEnv{ NodeAttrs: make(map[string]string), deviceEnv: make(map[string]string), EnvMap: make(map[string]string), } }
go
func NewEmptyTaskEnv() *TaskEnv { return &TaskEnv{ NodeAttrs: make(map[string]string), deviceEnv: make(map[string]string), EnvMap: make(map[string]string), } }
[ "func", "NewEmptyTaskEnv", "(", ")", "*", "TaskEnv", "{", "return", "&", "TaskEnv", "{", "NodeAttrs", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "deviceEnv", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "EnvM...
// NewEmptyTaskEnv creates a new empty task environment.
[ "NewEmptyTaskEnv", "creates", "a", "new", "empty", "task", "environment", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L133-L139
133,090
hashicorp/nomad
client/taskenv/env.go
List
func (t *TaskEnv) List() []string { if t.envList != nil { return t.envList } env := []string{} for k, v := range t.EnvMap { env = append(env, fmt.Sprintf("%s=%s", k, v)) } return env }
go
func (t *TaskEnv) List() []string { if t.envList != nil { return t.envList } env := []string{} for k, v := range t.EnvMap { env = append(env, fmt.Sprintf("%s=%s", k, v)) } return env }
[ "func", "(", "t", "*", "TaskEnv", ")", "List", "(", ")", "[", "]", "string", "{", "if", "t", ".", "envList", "!=", "nil", "{", "return", "t", ".", "envList", "\n", "}", "\n\n", "env", ":=", "[", "]", "string", "{", "}", "\n", "for", "k", ",",...
// List returns the task's environment as a slice of NAME=value pair strings.
[ "List", "returns", "the", "task", "s", "environment", "as", "a", "slice", "of", "NAME", "=", "value", "pair", "strings", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L142-L153
133,091
hashicorp/nomad
client/taskenv/env.go
DeviceEnv
func (t *TaskEnv) DeviceEnv() map[string]string { m := make(map[string]string, len(t.deviceEnv)) for k, v := range t.deviceEnv { m[k] = v } return m }
go
func (t *TaskEnv) DeviceEnv() map[string]string { m := make(map[string]string, len(t.deviceEnv)) for k, v := range t.deviceEnv { m[k] = v } return m }
[ "func", "(", "t", "*", "TaskEnv", ")", "DeviceEnv", "(", ")", "map", "[", "string", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "t", ".", "deviceEnv", ")", ")", "\n", "for", "k", ",", "v", ...
// DeviceEnv returns the task's environment variables set by device hooks.
[ "DeviceEnv", "returns", "the", "task", "s", "environment", "variables", "set", "by", "device", "hooks", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L156-L163
133,092
hashicorp/nomad
client/taskenv/env.go
Map
func (t *TaskEnv) Map() map[string]string { m := make(map[string]string, len(t.EnvMap)) for k, v := range t.EnvMap { m[k] = v } return m }
go
func (t *TaskEnv) Map() map[string]string { m := make(map[string]string, len(t.EnvMap)) for k, v := range t.EnvMap { m[k] = v } return m }
[ "func", "(", "t", "*", "TaskEnv", ")", "Map", "(", ")", "map", "[", "string", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "t", ".", "EnvMap", ")", ")", "\n", "for", "k", ",", "v", ":=", ...
// Map of the task's environment variables.
[ "Map", "of", "the", "task", "s", "environment", "variables", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L166-L173
133,093
hashicorp/nomad
client/taskenv/env.go
All
func (t *TaskEnv) All() map[string]string { m := make(map[string]string, len(t.EnvMap)+len(t.NodeAttrs)) for k, v := range t.EnvMap { m[k] = v } for k, v := range t.NodeAttrs { m[k] = v } return m }
go
func (t *TaskEnv) All() map[string]string { m := make(map[string]string, len(t.EnvMap)+len(t.NodeAttrs)) for k, v := range t.EnvMap { m[k] = v } for k, v := range t.NodeAttrs { m[k] = v } return m }
[ "func", "(", "t", "*", "TaskEnv", ")", "All", "(", ")", "map", "[", "string", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "t", ".", "EnvMap", ")", "+", "len", "(", "t", ".", "NodeAttrs", "...
// All of the task's environment variables and the node's attributes in a // single map.
[ "All", "of", "the", "task", "s", "environment", "variables", "and", "the", "node", "s", "attributes", "in", "a", "single", "map", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L177-L187
133,094
hashicorp/nomad
client/taskenv/env.go
ParseAndReplace
func (t *TaskEnv) ParseAndReplace(args []string) []string { if args == nil { return nil } replaced := make([]string, len(args)) for i, arg := range args { replaced[i] = hargs.ReplaceEnv(arg, t.EnvMap, t.NodeAttrs) } return replaced }
go
func (t *TaskEnv) ParseAndReplace(args []string) []string { if args == nil { return nil } replaced := make([]string, len(args)) for i, arg := range args { replaced[i] = hargs.ReplaceEnv(arg, t.EnvMap, t.NodeAttrs) } return replaced }
[ "func", "(", "t", "*", "TaskEnv", ")", "ParseAndReplace", "(", "args", "[", "]", "string", ")", "[", "]", "string", "{", "if", "args", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "replaced", ":=", "make", "(", "[", "]", "string", ",", "...
// ParseAndReplace takes the user supplied args replaces any instance of an // environment variable or Nomad variable in the args with the actual value.
[ "ParseAndReplace", "takes", "the", "user", "supplied", "args", "replaces", "any", "instance", "of", "an", "environment", "variable", "or", "Nomad", "variable", "in", "the", "args", "with", "the", "actual", "value", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L255-L266
133,095
hashicorp/nomad
client/taskenv/env.go
ReplaceEnv
func (t *TaskEnv) ReplaceEnv(arg string) string { return hargs.ReplaceEnv(arg, t.EnvMap, t.NodeAttrs) }
go
func (t *TaskEnv) ReplaceEnv(arg string) string { return hargs.ReplaceEnv(arg, t.EnvMap, t.NodeAttrs) }
[ "func", "(", "t", "*", "TaskEnv", ")", "ReplaceEnv", "(", "arg", "string", ")", "string", "{", "return", "hargs", ".", "ReplaceEnv", "(", "arg", ",", "t", ".", "EnvMap", ",", "t", ".", "NodeAttrs", ")", "\n", "}" ]
// ReplaceEnv takes an arg and replaces all occurrences of environment variables // and Nomad variables. If the variable is found in the passed map it is // replaced, otherwise the original string is returned.
[ "ReplaceEnv", "takes", "an", "arg", "and", "replaces", "all", "occurrences", "of", "environment", "variables", "and", "Nomad", "variables", ".", "If", "the", "variable", "is", "found", "in", "the", "passed", "map", "it", "is", "replaced", "otherwise", "the", ...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L271-L273
133,096
hashicorp/nomad
client/taskenv/env.go
NewBuilder
func NewBuilder(node *structs.Node, alloc *structs.Allocation, task *structs.Task, region string) *Builder { b := NewEmptyBuilder() b.region = region return b.setTask(task).setAlloc(alloc).setNode(node) }
go
func NewBuilder(node *structs.Node, alloc *structs.Allocation, task *structs.Task, region string) *Builder { b := NewEmptyBuilder() b.region = region return b.setTask(task).setAlloc(alloc).setNode(node) }
[ "func", "NewBuilder", "(", "node", "*", "structs", ".", "Node", ",", "alloc", "*", "structs", ".", "Allocation", ",", "task", "*", "structs", ".", "Task", ",", "region", "string", ")", "*", "Builder", "{", "b", ":=", "NewEmptyBuilder", "(", ")", "\n", ...
// NewBuilder creates a new task environment builder.
[ "NewBuilder", "creates", "a", "new", "task", "environment", "builder", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L345-L349
133,097
hashicorp/nomad
client/taskenv/env.go
NewEmptyBuilder
func NewEmptyBuilder() *Builder { return &Builder{ mu: &sync.RWMutex{}, hookEnvs: map[string]map[string]string{}, envvars: make(map[string]string), } }
go
func NewEmptyBuilder() *Builder { return &Builder{ mu: &sync.RWMutex{}, hookEnvs: map[string]map[string]string{}, envvars: make(map[string]string), } }
[ "func", "NewEmptyBuilder", "(", ")", "*", "Builder", "{", "return", "&", "Builder", "{", "mu", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "hookEnvs", ":", "map", "[", "string", "]", "map", "[", "string", "]", "string", "{", "}", ",", "envvars...
// NewEmptyBuilder creates a new environment builder.
[ "NewEmptyBuilder", "creates", "a", "new", "environment", "builder", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L352-L358
133,098
hashicorp/nomad
client/taskenv/env.go
UpdateTask
func (b *Builder) UpdateTask(alloc *structs.Allocation, task *structs.Task) *Builder { b.mu.Lock() defer b.mu.Unlock() return b.setTask(task).setAlloc(alloc) }
go
func (b *Builder) UpdateTask(alloc *structs.Allocation, task *structs.Task) *Builder { b.mu.Lock() defer b.mu.Unlock() return b.setTask(task).setAlloc(alloc) }
[ "func", "(", "b", "*", "Builder", ")", "UpdateTask", "(", "alloc", "*", "structs", ".", "Allocation", ",", "task", "*", "structs", ".", "Task", ")", "*", "Builder", "{", "b", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mu", ".", ...
// Update task updates the environment based on a new alloc and task.
[ "Update", "task", "updates", "the", "environment", "based", "on", "a", "new", "alloc", "and", "task", "." ]
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L496-L500
133,099
hashicorp/nomad
client/taskenv/env.go
SetHookEnv
func (b *Builder) SetHookEnv(hook string, envs map[string]string) *Builder { b.mu.Lock() defer b.mu.Unlock() return b.setHookEnvLocked(hook, envs) }
go
func (b *Builder) SetHookEnv(hook string, envs map[string]string) *Builder { b.mu.Lock() defer b.mu.Unlock() return b.setHookEnvLocked(hook, envs) }
[ "func", "(", "b", "*", "Builder", ")", "SetHookEnv", "(", "hook", "string", ",", "envs", "map", "[", "string", "]", "string", ")", "*", "Builder", "{", "b", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "mu", ".", "Unlock", "(", ")...
// SetHookEnv sets environment variables from a hook. Variables are // Last-Write-Wins, so if a hook writes a variable that's also written by a // later hook, the later hooks value always gets used.
[ "SetHookEnv", "sets", "environment", "variables", "from", "a", "hook", ".", "Variables", "are", "Last", "-", "Write", "-", "Wins", "so", "if", "a", "hook", "writes", "a", "variable", "that", "s", "also", "written", "by", "a", "later", "hook", "the", "lat...
01c267b92b476a61fbdef49ba3c6b62a84509043
https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/taskenv/env.go#L505-L509