mirror of
https://github.com/rancher/rke.git
synced 2025-08-31 14:36:32 +00:00
init commit for refactor state
add init test use rkeconfig for init reconcile old state file
This commit is contained in:
committed by
Alena Prokharchyk
parent
631c0725f4
commit
f48da22d8e
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/rancher/rke/authz"
|
||||
"github.com/rancher/rke/cloudprovider"
|
||||
"github.com/rancher/rke/docker"
|
||||
@@ -31,6 +32,7 @@ type Cluster struct {
|
||||
v3.RancherKubernetesEngineConfig `yaml:",inline"`
|
||||
ConfigPath string
|
||||
LocalKubeConfigPath string
|
||||
StateFilePath string
|
||||
EtcdHosts []*hosts.Host
|
||||
WorkerHosts []*hosts.Host
|
||||
ControlPlaneHosts []*hosts.Host
|
||||
@@ -151,9 +153,12 @@ func ParseCluster(
|
||||
localConnDialerFactory hosts.DialerFactory,
|
||||
k8sWrapTransport k8s.WrapTransport) (*Cluster, error) {
|
||||
var err error
|
||||
// get state filepath
|
||||
stateFilePath := GetStateFilePath(clusterFilePath, configDir)
|
||||
c := &Cluster{
|
||||
RancherKubernetesEngineConfig: *rkeConfig,
|
||||
ConfigPath: clusterFilePath,
|
||||
StateFilePath: stateFilePath,
|
||||
DockerDialerFactory: dockerDialerFactory,
|
||||
LocalConnDialerFactory: localConnDialerFactory,
|
||||
PrivateRegistriesMap: make(map[string]v3.PrivateRegistry),
|
||||
@@ -506,3 +511,12 @@ func RestartClusterPods(ctx context.Context, kubeCluster *Cluster) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) GetHostInfoMap() map[string]types.Info {
|
||||
hostsInfoMap := make(map[string]types.Info)
|
||||
allHosts := hosts.GetUniqueHostList(c.EtcdHosts, c.ControlPlaneHosts, c.WorkerHosts)
|
||||
for _, host := range allHosts {
|
||||
hostsInfoMap[host.Address] = host.DockerInfo
|
||||
}
|
||||
return hostsInfoMap
|
||||
}
|
||||
|
Reference in New Issue
Block a user