From e5aeb3bdbc1784c01ffcd2935c72cd61a626fcaa Mon Sep 17 00:00:00 2001 From: Dong Chen Date: Fri, 17 Feb 2017 10:34:21 -0800 Subject: [PATCH] add 2 seocnd delay to allow gossip converge Signed-off-by: Dong Chen Upstream-commit: 4d233943331865cab0cdd1b0bb986a4492bf74b1 Component: engine --- .../daemon/cluster/executor/container/controller.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/engine/daemon/cluster/executor/container/controller.go b/components/engine/daemon/cluster/executor/container/controller.go index da09d2ee47..4552735f59 100644 --- a/components/engine/daemon/cluster/executor/container/controller.go +++ b/components/engine/daemon/cluster/executor/container/controller.go @@ -25,6 +25,8 @@ import ( "golang.org/x/time/rate" ) +const defaultGossipConvergeDelay = 2 * time.Second + // controller implements agent.Controller against docker's API. // // Most operations against docker's API are done through the container name, @@ -323,6 +325,13 @@ func (r *controller) Shutdown(ctx context.Context) error { // started. } + // add a delay for gossip converge + // TODO(dongluochen): this delay shoud be configurable to fit different cluster size and network delay. + // TODO(dongluochen): if there is no service binding for this container, this delay is not necessary. + // if r.adapter.deactivateServiceBinding can return an error to indicate that, it'd reduce service + // converge time. + time.Sleep(defaultGossipConvergeDelay) + if err := r.adapter.shutdown(ctx); err != nil { if isUnknownContainer(err) || isStoppedContainer(err) { return nil