diff --git a/cmd/kubeadm/app/util/etcd/etcd.go b/cmd/kubeadm/app/util/etcd/etcd.go index 09ada277530..461ce8477d5 100644 --- a/cmd/kubeadm/app/util/etcd/etcd.go +++ b/cmd/kubeadm/app/util/etcd/etcd.go @@ -42,7 +42,7 @@ const etcdTimeout = 2 * time.Second // Exponential backoff for etcd operations var etcdBackoff = wait.Backoff{ - Steps: 9, + Steps: 11, Duration: 50 * time.Millisecond, Factor: 2.0, Jitter: 0.1, @@ -128,9 +128,9 @@ func NewFromCluster(client clientset.Interface, certificatesDir string) (*Client } // dialTimeout is the timeout for failing to establish a connection. -// It is set to 20 seconds as times shorter than that will cause TLS connections to fail +// It is set to >20 seconds as times shorter than that will cause TLS connections to fail // on heavily loaded arm64 CPUs (issue #64649) -const dialTimeout = 20 * time.Second +const dialTimeout = 40 * time.Second // Sync synchronizes client's endpoints with the known endpoints from the etcd membership. func (c *Client) Sync() error { @@ -303,12 +303,20 @@ func (c *Client) AddMember(name string, peerAddrs string) ([]Member, error) { // Returns the updated list of etcd members ret := []Member{} for _, m := range resp.Members { - // fixes the entry for the joining member (that doesn't have a name set in the initialCluster returned by etcd) - if m.Name == "" { - ret = append(ret, Member{Name: name, PeerURL: m.PeerURLs[0]}) - } else { - ret = append(ret, Member{Name: m.Name, PeerURL: m.PeerURLs[0]}) + // If the peer address matches, this is the member we are adding. + // Use the name we passed to the function. + if peerAddrs == m.PeerURLs[0] { + ret = append(ret, Member{Name: name, PeerURL: peerAddrs}) + continue } + // Otherwise, we are processing other existing etcd members returned by AddMembers. + memberName := m.Name + // In some cases during concurrent join, some members can end up without a name. + // Use the member ID as name for those. + if len(memberName) == 0 { + memberName = strconv.FormatUint(m.ID, 16) + } + ret = append(ret, Member{Name: memberName, PeerURL: m.PeerURLs[0]}) } // Add the new member client address to the list of endpoints