diff --git a/nomad/deployment_endpoint.go b/nomad/deployment_endpoint.go index 6dae8c4ab..838fdca4f 100644 --- a/nomad/deployment_endpoint.go +++ b/nomad/deployment_endpoint.go @@ -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 diff --git a/nomad/deploymentwatcher/deployment_watcher.go b/nomad/deploymentwatcher/deployment_watcher.go index 4c18757cb..1967e4262 100644 --- a/nomad/deploymentwatcher/deployment_watcher.go +++ b/nomad/deploymentwatcher/deployment_watcher.go @@ -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 diff --git a/nomad/deploymentwatcher/deployment_watcher_oss.go b/nomad/deploymentwatcher/multiregion_oss.go similarity index 86% rename from nomad/deploymentwatcher/deployment_watcher_oss.go rename to nomad/deploymentwatcher/multiregion_oss.go index cf4d5f055..f83cbf258 100644 --- a/nomad/deploymentwatcher/deployment_watcher_oss.go +++ b/nomad/deploymentwatcher/multiregion_oss.go @@ -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. diff --git a/nomad/structs/errors.go b/nomad/structs/errors.go index 2e3e1edd2..f1adc8b13 100644 --- a/nomad/structs/errors.go +++ b/nomad/structs/errors.go @@ -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.