1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #23553 from icecrime/heartbeat_as_duration

Make `--dispatcher-heartbeat-period` a duration
This commit is contained in:
Arnaud Porterie 2016-06-15 02:36:17 +00:00 committed by GitHub
commit 2e9aac59e2
3 changed files with 21 additions and 17 deletions

View file

@ -2,6 +2,7 @@ package swarm
import ( import (
"fmt" "fmt"
"time"
"golang.org/x/net/context" "golang.org/x/net/context"
@ -13,10 +14,10 @@ import (
) )
type updateOptions struct { type updateOptions struct {
autoAccept AutoAcceptOption autoAccept AutoAcceptOption
secret string secret string
taskHistoryLimit int64 taskHistoryLimit int64
heartbeatPeriod uint64 dispatcherHeartbeat time.Duration
} }
func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command { func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command {
@ -36,7 +37,7 @@ func newUpdateCommand(dockerCli *client.DockerCli) *cobra.Command {
flags.Var(&opts.autoAccept, "auto-accept", "Auto acceptance policy (worker, manager or none)") flags.Var(&opts.autoAccept, "auto-accept", "Auto acceptance policy (worker, manager or none)")
flags.StringVar(&opts.secret, "secret", "", "Set secret value needed to accept nodes into cluster") flags.StringVar(&opts.secret, "secret", "", "Set secret value needed to accept nodes into cluster")
flags.Int64Var(&opts.taskHistoryLimit, "task-history-limit", 10, "Task history retention limit") flags.Int64Var(&opts.taskHistoryLimit, "task-history-limit", 10, "Task history retention limit")
flags.Uint64Var(&opts.heartbeatPeriod, "dispatcher-heartbeat-period", 5000000000, "Dispatcher heartbeat period") flags.DurationVar(&opts.dispatcherHeartbeat, "dispatcher-heartbeat", time.Duration(5*time.Second), "Dispatcher heartbeat period")
return cmd return cmd
} }
@ -85,8 +86,10 @@ func mergeSwarm(swarm *swarm.Swarm, flags *pflag.FlagSet) error {
spec.Orchestration.TaskHistoryRetentionLimit, _ = flags.GetInt64("task-history-limit") spec.Orchestration.TaskHistoryRetentionLimit, _ = flags.GetInt64("task-history-limit")
} }
if flags.Changed("dispatcher-heartbeat-period") { if flags.Changed("dispatcher-heartbeat") {
spec.Dispatcher.HeartbeatPeriod, _ = flags.GetUint64("dispatcher-heartbeat-period") if v, err := flags.GetDuration("dispatcher-heartbeat"); err == nil {
spec.Dispatcher.HeartbeatPeriod = uint64(v.Nanoseconds())
}
} }
return nil return nil

View file

@ -1641,7 +1641,7 @@ _docker_swarm_join() {
_docker_swarm_update() { _docker_swarm_update() {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "--auto-accept --dispatcher-heartbeat-period --help --secret --task-history-limit" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--auto-accept --dispatcher-heartbeat --help --secret --task-history-limit" -- "$cur" ) )
;; ;;
esac esac
} }

View file

@ -12,15 +12,16 @@ parent = "smn_cli"
# swarm update # swarm update
Usage: docker swarm update [OPTIONS] Usage: docker swarm update [OPTIONS]
update the Swarm. update the Swarm.
Options: Options:
--auto-accept value Acceptance policy (default [worker,manager]) --auto-accept value Auto acceptance policy (worker, manager or none)
--help Print usage --dispatcher-heartbeat duration Dispatcher heartbeat period (default 5s)
--secret string Set secret value needed to accept nodes into cluster --help Print usage
--secret string Set secret value needed to accept nodes into cluster
--task-history-limit int Task history retention limit (default 10)
Updates a Swarm cluster with new parameter values. This command must target a manager node. Updates a Swarm cluster with new parameter values. This command must target a manager node.