Extract preloaded tarball as soon as minikube volume is created
Extracting preload currently takes 6 seconds. This PR begins preload extraction as soon as the minikube volume is created, and runs it in parallell with creating the container node and setting up SSH. This shaves 2-3 secnods off of `node.StartHost`pull/7490/head
parent
a57dc855bc
commit
b509d69182
|
@ -22,6 +22,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/drivers"
|
"github.com/docker/machine/libmachine/drivers"
|
||||||
|
@ -112,6 +113,28 @@ func (d *Driver) Create() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := oci.SetupContainerNode(params); err != nil {
|
||||||
|
return errors.Wrap(err, "setting up container node")
|
||||||
|
}
|
||||||
|
|
||||||
|
var waitForPreload sync.WaitGroup
|
||||||
|
waitForPreload.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer waitForPreload.Done()
|
||||||
|
// If preload doesn't exist, don't bother extracting tarball to volume
|
||||||
|
if !download.PreloadExists(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t := time.Now()
|
||||||
|
glog.Infof("Starting extracting preloaded images to volume")
|
||||||
|
// Extract preloaded images to container
|
||||||
|
if err := oci.ExtractTarballToVolume(download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, BaseImage); err != nil {
|
||||||
|
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
|
||||||
|
} else {
|
||||||
|
glog.Infof("Took %f seconds to extract preloaded images to volume", time.Since(t).Seconds())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if err := oci.CreateContainerNode(params); err != nil {
|
if err := oci.CreateContainerNode(params); err != nil {
|
||||||
return errors.Wrap(err, "create kic node")
|
return errors.Wrap(err, "create kic node")
|
||||||
}
|
}
|
||||||
|
@ -120,19 +143,7 @@ func (d *Driver) Create() error {
|
||||||
return errors.Wrap(err, "prepare kic ssh")
|
return errors.Wrap(err, "prepare kic ssh")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If preload doesn't exist, don't bother extracting tarball to volume
|
waitForPreload.Wait()
|
||||||
if !download.PreloadExists(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
t := time.Now()
|
|
||||||
glog.Infof("Starting extracting preloaded images to volume")
|
|
||||||
// Extract preloaded images to container
|
|
||||||
if err := oci.ExtractTarballToVolume(download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, BaseImage); err != nil {
|
|
||||||
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
|
|
||||||
} else {
|
|
||||||
glog.Infof("Took %f seconds to extract preloaded images to volume", time.Since(t).Seconds())
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,18 @@ func DeleteContainer(ociBin string, name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetupContainerNode sets up the container node
|
||||||
|
func SetupContainerNode(p CreateParams) error {
|
||||||
|
if p.OCIBinary != Docker {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err := createDockerVolume(p.Name, p.Name); err != nil {
|
||||||
|
return errors.Wrapf(err, "creating volume for %s container", p.Name)
|
||||||
|
}
|
||||||
|
glog.Infof("Successfully created a docker volume %s", p.Name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// CreateContainerNode creates a new container node
|
// CreateContainerNode creates a new container node
|
||||||
func CreateContainerNode(p CreateParams) error {
|
func CreateContainerNode(p CreateParams) error {
|
||||||
runArgs := []string{
|
runArgs := []string{
|
||||||
|
@ -122,10 +134,6 @@ func CreateContainerNode(p CreateParams) error {
|
||||||
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var:exec", hostVarVolPath))
|
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var:exec", hostVarVolPath))
|
||||||
}
|
}
|
||||||
if p.OCIBinary == Docker {
|
if p.OCIBinary == Docker {
|
||||||
if err := createDockerVolume(p.Name, p.Name); err != nil {
|
|
||||||
return errors.Wrapf(err, "creating volume for %s container", p.Name)
|
|
||||||
}
|
|
||||||
glog.Infof("Successfully created a docker volume %s", p.Name)
|
|
||||||
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var", p.Name))
|
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var", p.Name))
|
||||||
// setting resource limit in privileged mode is only supported by docker
|
// setting resource limit in privileged mode is only supported by docker
|
||||||
// podman error: "Error: invalid configuration, cannot set resources with rootless containers not using cgroups v2 unified mode"
|
// podman error: "Error: invalid configuration, cannot set resources with rootless containers not using cgroups v2 unified mode"
|
||||||
|
|
Loading…
Reference in New Issue