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

Restarting minikube takes longer than initial start #17509

Closed
spowelljr opened this issue Oct 26, 2023 · 7 comments · Fixed by #17909
Closed

Restarting minikube takes longer than initial start #17509

spowelljr opened this issue Oct 26, 2023 · 7 comments · Fixed by #17909
Labels
kind/improvement Categorizes issue or PR as related to improving upon a current feature. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@spowelljr
Copy link
Member

Initial start: 0m15.890s
Restart: 0m20.424s

I think it's related to kubeadm commands as we run different commands on initial start vs restart

There are likely improvements we can make to bring the restart down to the initial start time or even less

@spowelljr spowelljr added the kind/improvement Categorizes issue or PR as related to improving upon a current feature. label Oct 26, 2023
@spowelljr
Copy link
Member Author

spowelljr commented Oct 26, 2023

We wait 10 seconds to check if the API server is up, that's likely the biggest cause

I1026 14:02:14.483613 32925 kubeadm.go:612] needs reconfigure: apiserver error: context deadline exceeded

// needsReconfigure returns whether or not the cluster needs to be reconfigured
func (k *Bootstrapper) needsReconfigure(conf string, hostname string, port int, client *kubernetes.Clientset, version string) bool { 
        g := time.Now()
        if rr, err := k.c.RunCmd(exec.Command("sudo", "diff", "-u", conf, conf+".new")); err != nil { 
                klog.Infof("needs reconfigure: configs differ:\n%s", rr.Output())
                return true
        } 

        // cruntime.Enable() may restart kube-apiserver but does not wait for it to return back
        // could take five-ish seconds, so hopefully 10 seconds is sufficient to wait for api server to come back up
        apiStatusTimeout := 10 * time.Second
        st, err := kverify.WaitForAPIServerStatus(k.c, apiStatusTimeout, hostname, port)
        if err != nil { 
                klog.Infof("needs reconfigure: apiserver error: %v", err)
                return true
        } 
        if st != state.Running { 
                klog.Infof("needs reconfigure: apiserver in state %s", st)
                return true
        } 

        if err := kverify.ExpectAppsRunning(client, kverify.AppsRunningList); err != nil { 
                klog.Infof("needs reconfigure: %v", err)
                return true
        } 

        if err := kverify.APIServerVersionMatch(client, version); err != nil { 
                klog.Infof("needs reconfigure: %v", err)
                return true
        } 

        // DANGER: This log message is hard-coded in an integration test!
        klog.Infof("The running cluster does not require reconfiguration: %s", hostname)
        fmt.Println(time.Now().Sub(g))
        return false
}

Removing the check dropped the restart by 10 second to 10 total seconds

@medyagh
Copy link
Member

medyagh commented Dec 6, 2023

@prezha do you mind taking a look

@medyagh medyagh added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Dec 6, 2023
@prezha
Copy link
Contributor

prezha commented Dec 6, 2023

@medyagh sure, i'll have a look - we'll have to change lots of things to support the multi-cp setup, and it'll include refactoring this part of the code logic for sure

@medyagh
Copy link
Member

medyagh commented Dec 6, 2023

@medyagh sure, i'll have a look - we'll have to change lots of things to support the multi-cp setup, and it'll include refactoring this part of the code logic for sure

Excellent I look forward for that refactor, sounds exciting.

@prezha
Copy link
Contributor

prezha commented Jan 8, 2024

after pr #17909

docker driver

$ time minikube start --driver=docker
real    0m19.995s
user    0m1.323s
sys     0m0.297s

$ minikube stop

$ time minikube start
real    0m12.776s
user    0m0.670s
sys     0m0.205s

cleanup

$ minikube delete

kvm driver

$ time minikube start --driver=kvm2
real    0m35.555s
user    0m1.070s
sys     0m0.303s

$ minikube stop

$ time minikube start
real    0m26.548s
user    0m0.462s
sys     0m0.129s

@spowelljr
Copy link
Member Author

#17909 Made my restart go from 21s to 8.5s

@prezha
Copy link
Contributor

prezha commented Jan 9, 2024

that's excellent, thanks for checking @spowelljr !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement Categorizes issue or PR as related to improving upon a current feature. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants