From f36020741696d687576b8d42bb1efa07f08c6184 Mon Sep 17 00:00:00 2001 From: kinarashah Date: Mon, 8 Jul 2019 15:21:03 -0700 Subject: [PATCH] move metadata init to InitClusterObject --- cluster/cluster.go | 4 ++++ cmd/common.go | 7 ++----- cmd/remove.go | 4 ---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cluster/cluster.go b/cluster/cluster.go index 62156001..e4daf24b 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/rancher/rke/metadata" "net" "reflect" "strings" @@ -160,6 +161,9 @@ func InitClusterObject(ctx context.Context, rkeConfig *v3.RancherKubernetesEngin StateFilePath: GetStateFilePath(flags.ClusterFilePath, flags.ConfigDir), PrivateRegistriesMap: make(map[string]v3.PrivateRegistry), } + if metadata.K8sVersionToRKESystemImages == nil { + metadata.InitMetadata(ctx) + } if len(c.ConfigPath) == 0 { c.ConfigPath = pki.ClusterConfig } diff --git a/cmd/common.go b/cmd/common.go index 55d90d9a..0ad74a4b 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -3,7 +3,6 @@ package cmd import ( "context" "fmt" - "github.com/rancher/rke/metadata" "io/ioutil" "os" "path/filepath" @@ -14,7 +13,7 @@ import ( "github.com/rancher/rke/log" "github.com/rancher/rke/pki" "github.com/rancher/rke/util" - v3 "github.com/rancher/types/apis/management.cattle.io/v3" + "github.com/rancher/types/apis/management.cattle.io/v3" "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -75,9 +74,7 @@ func ClusterInit(ctx context.Context, rkeConfig *v3.RancherKubernetesEngineConfi if len(flags.CertificateDir) == 0 { flags.CertificateDir = cluster.GetCertificateDirPath(flags.ClusterFilePath, flags.ConfigDir) } - if metadata.K8sVersionToRKESystemImages == nil { - metadata.InitMetadata(ctx) - } + rkeFullState, _ := cluster.ReadStateFile(ctx, stateFilePath) kubeCluster, err := cluster.InitClusterObject(ctx, rkeConfig, flags) diff --git a/cmd/remove.go b/cmd/remove.go index bc5e2099..e08166eb 100644 --- a/cmd/remove.go +++ b/cmd/remove.go @@ -4,7 +4,6 @@ import ( "bufio" "context" "fmt" - "github.com/rancher/rke/metadata" "os" "strings" @@ -58,9 +57,6 @@ func ClusterRemove( log.Infof(ctx, "Tearing down Kubernetes cluster") - if metadata.K8sVersionToRKESystemImages == nil { - metadata.InitMetadata(ctx) - } kubeCluster, err := cluster.InitClusterObject(ctx, rkeConfig, flags) if err != nil { return err