1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-17 07:30:01 +00:00

Refactor reconcilation

Add role based add/delete for services

Use pointers for hosts

Consistent log format
This commit is contained in:
galal-hussein
2017-12-01 01:16:45 +02:00
parent 7699c6b5f0
commit d1f78f0b40
20 changed files with 341 additions and 202 deletions

View File

@@ -46,22 +46,24 @@ func (c *Cluster) TunnelHosts() error {
}
func (c *Cluster) InvertIndexHosts() error {
c.EtcdHosts = make([]hosts.Host, 0)
c.WorkerHosts = make([]hosts.Host, 0)
c.ControlPlaneHosts = make([]hosts.Host, 0)
c.EtcdHosts = make([]*hosts.Host, 0)
c.WorkerHosts = make([]*hosts.Host, 0)
c.ControlPlaneHosts = make([]*hosts.Host, 0)
for _, host := range c.Nodes {
newHost := hosts.Host{
RKEConfigNode: host,
}
for _, role := range host.Role {
logrus.Debugf("Host: " + host.Address + " has role: " + role)
newHost := hosts.Host{
RKEConfigNode: host,
}
switch role {
case services.ETCDRole:
c.EtcdHosts = append(c.EtcdHosts, newHost)
c.EtcdHosts = append(c.EtcdHosts, &newHost)
case services.ControlRole:
c.ControlPlaneHosts = append(c.ControlPlaneHosts, newHost)
newHost.IsControl = true
c.ControlPlaneHosts = append(c.ControlPlaneHosts, &newHost)
case services.WorkerRole:
c.WorkerHosts = append(c.WorkerHosts, newHost)
newHost.IsWorker = true
c.WorkerHosts = append(c.WorkerHosts, &newHost)
default:
return fmt.Errorf("Failed to recognize host [%s] role %s", host.Address, role)
}