mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 15:06:23 +00:00
Fix multiple etcd add at runtime
This commit is contained in:
committed by
Darren Shepherd
parent
829afa1084
commit
b3f457426c
@@ -32,6 +32,7 @@ type Cluster struct {
|
|||||||
WorkerHosts []*hosts.Host
|
WorkerHosts []*hosts.Host
|
||||||
ControlPlaneHosts []*hosts.Host
|
ControlPlaneHosts []*hosts.Host
|
||||||
InactiveHosts []*hosts.Host
|
InactiveHosts []*hosts.Host
|
||||||
|
EtcdReadyHosts []*hosts.Host
|
||||||
KubeClient *kubernetes.Clientset
|
KubeClient *kubernetes.Clientset
|
||||||
KubernetesServiceIP net.IP
|
KubernetesServiceIP net.IP
|
||||||
Certificates map[string]pki.CertificatePKI
|
Certificates map[string]pki.CertificatePKI
|
||||||
|
@@ -59,7 +59,7 @@ func BuildRKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts
|
|||||||
portChecks = append(portChecks, BuildPortChecksFromPortList(host, ControlPlanePortList, ProtocolTCP)...)
|
portChecks = append(portChecks, BuildPortChecksFromPortList(host, ControlPlanePortList, ProtocolTCP)...)
|
||||||
}
|
}
|
||||||
if host.IsEtcd {
|
if host.IsEtcd {
|
||||||
processes[services.EtcdContainerName] = myCluster.BuildEtcdProcess(host, nil, prefixPath)
|
processes[services.EtcdContainerName] = myCluster.BuildEtcdProcess(host, myCluster.EtcdReadyHosts, prefixPath)
|
||||||
|
|
||||||
portChecks = append(portChecks, BuildPortChecksFromPortList(host, EtcdPortList, ProtocolTCP)...)
|
portChecks = append(portChecks, BuildPortChecksFromPortList(host, EtcdPortList, ProtocolTCP)...)
|
||||||
}
|
}
|
||||||
|
@@ -208,14 +208,14 @@ func reconcileEtcd(ctx context.Context, currentCluster, kubeCluster *Cluster, ku
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
etcdHost.ToAddEtcdMember = false
|
etcdHost.ToAddEtcdMember = false
|
||||||
readyHosts := getReadyEtcdHosts(kubeCluster.EtcdHosts)
|
kubeCluster.setReadyEtcdHosts()
|
||||||
|
|
||||||
etcdNodePlanMap := make(map[string]v3.RKEConfigNodePlan)
|
etcdNodePlanMap := make(map[string]v3.RKEConfigNodePlan)
|
||||||
for _, etcdReadyHost := range readyHosts {
|
for _, etcdReadyHost := range kubeCluster.EtcdReadyHosts {
|
||||||
etcdNodePlanMap[etcdReadyHost.Address] = BuildRKEConfigNodePlan(ctx, kubeCluster, etcdReadyHost, etcdReadyHost.DockerInfo)
|
etcdNodePlanMap[etcdReadyHost.Address] = BuildRKEConfigNodePlan(ctx, kubeCluster, etcdReadyHost, etcdReadyHost.DockerInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := services.ReloadEtcdCluster(ctx, readyHosts, currentCluster.LocalConnDialerFactory, clientCert, clientkey, currentCluster.PrivateRegistriesMap, etcdNodePlanMap, kubeCluster.SystemImages.Alpine); err != nil {
|
if err := services.ReloadEtcdCluster(ctx, kubeCluster.EtcdReadyHosts, currentCluster.LocalConnDialerFactory, clientCert, clientkey, currentCluster.PrivateRegistriesMap, etcdNodePlanMap, kubeCluster.SystemImages.Alpine); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,13 +239,12 @@ func syncLabels(ctx context.Context, currentCluster, kubeCluster *Cluster) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getReadyEtcdHosts(etcdHosts []*hosts.Host) []*hosts.Host {
|
func (c *Cluster) setReadyEtcdHosts() {
|
||||||
readyEtcdHosts := []*hosts.Host{}
|
c.EtcdReadyHosts = []*hosts.Host{}
|
||||||
for _, host := range etcdHosts {
|
for _, host := range c.EtcdHosts {
|
||||||
if !host.ToAddEtcdMember {
|
if !host.ToAddEtcdMember {
|
||||||
readyEtcdHosts = append(readyEtcdHosts, host)
|
c.EtcdReadyHosts = append(c.EtcdReadyHosts, host)
|
||||||
host.ExistingEtcdCluster = true
|
host.ExistingEtcdCluster = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return readyEtcdHosts
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user