Skip to content
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

Automated cherry pick of #87505: kubeadm: handle multiple members without names during #89441

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions cmd/kubeadm/app/util/etcd/etcd.go
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down