mirror of
https://github.com/rancher/rke.git
synced 2025-07-13 15:15:59 +00:00
Merge pull request #47 from galal-hussein/error_fix
Add error messages for adding/removing nodes while upgrade
This commit is contained in:
commit
e22f6e79de
@ -89,6 +89,14 @@ func (c *Cluster) SetUpHosts() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CheckEtcdHostsChanged(kubeCluster, currentCluster *Cluster) error {
|
||||||
|
etcdChanged := hosts.IsHostListChanged(currentCluster.EtcdHosts, kubeCluster.EtcdHosts)
|
||||||
|
if etcdChanged {
|
||||||
|
return fmt.Errorf("Adding or removing Etcd nodes is not supported")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func checkEncryptedKey(sshKeyPath string) (ssh.Signer, error) {
|
func checkEncryptedKey(sshKeyPath string) (ssh.Signer, error) {
|
||||||
logrus.Infof("[ssh] Checking private key")
|
logrus.Infof("[ssh] Checking private key")
|
||||||
key, err := hosts.ParsePrivateKey(privateKeyPath(sshKeyPath))
|
key, err := hosts.ParsePrivateKey(privateKeyPath(sshKeyPath))
|
||||||
|
@ -3,6 +3,7 @@ package cluster
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/rancher/rke/hosts"
|
||||||
"github.com/rancher/rke/k8s"
|
"github.com/rancher/rke/k8s"
|
||||||
"github.com/rancher/rke/services"
|
"github.com/rancher/rke/services"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -48,3 +49,19 @@ func checkK8sNodesState(localConfigPath string) error {
|
|||||||
logrus.Infof("[upgrade] All nodes are Ready")
|
logrus.Infof("[upgrade] All nodes are Ready")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CheckHostsChangedOnUpgrade(kubeCluster, currentCluster *Cluster) error {
|
||||||
|
etcdChanged := hosts.IsHostListChanged(currentCluster.EtcdHosts, kubeCluster.EtcdHosts)
|
||||||
|
if etcdChanged {
|
||||||
|
return fmt.Errorf("Adding or removing Etcd nodes while upgrade is not supported")
|
||||||
|
}
|
||||||
|
cpChanged := hosts.IsHostListChanged(currentCluster.ControlPlaneHosts, kubeCluster.ControlPlaneHosts)
|
||||||
|
if cpChanged {
|
||||||
|
return fmt.Errorf("Adding or removing Control plane nodes while upgrade is not supported")
|
||||||
|
}
|
||||||
|
workerChanged := hosts.IsHostListChanged(currentCluster.WorkerHosts, kubeCluster.WorkerHosts)
|
||||||
|
if workerChanged {
|
||||||
|
return fmt.Errorf("Adding or removing Worker plane nodes while upgrade is not supported")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -82,6 +82,10 @@ func ClusterUp(clusterFile string) (string, string, string, string, error) {
|
|||||||
return APIURL, caCrt, clientCert, clientKey, err
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := cluster.CheckEtcdHostsChanged(kubeCluster, currentCluster); err != nil {
|
||||||
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
|
}
|
||||||
|
|
||||||
err = cluster.SetUpAuthentication(kubeCluster, currentCluster)
|
err = cluster.SetUpAuthentication(kubeCluster, currentCluster)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return APIURL, caCrt, clientCert, clientKey, err
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
@ -148,6 +152,10 @@ func ClusterUpgrade(clusterFile string) (string, string, string, string, error)
|
|||||||
if currentCluster == nil {
|
if currentCluster == nil {
|
||||||
return APIURL, caCrt, clientCert, clientKey, fmt.Errorf("Failed to get the current state of Kubernetes cluster")
|
return APIURL, caCrt, clientCert, clientKey, fmt.Errorf("Failed to get the current state of Kubernetes cluster")
|
||||||
}
|
}
|
||||||
|
// check if user try to add/remove hosts during upgrade
|
||||||
|
if err := cluster.CheckHostsChangedOnUpgrade(kubeCluster, currentCluster); err != nil {
|
||||||
|
return APIURL, caCrt, clientCert, clientKey, err
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
kubeCluster is the cluster.yaml definition. It should have updated configuration
|
kubeCluster is the cluster.yaml definition. It should have updated configuration
|
||||||
currentCluster is the current state fetched from kubernetes
|
currentCluster is the current state fetched from kubernetes
|
||||||
|
Loading…
Reference in New Issue
Block a user