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

update prune instructions to not prune minikube itself #10801

Closed
wants to merge 2 commits into from

Conversation

medyagh
Copy link
Member

@medyagh medyagh commented Mar 12, 2021

closes #10773

Before this PR

$ mk start
πŸ˜„  minikube v1.18.1 on Darwin 11.2.3
✨  Using the docker driver based on existing profile
πŸ‘  Starting control plane node minikube in cluster minikube
❗  Executing "docker container inspect minikube --format={{.State.Status}}" took an unusually long time: 140.562388ms
πŸ’‘  Restarting the docker service may improve performance.
πŸƒ  Updating the running docker "minikube" container ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
πŸ”Ž  Verifying Kubernetes components...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by defaul

After this PR

fix the suggestion not to prune minikube itself (if it is stopped)

πŸ˜„  minikube v1.18.1 on Darwin 11.2.3
✨  Using the docker driver based on existing profile
πŸ‘  Starting control plane node minikube in cluster minikube
❗  Executing "docker container inspect minikube --format={{.State.Status}}" took an unusually long time: 196.475601ms
πŸ’‘  Restarting or pruning the docker service may improve performance.
    β–ͺ To prune run: $ docker system prune --filter="label!=created_by.minikube.sigs.k8s.io=true"
    β–ͺ To restart: Click Docker 🐳 in the system tray and then click "Restart Docker"
πŸ”„  Restarting existing docker container for "minikube" ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
πŸ”Ž  Verifying Kubernetes components...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh

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

@k8s-ci-robot k8s-ci-robot added 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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 12, 2021
@medyagh
Copy link
Member Author

medyagh commented Mar 13, 2021

/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 Mar 13, 2021
@tstromberg
Copy link
Contributor

Could you please provide more context? I don't yet agree with this PR.

  • Pruning containers should not improve performance. The containers are after all, stopped. Please provide evidence otherwise.
  • Pruning does not affect usage of 'minikube pause'. It does not stop containers.

@medyagh
Copy link
Member Author

medyagh commented Mar 15, 2021

Could you please provide more context? I don't yet agree with this PR.

  • Pruning containers should not improve performance. The containers are after all, stopped. Please provide evidence otherwise.
  • Pruning does not affect usage of 'minikube pause'. It does not stop containers.

@tstromberg I agree it is probably not an advice that will help everybody, but in some cases I have seen when users have hundreds of dangling images, docker ps and docker imgages is very slow (due to docker calucating hashesh)
so while it might not help eveyrone, but it might help someone and it is the best advice we got anyways (if they reach out for us to help)

not strong opinion though, I am okay with removing the prune, wdyt ?

@kubernetes kubernetes deleted a comment from minikube-pr-bot Mar 16, 2021
@medyagh
Copy link
Member Author

medyagh commented Mar 16, 2021

  • Pruning does not affect usage of 'minikube pause'. It does not stop containers.

@tstromberg this PR doesnt affec the Paused clusters, only adds more specific instructions for pruninng, so the user doesn't remove minikube itself in the process of prunning

@minikube-pr-bot
Copy link

kvm2 Driver
Times for minikube: 67.4s 65.5s 64.7s
Average time for minikube: 65.9s

Times for Minikube (PR 10801): 63.7s 63.5s 65.0s
Average time for Minikube (PR 10801): 64.1s

Averages Time Per Log

+--------------------------------------------+----------+---------------------+
|                    LOG                     | MINIKUBE | MINIKUBE (PR 10801) |
+--------------------------------------------+----------+---------------------+
| * minikube v1.18.1 on Debian               | 1.1s     | 0.0s                |
| 9.11 (kvm/amd64)                           |          |                     |
| * Using the kvm2 driver based              | 0.0s     | 0.0s                |
| on user configuration                      |          |                     |
| * Starting control plane node              | 0.0s     | 0.0s                |
| minikube in cluster minikube               |          |                     |
| * Creating kvm2 VM (CPUs=2,                | 39.9s    | 39.8s               |
| Memory=3700MB, Disk=20000MB)               |          |                     |
| ...                                        |          |                     |
| * Preparing Kubernetes v1.20.2             | 8.6s     | 8.5s                |
| on Docker 20.10.3 ...                      |          |                     |
|   - Generating certificates                | 2.6s     | 2.7s                |
| and keys ...                               |          |                     |
|   - Booting up control plane               | 9.9s     | 10.1s               |
| ...                                        |          |                     |
|   - Configuring RBAC rules ...             | 1.1s     | 1.1s                |
| * Verifying Kubernetes                     | 0.1s     | 0.1s                |
| components...                              |          |                     |
|   - Using image                            | 1.3s     | 1.2s                |
| gcr.io/k8s-minikube/storage-provisioner:v4 |          |                     |
| * Enabled addons:                          | 1.5s     | 0.6s                |
| default-storageclass,                      |          |                     |
| storage-provisioner                        |          |                     |
| * Done! kubectl is now                     | 0.0s     | 0.0s                |
| configured to use "minikube"               |          |                     |
| cluster and "default"                      |          |                     |
| namespace by default                       |          |                     |
+--------------------------------------------+----------+---------------------+

