mirror of https://github.com/k3s-io/k3s
kubeadm-reset: fetch init config only if client is non-nil
parent
37f0138278
commit
269a07c077
|
@ -63,18 +63,17 @@ func NewCmdReset(in io.Reader, out io.Writer) *cobra.Command {
|
||||||
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(ignorePreflightErrors)
|
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(ignorePreflightErrors)
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
if _, err := os.Stat(kubeConfigFile); !os.IsNotExist(err) {
|
var cfg *kubeadmapi.InitConfiguration
|
||||||
client, err = getClientset(kubeConfigFile, false)
|
client, err = getClientset(kubeConfigFile, false)
|
||||||
kubeadmutil.CheckErr(err)
|
if err == nil {
|
||||||
klog.V(1).Infof("[reset] loaded client set from kubeconfig file: %s", kubeConfigFile)
|
klog.V(1).Infof("[reset] loaded client set from kubeconfig file: %s", kubeConfigFile)
|
||||||
} else {
|
cfg, err = configutil.FetchInitConfigurationFromCluster(client, os.Stdout, "reset", false)
|
||||||
klog.V(1).Infof("[reset] could not get client set from missing kubeconfig file: %s", kubeConfigFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg, err := configutil.FetchInitConfigurationFromCluster(client, os.Stdout, "reset", false)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Warningf("[reset] Unable to fetch the kubeadm-config ConfigMap from cluster: %v", err)
|
klog.Warningf("[reset] Unable to fetch the kubeadm-config ConfigMap from cluster: %v", err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
klog.V(1).Infof("[reset] could not get client set from missing kubeconfig file: %s", kubeConfigFile)
|
||||||
|
}
|
||||||
|
|
||||||
if criSocketPath == "" {
|
if criSocketPath == "" {
|
||||||
criSocketPath, err = resetDetectCRISocket(cfg)
|
criSocketPath, err = resetDetectCRISocket(cfg)
|
||||||
|
|
Loading…
Reference in New Issue