提交 35aec77f 编写于 作者: S Sharif Elgamal

code comments

上级 4c00ae01
...@@ -17,8 +17,6 @@ limitations under the License. ...@@ -17,8 +17,6 @@ limitations under the License.
package cmd package cmd
import ( import (
"fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/spf13/viper" "github.com/spf13/viper"
...@@ -48,7 +46,7 @@ var nodeAddCmd = &cobra.Command{ ...@@ -48,7 +46,7 @@ var nodeAddCmd = &cobra.Command{
out.ErrT(out.FailureType, "none driver does not support multi-node clusters") out.ErrT(out.FailureType, "none driver does not support multi-node clusters")
} }
name := fmt.Sprintf("m%02d", len(cc.Nodes)+1) name := node.Name(len(cc.Nodes) + 1)
out.T(out.Happy, "Adding node {{.name}} to cluster {{.cluster}}", out.V{"name": name, "cluster": profile}) out.T(out.Happy, "Adding node {{.name}} to cluster {{.cluster}}", out.V{"name": name, "cluster": profile})
......
...@@ -60,8 +60,7 @@ var sshCmd = &cobra.Command{ ...@@ -60,8 +60,7 @@ var sshCmd = &cobra.Command{
} else { } else {
n, _, err = node.Retrieve(cc, nodeName) n, _, err = node.Retrieve(cc, nodeName)
if err != nil { if err != nil {
out.FailureT("Node {{.nodeName}} does not exist.", out.V{"nodeName": nodeName}) exit.WithCodeT(exit.Unavailable, "Node {{.nodeName}} does not exist.", out.V{"nodeName": nodeName})
exit.WithError("", err)
} }
} }
host, err := machine.LoadHost(api, driver.MachineName(*cc, *n)) host, err := machine.LoadHost(api, driver.MachineName(*cc, *n))
......
...@@ -356,10 +356,10 @@ func runStart(cmd *cobra.Command, args []string) { ...@@ -356,10 +356,10 @@ func runStart(cmd *cobra.Command, args []string) {
} }
if numNodes > 1 { if numNodes > 1 {
if driver.BareMetal(driverName) { if driver.BareMetal(driverName) {
out.T(out.Meh, "The none driver is not compatible with multi-node clusters.") exit.WithCodeT(exit.Config, "The none driver is not compatible with multi-node clusters.")
} else { } else {
for i := 1; i < numNodes; i++ { for i := 1; i < numNodes; i++ {
nodeName := fmt.Sprintf("m%02d", i+1) nodeName := node.Name(i + 1)
n := config.Node{ n := config.Node{
Name: nodeName, Name: nodeName,
Worker: true, Worker: true,
......
...@@ -419,13 +419,8 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) { ...@@ -419,13 +419,8 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
return "", errors.Wrap(err, "generating bootstrap token") return "", errors.Wrap(err, "generating bootstrap token")
} }
/*cp, err := config.PrimaryControlPlane(&cc)
if err != nil {
return "", errors.Wrap(err, "getting primary control plane")
}*/
joinCmd := r.Stdout.String() joinCmd := r.Stdout.String()
joinCmd = strings.Replace(joinCmd, "kubeadm", bsutil.InvokeKubeadm(cc.KubernetesConfig.KubernetesVersion), 1) joinCmd = strings.Replace(joinCmd, "kubeadm", bsutil.InvokeKubeadm(cc.KubernetesConfig.KubernetesVersion), 1)
//joinCmd = strings.ReplaceAll(joinCmd, "localhost", cp.IP)
joinCmd = fmt.Sprintf("%s --ignore-preflight-errors=all", strings.TrimSpace(joinCmd)) joinCmd = fmt.Sprintf("%s --ignore-preflight-errors=all", strings.TrimSpace(joinCmd))
return joinCmd, nil return joinCmd, nil
......
...@@ -18,6 +18,7 @@ package node ...@@ -18,6 +18,7 @@ package node
import ( import (
"errors" "errors"
"fmt"
"github.com/spf13/viper" "github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/config"
...@@ -91,3 +92,8 @@ func Save(cfg *config.ClusterConfig, node *config.Node) error { ...@@ -91,3 +92,8 @@ func Save(cfg *config.ClusterConfig, node *config.Node) error {
} }
return config.SaveProfile(viper.GetString(config.ProfileName), cfg) return config.SaveProfile(viper.GetString(config.ProfileName), cfg)
} }
// Name returns the appropriate name for the node given the current number of nodes
func Name(index int) string {
return fmt.Sprintf("m%02d", index)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册