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

Fix status taking a long time on docker driver #15077

Merged
merged 2 commits into from
Oct 7, 2022

Conversation

spowelljr
Copy link
Member

@spowelljr spowelljr commented Oct 5, 2022

Fixes #15076

Problem:
While using the docker driver, minikube status when the apiserver was paused took 16 seconds, and would incorrectly report that the apiserver was Stopped. This is due to Kicbase not having the freezer cgroup and and falling back to HTTP calls, which all fail since the apiserver is paused, so after numerous retries it reports that the apiserver is Stopped.

Solution:
When the user pauses the kube-system namespace create a file in the cluster to indicate that the apiserver is paused. When the user unpauses the kube-system namespace the file is deleted. When checking the status if freezer is not on the system it looks for the file and if it's found it reports back that the apiserver is paused, otherwise if does the existing HTTP calls.

Before:
minikube status while apiserver is paused takes 16 seconds and apiserver status is Stopped (wrong).

$ time minikube status
minikube
type: Control Plane
host: Running
kubelet: Stopped
apiserver: Stopped
kubeconfig: Configured


real	0m15.906s

After:
minikube status while apiserver is paused takes 0.5 seconds and apiserver status is Paused (correct).

$ time minikube status
minikube
type: Control Plane
host: Running
kubelet: Stopped
apiserver: Paused
kubeconfig: Configured


real	0m0.517s

Result: 97% time reduction in minikube status command while now reporting the correct status.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 5, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 5, 2022
@spowelljr
Copy link
Member Author

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Oct 5, 2022
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15077) |
+----------------+----------+---------------------+
| minikube start | 59.5s    | 59.8s               |
| enable ingress | 31.4s    | 31.6s               |
+----------------+----------+---------------------+

Times for minikube start: 59.1s 59.4s 59.9s 59.5s 59.7s
Times for minikube (PR 15077) start: 60.3s 59.8s 59.9s 58.9s 60.1s

Times for minikube ingress: 31.0s 30.4s 31.9s 31.4s 32.4s
Times for minikube (PR 15077) ingress: 30.4s 32.4s 31.9s 31.9s 31.4s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15077) |
+----------------+----------+---------------------+
| minikube start | 30.5s    | 32.5s               |
| enable ingress | 23.2s    | 23.5s               |
+----------------+----------+---------------------+

Times for minikube start: 29.8s 28.7s 30.2s 29.9s 34.0s
Times for minikube (PR 15077) start: 32.6s 30.1s 33.7s 33.2s 32.8s

Times for minikube ingress: 23.1s 23.1s 23.6s 23.1s 23.1s
Times for minikube (PR 15077) ingress: 22.6s 23.6s 26.1s 22.7s 22.6s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15077) |
+----------------+----------+---------------------+
| minikube start | 28.5s    | 29.2s               |
| enable ingress | 27.7s    | 28.6s               |
+----------------+----------+---------------------+

Times for minikube (PR 15077) start: 39.5s 26.3s 25.8s 28.6s 25.8s
Times for minikube start: 26.0s 37.0s 26.4s 26.2s 26.7s

