-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
etcdserver: include IsLeader in etcdserverpb.Member #4487
Conversation
Thanks. |
would this be better as a flag in |
membs := cs.cluster.Members() | ||
var peerURLs []string | ||
if len(membs) > 0 { | ||
peerURLs = membs[0].PeerURLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is membs[0]
always the leader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sorted by ID, so I think it's not always (https://github.com/coreos/etcd/blob/master/etcdserver/member.go#L160-L165).
@heyitsanthony I will try to include leader information in Thanks. |
@heyitsanthony Just addressed. PTAL.Thanks! |
@@ -323,10 +323,11 @@ message Member { | |||
uint64 ID = 1; | |||
// If the member is not started, name will be an empty string. | |||
string name = 2; | |||
repeated string peerURLs = 3; | |||
uint64 LeaderID = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool isLeader
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah boolean is easier to use. Will change.
@heyitsanthony PTAL. Just changed it to |
can we add another API called memberLeader instead of adding this field? |
Or shall we do it in client library? |
@xiang90 I have code that adds |
@xiang90 MemberLeader() can go in the client library. |
So |
yeah, the clientv3 implementation would just process memberlist if it's using the bool flag |
Ok will add that. Thanks. |
Just added |
lgtm |
Thanks. Will merge in green lights. |
@@ -33,6 +34,9 @@ type Cluster interface { | |||
// List lists the current cluster membership. | |||
MemberList(ctx context.Context) (*MemberListResponse, error) | |||
|
|||
// Leader returns the current leader member. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this comment. You mean to make the comment MemberLeader
? I can change that in a separate PR with the fix for MemberList
as well.
etcdserver: include IsLeader in etcdserverpb.Member
This is especially useful to functional-test leader failure.
For #4477.