From 0e221450f927f83ab5ca3346a714e2641a425ecc Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Wed, 15 Apr 2020 17:00:08 -0700 Subject: [PATCH] generate join token on control plane --- pkg/minikube/node/start.go | 6 ++++-- test/integration/functional_test.go | 33 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 689adef274..d03e073179 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -156,9 +156,11 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { return nil, errors.Wrap(err, "Updating node") } - cpBs, err := cluster.Bootstrapper(starter.MachineAPI, viper.GetString(cmdcfg.Bootstrapper), *starter.Cfg, starter.Runner) + // Make sure to use the command runner for the control plane to generate the join token + c := mustload.Running(starter.Cfg.Name) + cpBs, err := cluster.Bootstrapper(starter.MachineAPI, viper.GetString(cmdcfg.Bootstrapper), *starter.Cfg, c.CP.Runner) if err != nil { - return nil, errors.Wrap(err, "Getting bootstrapper") + return nil, errors.Wrap(err, "getting control plane bootstrapper") } joinCmd, err := cpBs.GenerateToken(*starter.Cfg) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 5f1ef0124b..f281fff5da 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -132,6 +132,7 @@ func TestFunctional(t *testing.T) { {"UpdateContextCmd", validateUpdateContextCmd}, {"DockerEnv", validateDockerEnv}, {"NodeLabels", validateNodeLabels}, + {"MultiNode", validateMultiNode}, } for _, tc := range tests { tc := tc @@ -187,6 +188,38 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { } +func validateMultiNode(ctx context.Context, t *testing.T, profile string) { + if NoneDriver() { + t.Skip("none driver does not support multinode") + } + + // TODO: remove this skip once docker multinode is fixed + if KicDriver() { + t.Skip("docker driver multinode is currently broken :(") + } + + // Add a node to the current cluster + addArgs := []string{"node", "add", "-p", profile} + rr, err := Run(t, exec.CommandContext(ctx, Target(), addArgs...)) + if err != nil { + t.Errorf("failed to add node to current cluster. args %q : %v", rr.Command(), err) + } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "status")) + if err != nil { + t.Errorf("failed to run minikube status. args %q : %v", rr.Command(), err) + } + + if strings.Count(rr.Stdout.String(), "host: Running") != 2 { + t.Errorf("status says both hosts are not running: args %q: %v", rr.Command(), rr.Stdout.String()) + } + + if strings.Count(rr.Stdout.String(), "kubelet: Running") != 2 { + t.Errorf("status says both kubelets are not running: args %q: %v", rr.Command(), rr.Stdout.String()) + } + +} + func validateStartWithProxy(ctx context.Context, t *testing.T, profile string) { srv, err := startHTTPProxy(t) if err != nil {