From ee1be71e9dc52db8a7ac951ba96f18a5c894806a Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 2 Nov 2017 16:34:00 -0700 Subject: [PATCH] cluster: avoid recursive readlock on swarm info Signed-off-by: Tonis Tiigi --- daemon/cluster/swarm.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/cluster/swarm.go b/daemon/cluster/swarm.go index e3fffe983d..61223691bd 100644 --- a/daemon/cluster/swarm.go +++ b/daemon/cluster/swarm.go @@ -198,9 +198,9 @@ func (c *Cluster) Join(req types.JoinRequest) error { // Inspect retrieves the configuration properties of a managed swarm cluster. func (c *Cluster) Inspect() (types.Swarm, error) { - var swarm *swarmapi.Cluster + var swarm types.Swarm if err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error { - s, err := getSwarm(ctx, state.controlClient) + s, err := c.inspect(ctx, state) if err != nil { return err } @@ -209,7 +209,15 @@ func (c *Cluster) Inspect() (types.Swarm, error) { }); err != nil { return types.Swarm{}, err } - return convert.SwarmFromGRPC(*swarm), nil + return swarm, nil +} + +func (c *Cluster) inspect(ctx context.Context, state nodeState) (types.Swarm, error) { + s, err := getSwarm(ctx, state.controlClient) + if err != nil { + return types.Swarm{}, err + } + return convert.SwarmFromGRPC(*s), nil } // Update updates configuration of a managed swarm cluster. @@ -413,7 +421,7 @@ func (c *Cluster) Info() types.Info { if state.IsActiveManager() { info.ControlAvailable = true - swarm, err := c.Inspect() + swarm, err := c.inspect(ctx, state) if err != nil { info.Error = err.Error() }