-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Migrate cluster attributes to use v3 backend #11427
Changes from 1 commit
dcd622b
0c3401f
5cd2502
ed5a01a
7784ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -732,7 +732,7 @@ func (s *EtcdServer) adjustTicks() { | |
func (s *EtcdServer) Start() { | ||
s.start() | ||
s.goAttach(func() { s.adjustTicks() }) | ||
s.goAttach(func() { s.publish(s.Cfg.ReqTimeout()) }) | ||
s.goAttach(func() { s.publishV3(s.Cfg.ReqTimeout()) }) | ||
s.goAttach(s.purgeFile) | ||
s.goAttach(func() { monitorFileDescriptor(s.getLogger(), s.stopping) }) | ||
s.goAttach(s.monitorVersions) | ||
|
@@ -1992,6 +1992,67 @@ func (s *EtcdServer) sync(timeout time.Duration) { | |
}) | ||
} | ||
|
||
// publishV3 registers server information into the cluster using v3 request. The | ||
// information is the JSON representation of this server's member struct, updated | ||
// with the static clientURLs of the server. | ||
// The function keeps attempting to register until it succeeds, | ||
// or its server is stopped. | ||
func (s *EtcdServer) publishV3(timeout time.Duration) { | ||
req := &membershippb.ClusterMemberAttrSetRequest{ | ||
Member_ID: uint64(s.id), | ||
MemberAttributes: &membershippb.Attributes{ | ||
Name: s.attributes.Name, | ||
ClientUrls: s.attributes.ClientURLs, | ||
}, | ||
} | ||
|
||
for { | ||
select { | ||
case <-s.stopping: | ||
if lg := s.getLogger(); lg != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Will fix other |
||
lg.Warn( | ||
"stopped publish because server is stopping", | ||
zap.String("local-member-id", s.ID().String()), | ||
zap.String("local-member-attributes", fmt.Sprintf("%+v", s.attributes)), | ||
zap.Duration("publish-timeout", timeout), | ||
) | ||
} | ||
return | ||
|
||
default: | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(s.ctx, timeout) | ||
_, err := s.raftRequest(ctx, pb.InternalRaftRequest{ClusterMemberAttrSet: req}) | ||
cancel() | ||
switch err { | ||
case nil: | ||
close(s.readych) | ||
if lg := s.getLogger(); lg != nil { | ||
lg.Info( | ||
"published local member to cluster through raft", | ||
zap.String("local-member-id", s.ID().String()), | ||
zap.String("local-member-attributes", fmt.Sprintf("%+v", s.attributes)), | ||
zap.String("cluster-id", s.cluster.ID().String()), | ||
zap.Duration("publish-timeout", timeout), | ||
) | ||
} | ||
return | ||
|
||
default: | ||
if lg := s.getLogger(); lg != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. Can we store variable once at top (before |
||
lg.Warn( | ||
"failed to publish local member to cluster through raft", | ||
zap.String("local-member-id", s.ID().String()), | ||
zap.String("local-member-attributes", fmt.Sprintf("%+v", s.attributes)), | ||
zap.Duration("publish-timeout", timeout), | ||
zap.Error(err), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// publish registers server information into the cluster. The information | ||
// is the JSON representation of this server's member struct, updated with the | ||
// static clientURLs of the server. | ||
|
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.
Add a TODO to replace publish() in etcd 3.6?
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.
Added