-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add swarm Is Leader field to docker info #25065
Comments
@kencochrane I think there is a https://github.com/docker/docker/blob/v1.12.0-rc4/daemon/cluster/cluster.go#L599-L601 |
@yongtang yes, you can call it like this. |
This field would be useless for Workers though (as in the information is only useful for Managers). Does this mean that we should only show the field when you are a Manager? Also the proper way I think to get those types of information and query for the Leader is to use the The problem being that you only get this on Managers. But we can think about giving limited access to the Agents to proxy their requests (to list manager nodes, etc.) to the Manager they are connected to. Then in one call you know if you are a Manager or not but also who is the Leader in the cluster. |
@abronan you could either only show the
The
That would be helpful, it would reduce the number of lookups required to find out if a node is a leader. Another thing that would be great (which this would now allow), is the ability to get the ClusterID in |
What's the use case for figuring out which node is the leader? It should be pretty transparent to the user. The only time I use it is testing the code ("what happens if i kill the leader?")
The |
We need to know if the current node is the leader for docker for aws and docker for azure. The servers don't know anything and we use the docker info commands to find out if it is a worker or manager node, and if manager if it is the leader. It comes into play when we upgrade the servers, we need to know if the node is the current leader so that we can make sure we don't cause any problems during the upgrade. We also run some commands only on the leader node, so knowing which node is the leader is important for this. These are all scripted against the CLI, so getting the data easily is important. Sorry about the confusion around the * I think it was like that in old versions of swarmkit. The CLI changes so often, it is hard to keep it all straight. |
FYI: Comments from another PR that led to this issue getting created. |
As a workaround, you can use
|
Right now docker info will return if a node is a swarm manager, but it doesn't say if that node is the leader node or not.
There is a way to find out by doing
docker node inspect self -f "{{ .ManagerStatus.Leader }}"
but this will not work on worker nodes, only manager nodes, since the node inspect isn't available on worker nodes.So you need to make two calls, find out if the node is a manager, and if so, then make the second call to find out if the node is a leader. Adding it to Docker info, will make it only one call, and it will work for both workers and managers.
End result would look like this.
If this seems reasonable, I can submit a PR, but I will need a little help to point me in the right direction for where the change needs to happen, I'm guessing there might need to be a swarmkit change as well?
@aluzzardi
The text was updated successfully, but these errors were encountered: