From d11cecff057c71e0ead4364146bf7154bf83e70b Mon Sep 17 00:00:00 2001 From: Anupama <38144301+anupama2501@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:36:35 -0800 Subject: [PATCH] Update rke state file --- clients/rkecli/state.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/clients/rkecli/state.go b/clients/rkecli/state.go index b6c1f15c..44ef4112 100644 --- a/clients/rkecli/state.go +++ b/clients/rkecli/state.go @@ -12,7 +12,6 @@ import ( "github.com/rancher/shepherd/clients/rancher" v3 "github.com/rancher/shepherd/clients/rancher/generated/management/v3" v1 "github.com/rancher/shepherd/clients/rancher/v1" - "github.com/rancher/shepherd/extensions/configmaps" "github.com/rancher/shepherd/pkg/config" "github.com/rancher/shepherd/pkg/file" "gopkg.in/yaml.v2" @@ -129,7 +128,7 @@ func NewClusterFile(state *cluster.FullState, dirName string, config *Config) (c rkeConfig.Nodes[i].SSHKeyPath = appendSSHPath(rkeConfig.Nodes[i].SSHKeyPath, config.SSHPath) } } else { - return "", errors.Wrap(err, "rke SSHPath or SSHKey not configured") + return "", errors.New("missing SSH configuration") } marshaled, err := yaml.Marshal(rkeConfig) @@ -166,28 +165,27 @@ func NewStateFile(state *cluster.FullState, dirName string) (stateFilePath strin return } -// GetFullState is a function that gets RKE full state from "full-cluster-state" configmap. +// GetFullState is a function that gets RKE full state from "full-cluster-state" secret. // And returns the cluster full state. func GetFullState(client *rancher.Client) (state *cluster.FullState, err error) { - namespacedConfigmapClient := client.Steve.SteveType(configmaps.ConfigMapSteveType).NamespacedSteveClient(cluster.SystemNamespace) - if err != nil { - return - } + namespacedSecretClient := client.Steve.SteveType("secret").NamespacedSteveClient(cluster.SystemNamespace) + + fullstateSecretID := fmt.Sprintf(cluster.SystemNamespace+"/%s", cluster.FullStateSecretName) - configmapResp, err := namespacedConfigmapClient.ByID(cluster.FullStateConfigMapName) + secretResp, err := namespacedSecretClient.ByID(fullstateSecretID) if err != nil { return } - configmap := &corev1.ConfigMap{} - err = v1.ConvertToK8sType(configmapResp.JSONResp, configmap) + secret := &corev1.Secret{} + err = v1.ConvertToK8sType(secretResp.JSONResp, secret) if err != nil { return } - rawState, ok := configmap.Data[cluster.FullStateConfigMapName] + rawState, ok := secret.Data[cluster.FullStateSecretName] if !ok { - err = errors.Wrapf(err, "couldn't retrieve full state data in the configmap") + err = errors.Wrapf(err, "couldn't retrieve full state data in the secret") return }