Times for minikube ingress: 28.1s 27.6s 27.6s 27.6s 27.6s
Times for minikube (PR 15077) ingress: 28.1s 27.6s 32.1s 27.6s 27.7s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Docker_macOS TestPause/serial/SecondStartNoReconfiguration (gopogh) 7.04 (chart)
KVM_Linux_containerd TestPreload (gopogh) 7.89 (chart)
Hyper-V_Windows TestNoKubernetes/serial/StartWithK8s (gopogh) 24.64 (chart)
Docker_Linux_containerd TestPreload (gopogh) 32.48 (chart)
Docker_macOS TestMultiNode/serial/RestartKeepsNodes (gopogh) 34.93 (chart)
Hyper-V_Windows TestPause/serial/SecondStartNoReconfiguration (gopogh) 38.41 (chart)
KVM_Linux TestPause/serial/SecondStartNoReconfiguration (gopogh) 39.87 (chart)
Docker_Windows TestAddons/Setup (gopogh) 47.76 (chart)
Docker_Windows TestCertExpiration (gopogh) 47.76 (chart)
Docker_Windows TestCertOptions (gopogh) 47.76 (chart)
Docker_Windows TestDockerFlags (gopogh) 47.76 (chart)
Docker_Windows TestErrorSpam/setup (gopogh) 47.76 (chart)
Docker_Windows TestForceSystemdEnv (gopogh) 47.76 (chart)
Docker_Windows TestForceSystemdFlag (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/CertSync (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/CpCmd (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/FileSync (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageBuild (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListJson (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListShort (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListTable (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListYaml (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageLoadDaemon (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageLoadFromFile (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageReloadDaemon (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageSaveDaemon (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageSaveToFile (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageTagAndLoadDaemon (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/Setup (gopogh) 47.76 (chart)
Docker_Windows TestFunctional/parallel/NonActiveRuntimeDisabled (gopogh) 47.76 (chart)
More tests... Continued...

Too many tests failed - See test logs for more details.

To see the flake rates of all tests by environment, click here.

@@ -207,6 +207,17 @@ func APIServerStatus(cr command.Runner, hostname string, port int) (state.State,
return apiServerHealthz(hostname, port)
}

func nonFreezerServerStatus(cr command.Runner, hostname string, port int) (state.State, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add detailed comment for this function. the name is not self-explantory

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment

@@ -207,6 +207,17 @@ func APIServerStatus(cr command.Runner, hostname string, port int) (state.State,
return apiServerHealthz(hostname, port)
}

func nonFreezerServerStatus(cr command.Runner, hostname string, port int) (state.State, error) {
rr, err := cr.RunCmd(exec.Command("ls"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this running in home folder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

return ids, errors.Wrap(err, "pausing containers")
}

if isTouchingKubeSystem(namespaces) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious if it is better to have the "paused" file to be in the /tmp ? in case minikube VM gets restarted to be auto-cleaned ?

the question is, when minikube is paused, and user restarts minikube VM (not through minikube interface but by shutting down the laptop) would minikube still be paused ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried moving the file to /tmp, it did auto-remove the file on minikube stop. However, running minikube start when the cluster was paused resulted in the apiserver still being marked as Paused. So the paused file has to be removed on a start which nullifies the benefit to moving it to /tmp.

When the user manually restarts the container (as this only affects kicbase, not ISO) the kubelet and apiserver are stopped and a minikube start has to be run.

@@ -115,3 +132,16 @@ func CheckIfPaused(cr cruntime.Manager, namespaces []string) (bool, error) {

return false, nil
}

// isTouchingKubeSystem returns if the user is pausing or unpausing the kube-system namespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this function return "-ing" state ? does it mean if it returns true then another function is Touch-ing the file ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name was vague, renamed and improved the comment

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once comments are resolved lgtm

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15077) |
+----------------+----------+---------------------+
| minikube start | 55.8s    | 55.7s               |
| enable ingress | 26.1s    | 28.2s               |
+----------------+----------+---------------------+

Times for minikube start: 55.6s 56.5s 55.8s 56.3s 54.7s
Times for minikube (PR 15077) start: 54.2s 55.7s 55.2s 56.8s 56.4s

Times for minikube ingress: 25.7s 25.7s 28.2s 25.6s 25.1s
Times for minikube (PR 15077) ingress: 29.2s 28.7s 27.7s 29.2s 26.2s

docker driver with docker runtime

+-------------------+----------+---------------------+
|      COMMAND      | MINIKUBE | MINIKUBE (PR 15077) |
+-------------------+----------+---------------------+
| minikube start    | 27.5s    | 27.8s               |
| ⚠️  enable ingress | 23.1s    | 34.6s ⚠️             |
+-------------------+----------+---------------------+

Times for minikube start: 27.2s 25.6s 28.1s 27.4s 29.0s
Times for minikube (PR 15077) start: 28.0s 26.3s 28.3s 29.2s 27.0s

Times for minikube ingress: 22.4s 24.0s 20.5s 23.0s 25.5s
Times for minikube (PR 15077) ingress: 22.5s 22.0s 83.0s 23.0s 22.5s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 15077) |
+----------------+----------+---------------------+
| minikube start | 23.4s    | 24.5s               |
| enable ingress | 29.1s    | 29.1s               |
+----------------+----------+---------------------+

Times for minikube start: 22.7s 24.0s 23.8s 23.7s 22.7s
Times for minikube (PR 15077) start: 22.5s 25.7s 24.1s 26.5s 23.8s

Times for minikube ingress: 27.5s 27.0s 27.0s 27.0s 37.0s
Times for minikube (PR 15077) ingress: 27.5s 37.0s 27.1s 27.0s 27.0s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
KVM_Linux_containerd TestPreload (gopogh) 13.58 (chart)
Docker_Linux_containerd TestPreload (gopogh) 36.53 (chart)
KVM_Linux TestPause/serial/SecondStartNoReconfiguration (gopogh) 39.88 (chart)
Docker_Windows TestAddons/Setup (gopogh) 48.25 (chart)
Docker_Windows TestCertExpiration (gopogh) 48.25 (chart)
Docker_Windows TestCertOptions (gopogh) 48.25 (chart)
Docker_Windows TestDockerFlags (gopogh) 48.25 (chart)
Docker_Windows TestErrorSpam/setup (gopogh) 48.25 (chart)
Docker_Windows TestForceSystemdEnv (gopogh) 48.25 (chart)
Docker_Windows TestForceSystemdFlag (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/CertSync (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/CpCmd (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/FileSync (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageBuild (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListJson (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListShort (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListTable (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageListYaml (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageLoadDaemon (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageLoadFromFile (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageReloadDaemon (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageSaveDaemon (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageSaveToFile (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/ImageTagAndLoadDaemon (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/ImageCommands/Setup (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/NonActiveRuntimeDisabled (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/SSHCmd (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/UpdateContextCmd/no_changes (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/UpdateContextCmd/no_clusters (gopogh) 48.25 (chart)
Docker_Windows TestFunctional/parallel/UpdateContextCmd/no_minikube_cluster (gopogh) 48.25 (chart)
More tests... Continued...

Too many tests failed - See test logs for more details.

To see the flake rates of all tests by environment, click here.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh, spowelljr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@spowelljr spowelljr merged commit 5b4b685 into kubernetes:master Oct 7, 2022
@spowelljr spowelljr deleted the fixPause branch October 7, 2022 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

minikube status take long time when paused on docker driver
4 participants