Fix bug in Member Exists Join for Kubeadm etcd join

In kubeadm etcd join there is a a bug that exists where,
if a peer already exists in etcd, it attempts to mitigate
by continuing and generating the etcd manifest file. However,
this existing "member name" may actually be unset, causing
subsequent etcd consistency checks to fail.

This change checks if the member name is empty - if it is,
it sets the member name to the node name, and resumes.
This commit is contained in:
Ian Gann 2020-12-17 11:54:02 -08:00
parent 4351e4dd47
commit dc70c79a00

View File

@ -162,9 +162,13 @@ func CreateStackedEtcdStaticPodManifestFile(client clientset.Interface, manifest
// only add the new member if it doesn't already exists
var exists bool
klog.V(1).Infof("[etcd] Checking if the etcd member already exists: %s", etcdPeerAddress)
for _, member := range initialCluster {
if member.PeerURL == etcdPeerAddress {
for i := range initialCluster {
if initialCluster[i].PeerURL == etcdPeerAddress {
exists = true
if len(initialCluster[i].Name) == 0 {
klog.V(1).Infof("[etcd] etcd member name is empty. Setting it to the node name: %s", nodeName)
initialCluster[i].Name = nodeName
}
break
}
}