@@ -42,7 +42,7 @@ const etcdTimeout = 2 * time.Second
42
42
43
43
// Exponential backoff for etcd operations
44
44
var etcdBackoff = wait.Backoff {
45
- Steps : 9 ,
45
+ Steps : 11 ,
46
46
Duration : 50 * time .Millisecond ,
47
47
Factor : 2.0 ,
48
48
Jitter : 0.1 ,
@@ -128,9 +128,9 @@ func NewFromCluster(client clientset.Interface, certificatesDir string) (*Client
128
128
}
129
129
130
130
// dialTimeout is the timeout for failing to establish a connection.
131
- // It is set to 20 seconds as times shorter than that will cause TLS connections to fail
131
+ // It is set to > 20 seconds as times shorter than that will cause TLS connections to fail
132
132
// on heavily loaded arm64 CPUs (issue #64649)
133
- const dialTimeout = 20 * time .Second
133
+ const dialTimeout = 40 * time .Second
134
134
135
135
// Sync synchronizes client's endpoints with the known endpoints from the etcd membership.
136
136
func (c * Client ) Sync () error {
@@ -303,12 +303,20 @@ func (c *Client) AddMember(name string, peerAddrs string) ([]Member, error) {
303
303
// Returns the updated list of etcd members
304
304
ret := []Member {}
305
305
for _ , m := range resp .Members {
306
- // fixes the entry for the joining member (that doesn't have a name set in the initialCluster returned by etcd)
307
- if m .Name == "" {
308
- ret = append (ret , Member {Name : name , PeerURL : m .PeerURLs [0 ]})
309
- } else {
310
- ret = append (ret , Member {Name : m .Name , PeerURL : m .PeerURLs [0 ]})
306
+ // If the peer address matches, this is the member we are adding.
307
+ // Use the name we passed to the function.
308
+ if peerAddrs == m .PeerURLs [0 ] {
309
+ ret = append (ret , Member {Name : name , PeerURL : peerAddrs })
310
+ continue
311
+ }
312
+ // Otherwise, we are processing other existing etcd members returned by AddMembers.
313
+ memberName := m .Name
314
+ // In some cases during concurrent join, some members can end up without a name.
315
+ // Use the member ID as name for those.
316
+ if len (memberName ) == 0 {
317
+ memberName = strconv .FormatUint (m .ID , 16 )
311
318
}
319
+ ret = append (ret , Member {Name : memberName , PeerURL : m .PeerURLs [0 ]})
312
320
}
313
321
314
322
// Add the new member client address to the list of endpoints
0 commit comments