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

code comments

上级 4c00ae01
......@@ -17,8 +17,6 @@ limitations under the License.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
......@@ -48,7 +46,7 @@ var nodeAddCmd = &cobra.Command{
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})
......
......@@ -60,8 +60,7 @@ var sshCmd = &cobra.Command{
} else {
n, _, err = node.Retrieve(cc, nodeName)
if err != nil {
out.FailureT("Node {{.nodeName}} does not exist.", out.V{"nodeName": nodeName})
exit.WithError("", err)
exit.WithCodeT(exit.Unavailable, "Node {{.nodeName}} does not exist.", out.V{"nodeName": nodeName})
}
}
host, err := machine.LoadHost(api, driver.MachineName(*cc, *n))
......
......@@ -356,10 +356,10 @@ func runStart(cmd *cobra.Command, args []string) {
}
if numNodes > 1 {
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 {
for i := 1; i < numNodes; i++ {
nodeName := fmt.Sprintf("m%02d", i+1)
nodeName := node.Name(i + 1)
n := config.Node{
Name: nodeName,
Worker: true,
......
......@@ -419,13 +419,8 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
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 = 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))
return joinCmd, nil
......
......@@ -18,6 +18,7 @@ package node
import (
"errors"
"fmt"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config"
......@@ -91,3 +92,8 @@ func Save(cfg *config.ClusterConfig, node *config.Node) error {
}
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.
先完成此消息的编辑!
想要评论请 注册