Skip to content

Commit 5ed8a7e

Browse files
mlgibbonsdlorenc
authored andcommitted
Made caching async with block for completion before copy of images into cluster. Default imageing caching to false
1 parent e9b95df commit 5ed8a7e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cmd/minikube/cmd/start.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/golang/glog"
3434
"github.com/spf13/cobra"
3535
"github.com/spf13/viper"
36+
"golang.org/x/sync/errgroup"
3637
cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config"
3738
cmdutil "k8s.io/minikube/cmd/util"
3839
"k8s.io/minikube/pkg/minikube/bootstrapper"
@@ -100,9 +101,13 @@ func runStart(cmd *cobra.Command, args []string) {
100101
k8sVersion := viper.GetString(kubernetesVersion)
101102
clusterBootstrapper := viper.GetString(cmdcfg.Bootstrapper)
102103

104+
var groupCacheImages errgroup.Group
103105
if shouldCacheImages {
104-
machine.CacheImagesForBootstrapper(k8sVersion, clusterBootstrapper)
106+
groupCacheImages.Go(func() error {
107+
return machine.CacheImagesForBootstrapper(k8sVersion, clusterBootstrapper)
108+
})
105109
}
110+
106111
api, err := machine.NewAPIClient()
107112
if err != nil {
108113
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
@@ -229,7 +234,15 @@ func runStart(cmd *cobra.Command, args []string) {
229234
glog.Errorln("Error saving profile cluster configuration: ", err)
230235
}
231236

237+
if shouldCacheImages {
238+
fmt.Println("Waiting for image caching to complete...")
239+
if err := groupCacheImages.Wait(); err != nil {
240+
glog.Errorln("Error caching images: ", err)
241+
}
242+
}
243+
232244
fmt.Println("Moving files into cluster...")
245+
233246
if err := k8sBootstrapper.UpdateCluster(kubernetesConfig); err != nil {
234247
glog.Errorln("Error updating cluster: ", err)
235248
cmdutil.MaybeReportErrorAndExit(err)
@@ -394,7 +407,7 @@ func init() {
394407
startCmd.Flags().String(containerRuntime, "", "The container runtime to be used")
395408
startCmd.Flags().String(networkPlugin, "", "The name of the network plugin")
396409
startCmd.Flags().String(featureGates, "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
397-
startCmd.Flags().Bool(cacheImages, true, "If true, cache docker images for the current bootstrapper and load them into the machine.")
410+
startCmd.Flags().Bool(cacheImages, false, "If true, cache docker images for the current bootstrapper and load them into the machine.")
398411
startCmd.Flags().Var(&extraOptions, "extra-config",
399412
`A set of key=value pairs that describe configuration that may be passed to different components.
400413
The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.

0 commit comments

Comments
 (0)