Skip to content

Cut down on the amount of logging when nerdctl-full cache already exist #1875

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

Closed
afbjorklund opened this issue Oct 2, 2023 · 2 comments · Fixed by #1877
Closed

Cut down on the amount of logging when nerdctl-full cache already exist #1875

afbjorklund opened this issue Oct 2, 2023 · 2 comments · Fixed by #1877

Comments

@afbjorklund
Copy link
Member

afbjorklund commented Oct 2, 2023

Description

Currently we skip the logging of the "image" (basedisk), when starting up an instance.

But we still log the "nerdctl archive" (nerdctl-full) every time, even if the file already exists.

I think we should check the cache, and skip the log if the file is already cached for this version.

Especially since we are already caching the file on create, so "normally" it will be in the cache...


limactl create

INFO[0000] Attempting to download the image              arch=x86_64 digest="sha256:1e35473cea5e1b827b91ad6ebb43b605a00d506c11f66c75076c424ae5372440" location="https://cloud-images.ubuntu.com/releases/23.04/release-20230926/ubuntu-23.04-server-cloudimg-amd64.img"
INFO[0000] Using cache "/home/anders/.cache/lima/download/by-url-sha256/c97220a456808578ed26e569621cdec0baae5996af78eb6ff7fd3668dd31526b/data" 
INFO[0000] Attempting to download the nerdctl archive    arch=x86_64 digest="sha256:2c5c43a8b77ed62090241027361baa62d8fb70a759bc9e7a82c637135598701f" location="https://github.com/containerd/nerdctl/releases/download/v1.6.0/nerdctl-full-1.6.0-linux-amd64.tar.gz"
INFO[0000] Using cache "/home/anders/.cache/lima/download/by-url-sha256/addb72512fd2fef72b08d8648173d7aaec3b4d5ae0566ac0bfd03c5adeeafc78/data" 

limactl start

INFO[0000] Attempting to download the nerdctl archive    arch=x86_64 digest="sha256:2c5c43a8b77ed62090241027361baa62d8fb70a759bc9e7a82c637135598701f" location="https://github.com/containerd/nerdctl/releases/download/v1.6.0/nerdctl-full-1.6.0-linux-amd64.tar.gz"
INFO[0000] Using cache "/home/anders/.cache/lima/download/by-url-sha256/addb72512fd2fef72b08d8648173d7aaec3b4d5ae0566ac0bfd03c5adeeafc78/data" 

It is probably overkill to make a copy (or even symlink) of it, like we do with the basedisk:

        if _, err := os.Stat(baseDisk); errors.Is(err, os.ErrNotExist) {

                        if _, err := fileutils.DownloadFile(baseDisk, f.File, true, "the image", *cfg.LimaYAML.Arch); err != nil {

But if needed, we could write some kind of placeholder cache reference to the lima directory

        if _, err := os.Stat(cacheFile); errors.Is(err, os.ErrNotExist) {

                path, err := fileutils.DownloadFile("", f, false, "the nerdctl archive", *y.Arch)

My idea was to just look and see if the cache file already exists, and if so skip the download.

This by adding a new function to fileutils, either return the cache path or just an "exists" boolean.

@afbjorklund
Copy link
Member Author

Should also look the special case where the archive is overridden with a local file, that would also work.

i.e. we don't copy local files to the cache, but if the local file exists that is also "good enough" to skip logging

@afbjorklund
Copy link
Member Author

This would also apply to any other files, beyond the containerd / nerdctl-full archives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant