Signed-off-by: Dong Chen <dongluo.chen@docker.com>
Dong Chen authored on 2017/02/18 03:34:21... | ... |
@@ -25,6 +25,8 @@ import ( |
25 | 25 |
"golang.org/x/time/rate" |
26 | 26 |
) |
27 | 27 |
|
28 |
+const defaultGossipConvergeDelay = 2 * time.Second |
|
29 |
+ |
|
28 | 30 |
// controller implements agent.Controller against docker's API. |
29 | 31 |
// |
30 | 32 |
// Most operations against docker's API are done through the container name, |
... | ... |
@@ -323,6 +325,13 @@ func (r *controller) Shutdown(ctx context.Context) error { |
323 | 323 |
// started. |
324 | 324 |
} |
325 | 325 |
|
326 |
+ // add a delay for gossip converge |
|
327 |
+ // TODO(dongluochen): this delay shoud be configurable to fit different cluster size and network delay. |
|
328 |
+ // TODO(dongluochen): if there is no service binding for this container, this delay is not necessary. |
|
329 |
+ // if r.adapter.deactivateServiceBinding can return an error to indicate that, it'd reduce service |
|
330 |
+ // converge time. |
|
331 |
+ time.Sleep(defaultGossipConvergeDelay) |
|
332 |
+ |
|
326 | 333 |
if err := r.adapter.shutdown(ctx); err != nil { |
327 | 334 |
if isUnknownContainer(err) || isStoppedContainer(err) { |
328 | 335 |
return nil |