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:
- 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.
- 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
We have the following code in
enableReconnectWatcherindaemon/cluster/noderunner.go:Setting
config.joinAddrlike this isn't quite right. There are two cases:remotes[0]will be the same address that was given toswarm join, and this code does nothing.JoinAddrtoswarmnode.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 causesObserveto 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
nodeRunnerknows whether the node successfully joined a swarm at this point. Ideally, if the node is part of a swarm, we should not be passingJoinAddr, and if we are retrying a failedswarm joinwe should keep passing the originalJoinAddr. Perhaps this could be accomplished by clearingconfig.joinAddrwhen thereadychannel is closed, and removing theconfig.joinAddr = config.RemoteAddrquoted 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