Skip to content

Commit

Permalink
Merge pull request #9476 from sharifelgamal/restart-worker
Browse files Browse the repository at this point in the history
make sure worker nodes actually join control plane on restart
  • Loading branch information
sharifelgamal authored Oct 16, 2020
2 parents f758fb0 + 14003b0 commit a282354
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
9 changes: 4 additions & 5 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,18 +673,17 @@ func (k *Bootstrapper) JoinCluster(cc config.ClusterConfig, n config.Node, joinC
klog.Infof("kubeadm reset failed, continuing anyway: %v", err)
}

out, err := k.c.RunCmd(exec.Command("/bin/bash", "-c", joinCmd))
_, err = k.c.RunCmd(exec.Command("/bin/bash", "-c", joinCmd))
if err != nil {
if strings.Contains(err.Error(), "status \"Ready\" already exists in the cluster") {
klog.Infof("Node %s already joined the cluster, skip failure.", n.Name)
} else {
return errors.Wrapf(err, "cmd failed: %s\n%+v\n", joinCmd, out.Output())
klog.Info("still waiting for the worker node to register with the api server")
}
return errors.Wrapf(err, "kubeadm join")
}
return nil
}

if err := retry.Expo(join, 10*time.Second, 1*time.Minute); err != nil {
if err := retry.Expo(join, 10*time.Second, 3*time.Minute); err != nil {
return errors.Wrap(err, "joining cp")
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
return nil, errors.Wrap(err, "setting up certs")
}

if err := bs.UpdateNode(*starter.Cfg, *starter.Node, cr); err != nil {
return nil, errors.Wrap(err, "update node")
}
}

var wg sync.WaitGroup
Expand Down Expand Up @@ -167,10 +170,6 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) {
prepareNone()
}
} else {
if err := bs.UpdateNode(*starter.Cfg, *starter.Node, cr); err != nil {
return nil, errors.Wrap(err, "update node")
}

// Make sure to use the command runner for the control plane to generate the join token
cpBs, cpr, err := cluster.ControlPlaneBootstrapper(starter.MachineAPI, starter.Cfg, viper.GetString(cmdcfg.Bootstrapper))
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions test/integration/multinode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"os/exec"
"strings"
"testing"
"time"
)

func TestMultiNode(t *testing.T) {
Expand Down Expand Up @@ -228,8 +227,6 @@ func validateRestartMultiNodeCluster(ctx context.Context, t *testing.T, profile
t.Fatalf("failed to start cluster. args %q : %v", rr.Command(), err)
}

time.Sleep(Seconds(45))

// Make sure minikube status shows 2 running nodes
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "status", "--alsologtostderr"))
if err != nil {
Expand Down

0 comments on commit a282354

Please sign in to comment.