Skip to content

Commit

Permalink
Merge pull request #4197 from dpandhi-git/master
Browse files Browse the repository at this point in the history
Make default output of 'minikube start' consume fewer lines in the terminal
  • Loading branch information
tstromberg authored May 7, 2019
2 parents 2ddd4c5 + c98ba69 commit 756cd0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
28 changes: 10 additions & 18 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func runStart(cmd *cobra.Command, args []string) {
exit.WithError("Failed to get command runner", err)
}

cr := configureRuntimes(host, runner)
cr := configureRuntimes(host, runner, k8sVersion)

// prepareHostEnvironment uses the downloaded images, so we need to wait for background task completion.
waitCacheImages(&cacheGroup)
Expand All @@ -251,14 +251,14 @@ func runStart(cmd *cobra.Command, args []string) {
}

showKubectlConnectInfo(kubeconfig)
console.OutStyle("ready", "Done! Thank you for using minikube!")

}

func showKubectlConnectInfo(kubeconfig *pkgutil.KubeConfigSetup) {
if kubeconfig.KeepContext {
console.OutStyle("kubectl", "To connect to this cluster, use: kubectl --context=%s", kubeconfig.ClusterName)
} else {
console.OutStyle("kubectl", "kubectl is now configured to use %q", cfg.GetMachineName())
console.OutStyle("ready", "Done! kubectl is now configured to use %q", cfg.GetMachineName())
}
_, err := exec.LookPath("kubectl")
if err != nil {
Expand Down Expand Up @@ -291,7 +291,7 @@ func beginCacheImages(g *errgroup.Group, k8sVersion string) {
if !viper.GetBool(cacheImages) {
return
}
console.OutStyle("caching", "Downloading Kubernetes %s images in the background ...", k8sVersion)

g.Go(func() error {
return machine.CacheImagesForBootstrapper(viper.GetString(imageRepository), k8sVersion, viper.GetString(cmdcfg.Bootstrapper))
})
Expand All @@ -302,7 +302,6 @@ func waitCacheImages(g *errgroup.Group) {
if !viper.GetBool(cacheImages) {
return
}
console.OutStyle("waiting", "Waiting for image downloads to complete ...")
if err := g.Wait(); err != nil {
glog.Errorln("Error caching images: ", err)
}
Expand Down Expand Up @@ -441,7 +440,6 @@ func validateNetwork(h *host.Host) string {
if err != nil {
exit.WithError("Unable to get VM IP address", err)
}
console.OutStyle("connectivity", "%q IP address is %s", cfg.GetMachineName(), ip)

optSeen := false
for _, k := range proxyVars {
Expand Down Expand Up @@ -497,7 +495,6 @@ func prepareHostEnvironment(api libmachine.API, kc cfg.KubernetesConfig) bootstr
if err != nil {
exit.WithError("Failed to get bootstrapper", err)
}
console.OutStyle("copying", "Preparing Kubernetes environment ...")
for _, eo := range extraOptions {
console.OutStyle("option", "%s.%s=%s", eo.Component, eo.Key, eo.Value)
}
Expand Down Expand Up @@ -540,13 +537,14 @@ func updateKubeConfig(h *host.Host, c *cfg.Config) *pkgutil.KubeConfigSetup {
}

// configureRuntimes does what needs to happen to get a runtime going.
func configureRuntimes(h *host.Host, runner bootstrapper.CommandRunner) cruntime.Manager {
func configureRuntimes(h *host.Host, runner bootstrapper.CommandRunner, k8sVersion string) cruntime.Manager {
config := cruntime.Config{Type: viper.GetString(containerRuntime), Runner: runner}
cr, err := cruntime.New(config)
if err != nil {
exit.WithError(fmt.Sprintf("Failed runtime for %+v", config), err)
}
console.OutStyle(cr.Name(), "Configuring %s as the container runtime ...", cr.Name())
version, _ := cr.Version()
console.OutStyle(cr.Name(), "Configuring environment for Kubernetes %s on %s %s", k8sVersion, cr.Name(), version)
for _, v := range dockerOpt {
console.OutStyle("option", "opt %s", v)
}
Expand All @@ -558,10 +556,7 @@ func configureRuntimes(h *host.Host, runner bootstrapper.CommandRunner) cruntime
if err != nil {
exit.WithError("Failed to enable container runtime", err)
}
version, err := cr.Version()
if err == nil {
console.OutStyle(cr.Name(), "Version of container runtime is %s", version)
}

return cr
}

Expand All @@ -571,7 +566,7 @@ func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner b
bsName := viper.GetString(cmdcfg.Bootstrapper)

if isUpgrade || !preexisting {
console.OutStyle("pulling", "Pulling images required by Kubernetes %s ...", kc.KubernetesVersion)
console.OutStyle("pulling", "Pulling images ...")
if err := bs.PullImages(kc); err != nil {
console.OutStyle("failure", "Unable to pull images, which may be OK: %v", err)
}
Expand All @@ -585,18 +580,16 @@ func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner b
return
}

console.OutStyle("launch", "Launching Kubernetes %s using %s ... ", kc.KubernetesVersion, bsName)
console.OutStyle("launch", "Launching Kubernetes ... ")
if err := bs.StartCluster(kc); err != nil {
exit.WithLogEntries("Error starting cluster", err, logs.FindProblems(r, bs, runner))
}
}

// validateCluster validates that the cluster is well-configured and healthy
func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bootstrapper.CommandRunner, ip string, apiserverPort int) {
console.OutStyle("verifying-noline", "Verifying component health ...")
k8sStat := func() (err error) {
st, err := bs.GetKubeletStatus()
console.Out(".")
if err != nil || st != state.Running.String() {
return &pkgutil.RetriableError{Err: fmt.Errorf("kubelet unhealthy: %v: %s", err, st)}
}
Expand All @@ -608,7 +601,6 @@ func validateCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bo
}
aStat := func() (err error) {
st, err := bs.GetAPIServerStatus(net.ParseIP(ip), apiserverPort)
console.Out(".")
if err != nil || st != state.Running.String() {
return &pkgutil.RetriableError{Err: fmt.Errorf("apiserver status=%s err=%v", st, err)}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
return errors.Wrap(err, "wait")
}

console.OutStyle("permissions", "Configuring cluster permissions ...")
glog.Infof("Configuring cluster permissions ...")
if err := util.RetryAfter(100, elevateKubeSystemPrivileges, time.Millisecond*500); err != nil {
return errors.Wrap(err, "timed out waiting to elevate kube-system RBAC privileges")
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func waitForPods(k8s config.KubernetesConfig, quiet bool) error {
componentsOnly := k8s.NetworkPlugin == "cni"

if !quiet {
console.OutStyle("waiting-pods", "Waiting for pods:")
console.OutStyle("waiting-pods", "Waiting for:")
}
client, err := util.GetClient()
if err != nil {
Expand Down

0 comments on commit 756cd0f

Please sign in to comment.