Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: docker/podman: make soft start 20 seconds faster #7435

Closed
wants to merge 13 commits into from
6 changes: 3 additions & 3 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,15 @@ func (k *Bootstrapper) needsReset(conf string, hostname string, port int, client
}

if err := kverify.ExpectAppsRunning(client, kverify.AppsRunningList); err != nil {
glog.Infof("needs reset: %v", err)
glog.Infof("needs reset because expected components to be running : %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems too difficult to read. Is the error retutrned by ExpectAppsRunning not meaningful already?

If not, just use: needs reset: expected apps: %v.

return true
}

if err := kverify.APIServerVersionMatch(client, version); err != nil {
glog.Infof("needs reset: %v", err)
glog.Infof("needs reset because API server version match : %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be reverted. The error made sense already. If not:

needs reset: api version: %v

return true
}

glog.Infof("the cluster does not need a reset. hostname: %s", hostname)
return false
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
if driver.BareMetal(cc.Driver) {
disableOthers = false
}
if driver.IsKIC(cc.Driver) && cc.KubernetesConfig.ContainerRuntime == "docker" {
// in kic driver, the docker service binds to containerd service https://github.com/kubernetes/minikube/issues/7433
disableOthers = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what about crio?

I think this fix should be done in cruntime.

}

// Preload is overly invasive for bare metal, and caching is not meaningful. KIC handled elsewhere.
if driver.IsVM(cc.Driver) {
Expand Down
7 changes: 4 additions & 3 deletions pkg/provision/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@ func updateUnit(p provision.SSHCommander, name string, content string, dst strin
glog.Infof("Updating %s unit: %s ...", name, dst)

if _, err := p.SSHCommand(fmt.Sprintf("sudo mkdir -p %s && printf %%s \"%s\" | sudo tee %s.new", path.Dir(dst), content, dst)); err != nil {
return err
return errors.Wrapf(err, "generating %q system unit", name)
}
if _, err := p.SSHCommand(fmt.Sprintf("sudo diff -u %s %s.new || { sudo mv %s.new %s; sudo systemctl -f daemon-reload && sudo sudo systemctl -f restart %s; }", dst, dst, dst, dst, name)); err != nil {
return err
cmd := fmt.Sprintf("sudo diff -u %s %s.new || { sudo mv %s.new %s; sudo systemctl -f daemon-reload && sudo sudo systemctl -f restart %s; }", dst, dst, dst, dst, name)
if _, err := p.SSHCommand(cmd); err != nil {
return errors.Wrapf(err, "running %q", cmd)
tstromberg marked this conversation as resolved.
Show resolved Hide resolved
}
return nil
}
72 changes: 72 additions & 0 deletions test/integration/preload_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// +build integration

/*
Copyright 2020 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package integration

import (
"context"
"fmt"
"os/exec"
"strings"
"testing"
)

// TestPreload tests that images are not over-written by preload
func TestPreload(t *testing.T) {
if NoneDriver() {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
}

profile := UniqueProfileName("test-preload")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(40))
defer CleanupWithLogs(t, profile, cancel)

startArgs := []string{"start", "-p", profile, "--memory=2200", "--alsologtostderr", "-v=3", "--wait=true", "--preload=false"}
startArgs = append(startArgs, StartArgs()...)
k8sVersion := "v1.17.0"
startArgs = append(startArgs, fmt.Sprintf("--kubernetes-version=%s", k8sVersion))

rr, err := Run(t, exec.CommandContext(ctx, Target(), startArgs...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}

// Now, pull the busybox image into the VMs docker daemon
image := "busybox"
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "--", "docker", "pull", image))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}

// Restart minikube with v1.17.3, which has a preloaded tarball
startArgs = []string{"start", "-p", profile, "--memory=2200", "--alsologtostderr", "-v=3", "--wait=true"}
startArgs = append(startArgs, StartArgs()...)
k8sVersion = "v1.17.3"
startArgs = append(startArgs, fmt.Sprintf("--kubernetes-version=%s", k8sVersion))
rr, err = Run(t, exec.CommandContext(ctx, Target(), startArgs...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "--", "docker", "images"))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), image) {
t.Fatalf("Expected to find %s in output of `docker images`, instead got %s", image, rr.Output())
}
}
63 changes: 18 additions & 45 deletions test/integration/start_stop_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,30 @@ func TestStartStop(t *testing.T) {
t.Fatalf("failed starting minikube -first start-. args %q: %v", rr.Command(), err)
}

// Soft Start this should not take longer than 10 seconds
softStartArgs := []string{"start", "-p", profile, "--alsologtostderr", "-v=3"}
rr, err = Run(t, exec.CommandContext(ctx, Target(), softStartArgs...))
if err != nil {
t.Fatalf("failed to soft start minikube. args %q: %v", rr.Command(), err)
}

// none driver does not invoke needs reset
// CNI ones will invoke a reset because the expected component coredns would not be running.
if !NoneDriver() && !strings.Contains(tc.name, "cni") {
// if this fails means, our soft start was a hard start.
softLog := "cluster does not need a reset"
if !strings.Contains(rr.Output(), softLog) {
t.Errorf("expected the soft start log outputs to include %q but got: %s", softLog, rr.Output())
}
}

if !strings.Contains(tc.name, "cni") {
testPodScheduling(ctx, t, profile)
}

rr, err = Run(t, exec.CommandContext(ctx, Target(), "stop", "-p", profile, "--alsologtostderr", "-v=3"))
if err != nil {
t.Errorf("failed stopping minikube - first stop-. args %q : %v", rr.Command(), err)
t.Errorf("failed stopping minikube - post soft start -. args %q : %v", rr.Command(), err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text does not make sense to me. How about:

failed to stop minikube after initial soft start

}

// The none driver never really stops
Expand Down Expand Up @@ -174,50 +191,6 @@ func TestStartStop(t *testing.T) {
})
}

func TestStartStopWithPreload(t *testing.T) {
if NoneDriver() {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
}

profile := UniqueProfileName("test-preload")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(40))
defer CleanupWithLogs(t, profile, cancel)

startArgs := []string{"start", "-p", profile, "--memory=2200", "--alsologtostderr", "-v=3", "--wait=true", "--preload=false"}
startArgs = append(startArgs, StartArgs()...)
k8sVersion := "v1.17.0"
startArgs = append(startArgs, fmt.Sprintf("--kubernetes-version=%s", k8sVersion))

rr, err := Run(t, exec.CommandContext(ctx, Target(), startArgs...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}

// Now, pull the busybox image into the VMs docker daemon
image := "busybox"
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "--", "docker", "pull", image))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}

// Restart minikube with v1.17.3, which has a preloaded tarball
startArgs = []string{"start", "-p", profile, "--memory=2200", "--alsologtostderr", "-v=3", "--wait=true"}
startArgs = append(startArgs, StartArgs()...)
k8sVersion = "v1.17.3"
startArgs = append(startArgs, fmt.Sprintf("--kubernetes-version=%s", k8sVersion))
rr, err = Run(t, exec.CommandContext(ctx, Target(), startArgs...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "--", "docker", "images"))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), image) {
t.Fatalf("Expected to find %s in output of `docker images`, instead got %s", image, rr.Output())
}
}

// testPodScheduling asserts that this configuration can schedule new pods
func testPodScheduling(ctx context.Context, t *testing.T, profile string) {
t.Helper()
Expand Down