Skip to content

Commit

Permalink
Cache just one image at a time, when using podman
Browse files Browse the repository at this point in the history
To not run out of memory due to loading the images, since it
does not have a daemon to serialize things (like Docker does)
  • Loading branch information
afbjorklund committed Jan 25, 2019
1 parent 25ad2d3 commit 98a2a55
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"

"github.com/google/go-containerregistry/pkg/v1/tarball"

Expand All @@ -48,6 +49,8 @@ const tempLoadDir = "/tmp"

var getWindowsVolumeName = getWindowsVolumeNameCmd

var podmanLoad sync.Mutex

func CacheImagesForBootstrapper(version string, clusterBootstrapper string) error {
images := bootstrapper.GetCachedImageList(version, clusterBootstrapper)

Expand Down Expand Up @@ -213,16 +216,25 @@ func LoadFromCacheBlocking(cmd bootstrapper.CommandRunner, k8s config.Kubernetes
}

var dockerLoadCmd string
if k8s.ContainerRuntime == constants.CrioRuntime || k8s.ContainerRuntime == constants.Cri_oRuntime {
crio := k8s.ContainerRuntime == constants.CrioRuntime || k8s.ContainerRuntime == constants.Cri_oRuntime
if crio {
dockerLoadCmd = "sudo podman load -i " + dst
} else {
dockerLoadCmd = "docker load -i " + dst
}

if crio {
podmanLoad.Lock()
}

if err := cmd.Run(dockerLoadCmd); err != nil {
return errors.Wrapf(err, "loading docker image: %s", dst)
}

if crio {
podmanLoad.Unlock()
}

if err := cmd.Run("sudo rm -rf " + dst); err != nil {
return errors.Wrap(err, "deleting temp docker image location")
}
Expand Down

0 comments on commit 98a2a55

Please sign in to comment.