cluster: avoid recursive readlock on swarm info
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
diff --git a/daemon/cluster/swarm.go b/daemon/cluster/swarm.go
index e3fffe9..6122369 100644
--- a/daemon/cluster/swarm.go
+++ b/daemon/cluster/swarm.go
@@ -198,9 +198,9 @@
// 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 @@
}); 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 @@
if state.IsActiveManager() {
info.ControlAvailable = true
- swarm, err := c.Inspect()
+ swarm, err := c.inspect(ctx, state)
if err != nil {
info.Error = err.Error()
}