docker Driver
Times for minikube: 26.0s 26.6s 26.7s
Average time for minikube: 26.4s

Times for Minikube (PR 10801): 26.5s 26.6s 26.7s
Average time for Minikube (PR 10801): 26.6s

Averages Time Per Log

+--------------------------------------------+----------+---------------------+
|                    LOG                     | MINIKUBE | MINIKUBE (PR 10801) |
+--------------------------------------------+----------+---------------------+
| * minikube v1.18.1 on Debian               | 0.2s     | 0.2s                |
| 9.11 (kvm/amd64)                           |          |                     |
| * Using the docker driver                  | 0.1s     | 0.1s                |
| based on user configuration                |          |                     |
| * Starting control plane node              | 0.1s     | 0.1s                |
| minikube in cluster minikube               |          |                     |
| * Creating docker container                | 9.4s     | 9.6s                |
| (CPUs=2, Memory=3700MB) ...                |          |                     |
| * Preparing Kubernetes v1.20.2             | 15.2s    | 15.4s               |
| on Docker 20.10.3 ...                      |          |                     |
| * Verifying Kubernetes                     | 0.1s     | 0.1s                |
| components...                              |          |                     |
|   - Using image                            | 1.4s     | 1.1s                |
| gcr.io/k8s-minikube/storage-provisioner:v4 |          |                     |
| * Enabled addons:                          | 0.1s     | 0.1s                |
| storage-provisioner,                       |          |                     |
| default-storageclass                       |          |                     |
| * Done! kubectl is now                     | 0.0s     | 0.0s                |
| configured to use "minikube"               |          |                     |
| cluster and "default"                      |          |                     |
| namespace by default                       |          |                     |
+--------------------------------------------+----------+---------------------+

