Skip to content

Don't pass random manager address to swarm node in JoinAddr #32980

Description

@aaronlehmann

We have the following code in enableReconnectWatcher in daemon/cluster/noderunner.go:

                remotes := n.cluster.getRemoteAddressList()
                if len(remotes) > 0 {
                        config.RemoteAddr = remotes[0]
                } else {
                        config.RemoteAddr = ""
                }

                config.joinAddr = config.RemoteAddr

Setting config.joinAddr like this isn't quite right. There are two cases:

  1. The node has not successfully joined a swarm yet. remotes[0] will be the same address that was given to swarm join, and this code does nothing.
  2. The node is already part of a swarm. In this case, we should not be passing a JoinAddr to swarmnode.New. If the node is a manager, it will log a warning about already being part of a swarm. On both workers and managers, this causes Observe to be called on the random manager address that's passed in, which distorts the order the node tries different managers.

I'm not sure if nodeRunner knows whether the node successfully joined a swarm at this point. Ideally, if the node is part of a swarm, we should not be passing JoinAddr, and if we are retrying a failed swarm join we should keep passing the original JoinAddr. Perhaps this could be accomplished by clearing config.joinAddr when the ready channel is closed, and removing the config.joinAddr = config.RemoteAddr quoted above.

This is not a big problem in practice. I think the only noticeable effect is log message about ignoring the join address.

cc @tonistiigi @fcrisciani

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/swarmpriority/P3Best effort: those are nice to have / minor issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions