1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-02 07:43:04 +00:00

Fix reconcile for ros prefix

This commit is contained in:
moelsayed 2018-06-26 00:50:45 +02:00 committed by Alena Prokharchyk
parent 74b81a8766
commit fdba4f86e5
5 changed files with 38 additions and 33 deletions

View File

@ -32,7 +32,7 @@ func (c *Cluster) TunnelHosts(ctx context.Context, local bool) error {
c.InactiveHosts = make([]*hosts.Host, 0)
uniqueHosts := hosts.GetUniqueHostList(c.EtcdHosts, c.ControlPlaneHosts, c.WorkerHosts)
for i := range uniqueHosts {
if err := uniqueHosts[i].TunnelUp(ctx, c.DockerDialerFactory); err != nil {
if err := uniqueHosts[i].TunnelUp(ctx, c.DockerDialerFactory, c.PrefixPath); err != nil {
// Unsupported Docker version is NOT a connectivity problem that we can recover! So we bail out on it
if strings.Contains(err.Error(), "Unsupported Docker version found") {
return err
@ -40,7 +40,6 @@ func (c *Cluster) TunnelHosts(ctx context.Context, local bool) error {
log.Warnf(ctx, "Failed to set up SSH tunneling for host [%s]: %v", uniqueHosts[i].Address, err)
c.InactiveHosts = append(c.InactiveHosts, uniqueHosts[i])
}
uniqueHosts[i].PrefixPath = c.getPrefixPath(uniqueHosts[i].DockerInfo.OperatingSystem)
}
for _, host := range c.InactiveHosts {
log.Warnf(ctx, "Removing host [%s] from node lists", host.Address)

View File

@ -23,12 +23,6 @@ import (
const (
EtcdPathPrefix = "/registry"
B2DOS = "Boot2Docker"
B2DPrefixPath = "/mnt/sda1/rke"
ROS = "RancherOS"
ROSPrefixPath = "/opt/rke"
CoreOS = "CoreOS"
CoreOSPrefixPath = "/opt/rke"
ContainerNameLabel = "io.rancher.rke.container.name"
CloudConfigSumEnv = "RKE_CLOUD_CONFIG_CHECKSUM"
)
@ -49,7 +43,7 @@ func GeneratePlan(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConf
}
func BuildRKEConfigNodePlan(ctx context.Context, myCluster *Cluster, host *hosts.Host, hostDockerInfo types.Info) v3.RKEConfigNodePlan {
prefixPath := myCluster.getPrefixPath(hostDockerInfo.OperatingSystem)
prefixPath := hosts.GetPrefixPath(hostDockerInfo.OperatingSystem, myCluster.PrefixPath)
processes := map[string]v3.Process{}
portChecks := []v3.PortCheck{}
// Everybody gets a sidecar and a kubelet..
@ -681,23 +675,6 @@ func BuildPortChecksFromPortList(host *hosts.Host, portList []string, proto stri
return portChecks
}
func (c *Cluster) getPrefixPath(osType string) string {
var prefixPath string
switch {
case c.PrefixPath != "/":
prefixPath = c.PrefixPath
case strings.Contains(osType, B2DOS):
prefixPath = B2DPrefixPath
case strings.Contains(osType, ROS):
prefixPath = ROSPrefixPath
case strings.Contains(osType, CoreOS):
prefixPath = CoreOSPrefixPath
default:
prefixPath = c.PrefixPath
}
return prefixPath
}
func (c *Cluster) GetKubernetesServicesOptions() v3.KubernetesServicesOptions {
clusterMajorVersion := getTagMajorVersion(c.Version)
NamedkK8sImage, _ := ref.ParseNormalizedNamed(c.SystemImages.Kubernetes)

View File

@ -61,7 +61,7 @@ func reconcileWorker(ctx context.Context, currentCluster, kubeCluster *Cluster,
return fmt.Errorf("Failed to delete worker node [%s] from cluster: %v", toDeleteHost.Address, err)
}
// attempting to clean services/files on the host
if err := reconcileHost(ctx, toDeleteHost, true, false, currentCluster.SystemImages.Alpine, currentCluster.DockerDialerFactory, currentCluster.PrivateRegistriesMap); err != nil {
if err := reconcileHost(ctx, toDeleteHost, true, false, currentCluster.SystemImages.Alpine, currentCluster.DockerDialerFactory, currentCluster.PrivateRegistriesMap, currentCluster.PrefixPath); err != nil {
log.Warnf(ctx, "[reconcile] Couldn't clean up worker node [%s]: %v", toDeleteHost.Address, err)
continue
}
@ -104,7 +104,7 @@ func reconcileControl(ctx context.Context, currentCluster, kubeCluster *Cluster,
return fmt.Errorf("Failed to delete controlplane node [%s] from cluster: %v", toDeleteHost.Address, err)
}
// attempting to clean services/files on the host
if err := reconcileHost(ctx, toDeleteHost, false, false, currentCluster.SystemImages.Alpine, currentCluster.DockerDialerFactory, currentCluster.PrivateRegistriesMap); err != nil {
if err := reconcileHost(ctx, toDeleteHost, false, false, currentCluster.SystemImages.Alpine, currentCluster.DockerDialerFactory, currentCluster.PrivateRegistriesMap, currentCluster.PrefixPath); err != nil {
log.Warnf(ctx, "[reconcile] Couldn't clean up controlplane node [%s]: %v", toDeleteHost.Address, err)
continue
}
@ -124,8 +124,8 @@ func reconcileControl(ctx context.Context, currentCluster, kubeCluster *Cluster,
return nil
}
func reconcileHost(ctx context.Context, toDeleteHost *hosts.Host, worker, etcd bool, cleanerImage string, dialerFactory hosts.DialerFactory, prsMap map[string]v3.PrivateRegistry) error {
if err := toDeleteHost.TunnelUp(ctx, dialerFactory); err != nil {
func reconcileHost(ctx context.Context, toDeleteHost *hosts.Host, worker, etcd bool, cleanerImage string, dialerFactory hosts.DialerFactory, prsMap map[string]v3.PrivateRegistry, clusterPrefixPath string) error {
if err := toDeleteHost.TunnelUp(ctx, dialerFactory, clusterPrefixPath); err != nil {
return fmt.Errorf("Not able to reach the host: %v", err)
}
if worker {
@ -170,7 +170,7 @@ func reconcileEtcd(ctx context.Context, currentCluster, kubeCluster *Cluster, ku
continue
}
// attempting to clean services/files on the host
if err := reconcileHost(ctx, etcdHost, false, true, currentCluster.SystemImages.Alpine, currentCluster.DockerDialerFactory, currentCluster.PrivateRegistriesMap); err != nil {
if err := reconcileHost(ctx, etcdHost, false, true, currentCluster.SystemImages.Alpine, currentCluster.DockerDialerFactory, currentCluster.PrivateRegistriesMap, currentCluster.PrefixPath); err != nil {
log.Warnf(ctx, "[reconcile] Couldn't clean up etcd node [%s]: %v", etcdHost.Address, err)
continue
}

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"path"
"strings"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
@ -47,6 +48,13 @@ const (
ToCleanCalicoRun = "/var/run/calico/"
ToCleanTempCertPath = "/etc/kubernetes/.tmp/"
CleanerContainerName = "kube-cleaner"
B2DOS = "Boot2Docker"
B2DPrefixPath = "/mnt/sda1/rke"
ROS = "RancherOS"
ROSPrefixPath = "/opt/rke"
CoreOS = "CoreOS"
CoreOSPrefixPath = "/opt/rke"
)
func (h *Host) CleanUpAll(ctx context.Context, cleanerImage string, prsMap map[string]v3.PrivateRegistry, externalEtcd bool) error {
@ -283,3 +291,20 @@ func GetUniqueHostList(etcdHosts, cpHosts, workerHosts []*Host) []*Host {
}
return uniqHostList
}
func GetPrefixPath(osType, ClusterPrefixPath string) string {
var prefixPath string
switch {
case ClusterPrefixPath != "/":
prefixPath = ClusterPrefixPath
case strings.Contains(osType, B2DOS):
prefixPath = B2DPrefixPath
case strings.Contains(osType, ROS):
prefixPath = ROSPrefixPath
case strings.Contains(osType, CoreOS):
prefixPath = CoreOSPrefixPath
default:
prefixPath = ClusterPrefixPath
}
return prefixPath
}

View File

@ -22,7 +22,7 @@ const (
K8sVersion = "1.8"
)
func (h *Host) TunnelUp(ctx context.Context, dialerFactory DialerFactory) error {
func (h *Host) TunnelUp(ctx context.Context, dialerFactory DialerFactory, clusterPrefixPath string) error {
if h.DClient != nil {
return nil
}
@ -37,7 +37,11 @@ func (h *Host) TunnelUp(ctx context.Context, dialerFactory DialerFactory) error
if err != nil {
return fmt.Errorf("Can't initiate NewClient: %v", err)
}
return checkDockerVersion(ctx, h)
if err := checkDockerVersion(ctx, h); err != nil {
return err
}
h.PrefixPath = GetPrefixPath(h.DockerInfo.OperatingSystem, clusterPrefixPath)
return nil
}
func (h *Host) TunnelUpLocal(ctx context.Context) error {