diff --git a/cluster/cluster.go b/cluster/cluster.go index bcc0f93d..e3b386fd 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -32,6 +32,7 @@ type Cluster struct { WorkerHosts []*hosts.Host ControlPlaneHosts []*hosts.Host InactiveHosts []*hosts.Host + EtcdReadyHosts []*hosts.Host KubeClient *kubernetes.Clientset KubernetesServiceIP net.IP Certificates map[string]pki.CertificatePKI diff --git a/cluster/plan.go b/cluster/plan.go index 4e180486..6a05881f 100644 --- a/cluster/plan.go +++ b/cluster/plan.go @@ -59,7 +59,7 @@ func BuildRKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts portChecks = append(portChecks, BuildPortChecksFromPortList(host, ControlPlanePortList, ProtocolTCP)...) } 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)...) } diff --git a/cluster/reconcile.go b/cluster/reconcile.go index 5464db35..a7efa4ac 100644 --- a/cluster/reconcile.go +++ b/cluster/reconcile.go @@ -208,14 +208,14 @@ func reconcileEtcd(ctx context.Context, currentCluster, kubeCluster *Cluster, ku } } etcdHost.ToAddEtcdMember = false - readyHosts := getReadyEtcdHosts(kubeCluster.EtcdHosts) + kubeCluster.setReadyEtcdHosts() etcdNodePlanMap := make(map[string]v3.RKEConfigNodePlan) - for _, etcdReadyHost := range readyHosts { + for _, etcdReadyHost := range kubeCluster.EtcdReadyHosts { 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 } } @@ -239,13 +239,12 @@ func syncLabels(ctx context.Context, currentCluster, kubeCluster *Cluster) { } } -func getReadyEtcdHosts(etcdHosts []*hosts.Host) []*hosts.Host { - readyEtcdHosts := []*hosts.Host{} - for _, host := range etcdHosts { +func (c *Cluster) setReadyEtcdHosts() { + c.EtcdReadyHosts = []*hosts.Host{} + for _, host := range c.EtcdHosts { if !host.ToAddEtcdMember { - readyEtcdHosts = append(readyEtcdHosts, host) + c.EtcdReadyHosts = append(c.EtcdReadyHosts, host) host.ExistingEtcdCluster = true } } - return readyEtcdHosts }