Description
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.