mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 03:45:41 +03:00
multiregion: deploymentwatcher hooks
This changeset establishes hooks in deploymentwatcher for multiregion deployments (for the enterprise version of Nomad).
This commit is contained in:
@@ -112,7 +112,7 @@ func (d *Deployment) Fail(args *structs.DeploymentFailRequest, reply *structs.De
|
||||
}
|
||||
|
||||
if !deploy.Active() {
|
||||
return fmt.Errorf("can't fail terminal deployment")
|
||||
return structs.ErrDeploymentTerminalNoFail
|
||||
}
|
||||
|
||||
// Call into the deployment watcher
|
||||
@@ -155,10 +155,10 @@ func (d *Deployment) Pause(args *structs.DeploymentPauseRequest, reply *structs.
|
||||
|
||||
if !deploy.Active() {
|
||||
if args.Pause {
|
||||
return fmt.Errorf("can't pause terminal deployment")
|
||||
return structs.ErrDeploymentTerminalNoPause
|
||||
}
|
||||
|
||||
return fmt.Errorf("can't resume terminal deployment")
|
||||
return structs.ErrDeploymentTerminalNoResume
|
||||
}
|
||||
|
||||
// Call into the deployment watcher
|
||||
@@ -200,7 +200,7 @@ func (d *Deployment) Promote(args *structs.DeploymentPromoteRequest, reply *stru
|
||||
}
|
||||
|
||||
if !deploy.Active() {
|
||||
return fmt.Errorf("can't promote terminal deployment")
|
||||
return structs.ErrDeploymentTerminalNoPromote
|
||||
}
|
||||
|
||||
// Call into the deployment watcher
|
||||
@@ -331,7 +331,7 @@ func (d *Deployment) SetAllocHealth(args *structs.DeploymentAllocHealthRequest,
|
||||
}
|
||||
|
||||
if !deploy.Active() {
|
||||
return fmt.Errorf("can't set health of allocations for a terminal deployment")
|
||||
return structs.ErrDeploymentTerminalNoSetHealth
|
||||
}
|
||||
|
||||
// Call into the deployment watcher
|
||||
|
||||
@@ -62,6 +62,10 @@ type deploymentWatcher struct {
|
||||
// deployment
|
||||
deploymentTriggers
|
||||
|
||||
// multiregionTriggers holds the methods required to trigger
|
||||
// changes on behalf of the deployment in enterprise edition
|
||||
multiregionTriggers
|
||||
|
||||
// state is the state that is watched for state changes.
|
||||
state *state.StateStore
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@ package deploymentwatcher
|
||||
|
||||
import "github.com/hashicorp/nomad/nomad/structs"
|
||||
|
||||
// TODO: move this into multiregion_oss.go once #269 is merged
|
||||
type multiregionTriggers interface{}
|
||||
|
||||
func (w *deploymentWatcher) nextRegion(status string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnblockDeployment is used to unblock a multiregion deployment. In
|
||||
// single-region deployments, the blocked state is unused.
|
||||
@@ -28,6 +28,15 @@ const (
|
||||
ErrUnknownDeploymentPrefix = "Unknown deployment"
|
||||
|
||||
errRPCCodedErrorPrefix = "RPC Error:: "
|
||||
|
||||
errDeploymentTerminalNoCancel = "can't cancel terminal deployment"
|
||||
errDeploymentTerminalNoFail = "can't fail terminal deployment"
|
||||
errDeploymentTerminalNoPause = "can't pause terminal deployment"
|
||||
errDeploymentTerminalNoPromote = "can't promote terminal deployment"
|
||||
errDeploymentTerminalNoResume = "can't resume terminal deployment"
|
||||
errDeploymentTerminalNoUnblock = "can't unblock terminal deployment"
|
||||
errDeploymentTerminalNoSetHealth = "can't set health of allocations for a terminal deployment"
|
||||
errDeploymentRunningNoUnblock = "can't unblock running deployment"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -41,6 +50,15 @@ var (
|
||||
ErrUnknownNomadVersion = errors.New(errUnknownNomadVersion)
|
||||
ErrNodeLacksRpc = errors.New(errNodeLacksRpc)
|
||||
ErrMissingAllocID = errors.New(errMissingAllocID)
|
||||
|
||||
ErrDeploymentTerminalNoCancel = errors.New(errDeploymentTerminalNoCancel)
|
||||
ErrDeploymentTerminalNoFail = errors.New(errDeploymentTerminalNoFail)
|
||||
ErrDeploymentTerminalNoPause = errors.New(errDeploymentTerminalNoPause)
|
||||
ErrDeploymentTerminalNoPromote = errors.New(errDeploymentTerminalNoPromote)
|
||||
ErrDeploymentTerminalNoResume = errors.New(errDeploymentTerminalNoResume)
|
||||
ErrDeploymentTerminalNoUnblock = errors.New(errDeploymentTerminalNoUnblock)
|
||||
ErrDeploymentTerminalNoSetHealth = errors.New(errDeploymentTerminalNoSetHealth)
|
||||
ErrDeploymentRunningNoUnblock = errors.New(errDeploymentRunningNoUnblock)
|
||||
)
|
||||
|
||||
// IsErrNoLeader returns whether the error is due to there being no leader.
|
||||
|
||||
Reference in New Issue
Block a user