8000 Don't cache images when --vmdriver=none by marcosdiez · Pull Request #4059 · kubernetes/minikube · GitHub
[go: up one dir, main page]

Skip to content

Don't cache images when --vmdriver=none - #4059

Merged
tstromberg merged 5 commits into
kubernetes:masterfrom
marcosdiez:dont-cache-images-when-vmdriver-is-none
Apr 10, 2019
Merged

tstromberg merged 5 commits into
kubernetes:masterfrom
marcosdiez:dont-cache-images-when-vmdriver-is-none

Conversation

@marcosdiez
Copy link
Copy Markdown
Contributor

Since #3917, images are cached by default.

That is great, except that it does not make sense when --vmdriver=none.
When cache is enabled,

  • minikube download the images to ~/.minikube/cache
  • minikube loads them (docker load -i ~/.minikube/cache/someimage)

When --vmdriver=none, the machine's docker is used, so any loaded image will be stored there "forever" anyway. Hence they are already cached. And setting the cache enable has actually two downsides:

  • it uses local disk space unnecessarily
  • on every minikube launch it will load images from ~/.minikube/cache/someimage to docker, even though they are there already.

So these 5 lines of code do speedup the launch!

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 5, 2019
8000
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: marcosdiez
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: dlorenc

If they are not already assigned, you can assign the PR to them by writing /assign @dlorenc in a comment when ready.

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

The pull request process is described here

Details 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 5, 2019
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @marcosdiez. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 5, 2019
@minikube-bot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 5, 2019
Comment thread cmd/minikube/cmd/start.go Outdated
`docker load -i ~/.minikube/cache/some_images` is unecessary and takes time.
As a bonus, we save disk space.
*/
console.OutStyle("starting-none", "Caching of container images is disabled when --vm-driver=none")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this line - minikube, particularly with the none driver, has enough console output as is.

@tstromberg
Copy link
Copy Markdown
Contributor

Thanks for the PR! It looks like it does the right thing - just one minor comment.

@tstromberg
Copy link
Copy Markdown
Contributor

@minikube-bot OK to test

@afbjorklund afbjorklund left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sounds to good me, it is a little disappointing that it reloads images that are already there.

I suppose that is wanted behaviour when using weird "tags" like latest, but maybe it could be fixed for all scenarios - i.e. if we already have the tag (or digest?) maybe we shouldn't be loading anything anywhere

@marcosdiez
Copy link
Copy Markdown
Contributor Author

@afbjorklund I believe even with weird tags like latest this is not necessary.

Kubernetes itself has a every interesting policy for tags.
By default, it only tries to check if there is an update if the tag is latest. Else, it will use what's in there or download it in case it does not have it locally. (source: https://kubernetes.io/docs/concepts/containers/images/ )

That means if we cache an image with the latest tag, kubernetes will try to download it again anyway.

Thinking about it a little bit further, it's worse!
Let's say minikube has a cached and "old" version of latest. It would to load it to docker all the time.

Then kubernetes would launch, check the version and download the newest version (because minikube's version is old)

Next time I reboot my laptop and run minikube again, minikube would put back the old version of latest and kubernetes would have to download once more.

@afbjorklund
Copy link
Copy Markdown
Collaborator

Yeah, that makes sense... And I guess even if you did reload the same image it would still reuse the layers - haven't tested

Comment thread cmd/minikube/cmd/start.go Outdated

if viper.GetString(vmDriver) == constants.DriverNone {
/*
Caching images means:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can do with a much smaller comment:

// Optimization: images will be persistently loaded into host Docker, so no need to duplicate work.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And to be policitally correct it should be "the container runtime", not Docker®

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 10, 2019
@tstromberg tstromberg left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0