@@ -148,8 +148,14 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
out.WarningT(`Executing "{{.command}}" took an unusually long time: {{.duration}}`, out.V{"command": rr.Command(), "duration": elapsed})
// Don't show any restarting hint, when running podman locally (on linux, with sudo). Only when having a service.
if cmd.Args[0] != "sudo" {
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic to determine if this is Docker should be improved so as not to require the clarifying comment. It's pretty obscure.

Copy link
Member Author

@medyagh medyagh Mar 23, 2021

Choose a reason for hiding this comment

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

I agree this code seems weird, even for me each time I read it it feels odd, that we check for sudo.

This is a compromise that @afbjorklund suggested and implemented to avoid code complexity and since we do not allow running docker with β€œSudo” , it is also most efficient way

Copy link
Contributor

Choose a reason for hiding this comment

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

If the runner can't be made aware of which environment it is in, perhaps it's a good sign that it should be passing the signal upwards rather than providing advice for an environment. For instance, returning duration upwards in RunResult.

If that isn't feasible, lets simplify this check, and make it more accurate at the same time. Is there a way to check if the OCI is Docker (based on either the object, cmd.Args, or some other magic)? Ideally, this should say something like:

if isDocker() {
  .. show docker advice ...
}

For instance, this function could simply check if cmd arg 0 or 1 is docker.

@@ -148,8 +148,14 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
out.WarningT(`Executing "{{.command}}" took an unusually long time: {{.duration}}`, out.V{"command": rr.Command(), "duration": elapsed})
// Don't show any restarting hint, when running podman locally (on linux, with sudo). Only when having a service.
if cmd.Args[0] != "sudo" {
out.ErrT(style.Tip, `Restarting the {{.name}} service may improve performance.`, out.V{"name": cmd.Args[0]})
out.ErrT(style.Tip, `Restarting or pruning the {{.name}} service may improve performance.`, out.V{"name": cmd.Args[0]})
out.Infof(`To prune run: $ docker system prune --filter="label!=created_by.minikube.sigs.k8s.io=true"`)
Copy link
Contributor

Choose a reason for hiding this comment

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

This still intuitively doesn't make much sense to me. Can you provide some additional context, such as a documentation from Docker or a benchmark? I want to make sure we aren't selling snake-oil here.

Copy link
Member Author

@medyagh medyagh Mar 23, 2021

Choose a reason for hiding this comment

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

One systems which user has hundreds of dangling images without owner, docker commands such as docker ps, do take longer.
(Which causes minikube to be slow too)

To replicate, you could do what an average user would do, go to random GitHub with READMe that says docker run.... And then forget about them. And many cases this might not help them at all, and same story for β€œrestart” suggestion, I have noticed slow dockers that nothing helped them.

It is not really selling snake oil, It is the only suggestions that we got, and might help someone, specially if they wanna do prune on their own (such as tejal, we better at least give them the Right prune command)

I would be happy to change the wording to say, This MIGH not help u at all, might 10% chance this might be the problem. but that would make the dislclaimer text long

We already tell the suer β€œMay improve”

And to be clear, on some slow dockers that I noticed, Restarting didn’t do anything either.

And if the user comes creates issue in github, I would tell them same suggestion, restart, prune,... there isn’t much else to do tbh

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my recommendation then to take a data driven approach to this:

  • Starting 10,000 abandoned containers.
  • Run minikube and note the run durations mentioned in the log file (you mention ps). minikube should complain about slowdowns.
  • prune
  • Run minikube and note the run durations that changed since prune
  • Adjust this logic to only suggest prune for the commands which would in fact be improved, such as ps as you have mentioned.

@@ -35,6 +35,14 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta

[comment]: <> (this title is used in the docs links, don't change)

### Prune docker to avoid performance downgrade in minikube
the following command will prune all on unused/stopped containers, volumes on your docker.
Copy link
Contributor

Choose a reason for hiding this comment

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

Provide contextual documentation on why this improves performance.

Also, remove the leading whitespace and capitalize "the".

@@ -173,8 +173,9 @@ var (
ID: "RSRC_DOCKER_STORAGE",
ExitCode: ExInsufficientStorage,
Advice: `Try one or more of the following to free up space on the device:

1. Run "docker system prune" to remove unused Docker data (optionally with "-a")
1. Remove unused Docker data (optionally with "-a")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this should say "Remove Docker daemon generated outside of minikube"?

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 am not sure if talking about outside and inside minikbue would make sense for the average end user. That might confuse them even more.
Since we give them the shell command with $ ... to copy paste.

If we wanted inside minikube we would give them this command
$ minikbue ssh docker system prune ...

Copy link
Contributor

Choose a reason for hiding this comment

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

By outside of minikube, I mean images that were not created by minikube, as this command explicitly filters those out. I'm not sure of the exact best verbiage here, but the comment is no longer accurate to the command it describes.

@@ -148,8 +148,14 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
out.WarningT(`Executing "{{.command}}" took an unusually long time: {{.duration}}`, out.V{"command": rr.Command(), "duration": elapsed})
// Don't show any restarting hint, when running podman locally (on linux, with sudo). Only when having a service.
if cmd.Args[0] != "sudo" {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the runner can't be made aware of which environment it is in, perhaps it's a good sign that it should be passing the signal upwards rather than providing advice for an environment. For instance, returning duration upwards in RunResult.

If that isn't feasible, lets simplify this check, and make it more accurate at the same time. Is there a way to check if the OCI is Docker (based on either the object, cmd.Args, or some other magic)? Ideally, this should say something like:

if isDocker() {
  .. show docker advice ...
}

For instance, this function could simply check if cmd arg 0 or 1 is docker.

@@ -148,8 +148,14 @@ func runCmd(cmd *exec.Cmd, warnSlow ...bool) (*RunResult, error) {
out.WarningT(`Executing "{{.command}}" took an unusually long time: {{.duration}}`, out.V{"command": rr.Command(), "duration": elapsed})
// Don't show any restarting hint, when running podman locally (on linux, with sudo). Only when having a service.
if cmd.Args[0] != "sudo" {
out.ErrT(style.Tip, `Restarting the {{.name}} service may improve performance.`, out.V{"name": cmd.Args[0]})
out.ErrT(style.Tip, `Restarting or pruning the {{.name}} service may improve performance.`, out.V{"name": cmd.Args[0]})
out.Infof(`To prune run: $ docker system prune --filter="label!=created_by.minikube.sigs.k8s.io=true"`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's my recommendation then to take a data driven approach to this:

  • Starting 10,000 abandoned containers.
  • Run minikube and note the run durations mentioned in the log file (you mention ps). minikube should complain about slowdowns.
  • prune
  • Run minikube and note the run durations that changed since prune
  • Adjust this logic to only suggest prune for the commands which would in fact be improved, such as ps as you have mentioned.

@@ -173,8 +173,9 @@ var (
ID: "RSRC_DOCKER_STORAGE",
ExitCode: ExInsufficientStorage,
Advice: `Try one or more of the following to free up space on the device:

1. Run "docker system prune" to remove unused Docker data (optionally with "-a")
1. Remove unused Docker data (optionally with "-a")
Copy link
Contributor

Choose a reason for hiding this comment

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

By outside of minikube, I mean images that were not created by minikube, as this command explicitly filters those out. I'm not sure of the exact best verbiage here, but the comment is no longer accurate to the command it describes.

@medyagh medyagh closed this Apr 23, 2021
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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker: Update prune suggestion to exclude minikube containers
4 participants