Add destroy runner route

This commit is contained in:
Jan-Eric Hellenberg
2021-05-05 09:07:23 +02:00
parent e45cd92557
commit ba51956ec3
7 changed files with 144 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ type ExecutorApi interface {
GetJobScale(jobId string) (jobScale int, err error)
SetJobScaling(jobId string, count int, reason string) (err error)
LoadRunners(jobId string) (runnerIds []string, err error)
DeleteRunner(runnerId string) (err error)
}
// ApiClient provides access to the Nomad functionality
@@ -69,3 +70,12 @@ func (apiClient *ApiClient) LoadRunners(jobId string) (runnerIds []string, err e
}
return
}
func (apiClient *ApiClient) DeleteRunner(runnerId string) (err error) {
allocation, _, err := apiClient.client.Allocations().Info(runnerId, nil)
if err != nil {
return
}
_, err = apiClient.client.Allocations().Stop(allocation, nil)
return err
}