mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add support for the "rollback" failure action
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
94d1a5b366
commit
cc9d04647a
7 changed files with 23 additions and 3 deletions
|
@ -2256,6 +2256,7 @@ definitions:
|
|||
enum:
|
||||
- "continue"
|
||||
- "pause"
|
||||
- "rollback"
|
||||
Monitor:
|
||||
description: "Amount of time to monitor each updated task for failures, in nanoseconds."
|
||||
type: "integer"
|
||||
|
|
|
@ -45,6 +45,12 @@ const (
|
|||
UpdateStatePaused UpdateState = "paused"
|
||||
// UpdateStateCompleted is the completed state.
|
||||
UpdateStateCompleted UpdateState = "completed"
|
||||
// UpdateStateRollbackStarted is the state with a rollback in progress.
|
||||
UpdateStateRollbackStarted UpdateState = "rollback_started"
|
||||
// UpdateStateRollbackPaused is the state with a rollback in progress.
|
||||
UpdateStateRollbackPaused UpdateState = "rollback_paused"
|
||||
// UpdateStateRollbackCompleted is the state with a rollback in progress.
|
||||
UpdateStateRollbackCompleted UpdateState = "rollback_completed"
|
||||
)
|
||||
|
||||
// UpdateStatus reports the status of a service update.
|
||||
|
@ -68,6 +74,8 @@ const (
|
|||
UpdateFailureActionPause = "pause"
|
||||
// UpdateFailureActionContinue CONTINUE
|
||||
UpdateFailureActionContinue = "continue"
|
||||
// UpdateFailureActionRollback ROLLBACK
|
||||
UpdateFailureActionRollback = "rollback"
|
||||
)
|
||||
|
||||
// UpdateConfig represents the update configuration.
|
||||
|
|
|
@ -487,7 +487,7 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
|
|||
flags.DurationVar(&opts.update.delay, flagUpdateDelay, time.Duration(0), "Delay between updates (ns|us|ms|s|m|h) (default 0s)")
|
||||
flags.DurationVar(&opts.update.monitor, flagUpdateMonitor, time.Duration(0), "Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)")
|
||||
flags.SetAnnotation(flagUpdateMonitor, "version", []string{"1.25"})
|
||||
flags.StringVar(&opts.update.onFailure, flagUpdateFailureAction, "pause", `Action on update failure ("pause"|"continue")`)
|
||||
flags.StringVar(&opts.update.onFailure, flagUpdateFailureAction, "pause", `Action on update failure ("pause"|"continue"|"rollback")`)
|
||||
flags.Var(&opts.update.maxFailureRatio, flagUpdateMaxFailureRatio, "Failure rate to tolerate during an update")
|
||||
flags.SetAnnotation(flagUpdateMaxFailureRatio, "version", []string{"1.25"})
|
||||
|
||||
|
|
|
@ -35,6 +35,12 @@ func ServiceFromGRPC(s swarmapi.Service) types.Service {
|
|||
service.UpdateStatus.State = types.UpdateStatePaused
|
||||
case swarmapi.UpdateStatus_COMPLETED:
|
||||
service.UpdateStatus.State = types.UpdateStateCompleted
|
||||
case swarmapi.UpdateStatus_ROLLBACK_STARTED:
|
||||
service.UpdateStatus.State = types.UpdateStateRollbackStarted
|
||||
case swarmapi.UpdateStatus_ROLLBACK_PAUSED:
|
||||
service.UpdateStatus.State = types.UpdateStateRollbackPaused
|
||||
case swarmapi.UpdateStatus_ROLLBACK_COMPLETED:
|
||||
service.UpdateStatus.State = types.UpdateStateRollbackCompleted
|
||||
}
|
||||
|
||||
startedAt, _ := gogotypes.TimestampFromProto(s.UpdateStatus.StartedAt)
|
||||
|
@ -102,6 +108,8 @@ func serviceSpecFromGRPC(spec *swarmapi.ServiceSpec) *types.ServiceSpec {
|
|||
convertedSpec.UpdateConfig.FailureAction = types.UpdateFailureActionPause
|
||||
case swarmapi.UpdateConfig_CONTINUE:
|
||||
convertedSpec.UpdateConfig.FailureAction = types.UpdateFailureActionContinue
|
||||
case swarmapi.UpdateConfig_ROLLBACK:
|
||||
convertedSpec.UpdateConfig.FailureAction = types.UpdateFailureActionRollback
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,6 +195,8 @@ func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) {
|
|||
failureAction = swarmapi.UpdateConfig_PAUSE
|
||||
case types.UpdateFailureActionContinue:
|
||||
failureAction = swarmapi.UpdateConfig_CONTINUE
|
||||
case types.UpdateFailureActionRollback:
|
||||
failureAction = swarmapi.UpdateConfig_ROLLBACK
|
||||
default:
|
||||
return swarmapi.ServiceSpec{}, fmt.Errorf("unrecognized update failure action %s", s.UpdateConfig.FailureAction)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ keywords: "API, Docker, rcli, REST, documentation"
|
|||
* `GET /containers/json` now supports `publish` and `expose` filters to filter containers that expose or publish certain ports.
|
||||
* `POST /services/create` and `POST /services/(id or name)/update` now accept the `ReadOnly` parameter, which mounts the container's root filesystem as read only.
|
||||
* `POST /build` now accepts `extrahosts` parameter to specify a host to ip mapping to use during the build.
|
||||
* `POST /services/create` and `POST /services/(id or name)/update` now accept a `rollback` value for `FailureAction`.
|
||||
|
||||
## v1.26 API changes
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Options:
|
|||
--stop-signal string Signal to stop the container
|
||||
-t, --tty Allocate a pseudo-TTY
|
||||
--update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s)
|
||||
--update-failure-action string Action on update failure ("pause"|"continue") (default "pause")
|
||||
--update-failure-action string Action on update failure ("pause"|"continue"|"rollback") (default "pause")
|
||||
--update-max-failure-ratio float Failure rate to tolerate during an update
|
||||
--update-monitor duration Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)
|
||||
--update-parallelism uint Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
|
||||
|
|
|
@ -75,7 +75,7 @@ Options:
|
|||
--stop-signal string Signal to stop the container
|
||||
-t, --tty Allocate a pseudo-TTY
|
||||
--update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s)
|
||||
--update-failure-action string Action on update failure ("pause"|"continue") (default "pause")
|
||||
--update-failure-action string Action on update failure ("pause"|"continue"|"rollback") (default "pause")
|
||||
--update-max-failure-ratio float Failure rate to tolerate during an update
|
||||
--update-monitor duration Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)
|
||||
--update-parallelism uint Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
|
||||
|
|
Loading…
Add table
Reference in a new issue