mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #87505 from neolit123/1.18-handle-etcd-members-without-names
kubeadm: improvements to the concurrent etcd member join support
This commit is contained in:
commit
236eee1eba
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user