mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
allocs: Add nomad alloc stop
This adds a `nomad alloc stop` command that can be used to stop and force migrate an allocation to a different node. This is built on top of the AllocUpdateDesiredTransitionRequest and explicitly limits the scope of access to that transition to expose it under the alloc-lifecycle ACL. The API returns the follow up eval that can be used as part of monitoring in the CLI or parsed and used in an external tool.
This commit is contained in:
@@ -89,6 +89,20 @@ func (a *Allocations) Restart(alloc *Allocation, taskName string, q *QueryOption
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *Allocations) Stop(alloc *Allocation, q *QueryOptions) (*AllocStopResponse, error) {
|
||||
var resp AllocStopResponse
|
||||
_, err := a.client.putQuery("/v1/allocation/"+alloc.ID+"/stop", nil, &resp, q)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// AllocStopResponse is the response to an `AllocStopRequest`
|
||||
type AllocStopResponse struct {
|
||||
// EvalID is the id of the follow up evalution for the rescheduled alloc.
|
||||
EvalID string
|
||||
|
||||
WriteMeta
|
||||
}
|
||||
|
||||
// Allocation is used for serialization of allocations.
|
||||
type Allocation struct {
|
||||
ID string
|
||||
|
||||
Reference in New Issue
Block a user