Recover Runner Allocations on startup.
This commit is contained in:

committed by
Sebastian Serth

parent
038d71ff51
commit
8950ce29d8
@@ -39,11 +39,14 @@ type apiQuerier interface {
|
||||
stdin io.Reader, stdout, stderr io.Writer) (int, error)
|
||||
|
||||
// listJobs loads all jobs with the specified prefix.
|
||||
listJobs(prefix string) (allocationListStub []*nomadApi.JobListStub, err error)
|
||||
listJobs(prefix string) (jobListStub []*nomadApi.JobListStub, err error)
|
||||
|
||||
// job returns the job of the given jobID.
|
||||
job(jobID string) (job *nomadApi.Job, err error)
|
||||
|
||||
// listAllocations loads all allocations.
|
||||
listAllocations() (allocationListStub []*nomadApi.AllocationListStub, err error)
|
||||
|
||||
// allocation returns the first allocation of the given job.
|
||||
allocation(jobID string) (*nomadApi.Allocation, error)
|
||||
|
||||
@@ -228,6 +231,14 @@ func (nc *nomadAPIClient) job(jobID string) (job *nomadApi.Job, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (nc *nomadAPIClient) listAllocations() ([]*nomadApi.AllocationListStub, error) {
|
||||
allocationListStubs, _, err := nc.client.Allocations().List(nc.queryOptions())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing Nomad allocations: %w", err)
|
||||
}
|
||||
return allocationListStubs, nil
|
||||
}
|
||||
|
||||
func (nc *nomadAPIClient) allocation(jobID string) (alloc *nomadApi.Allocation, err error) {
|
||||
allocs, _, err := nc.client.Jobs().Allocations(jobID, false, nil)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user