Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Please clean up old cached images #1366
Comments
martinpitt
commented
Dec 1, 2015
|
Alternatively, is there some "cache prune" command that one could run from cron? I'm planning to use this for production autopkgtest, and they will create and remove containers all the time (and thus quickly pile up huge caches). |
|
Hmm, images should be automatically flushed 10 days after they were last used (configurable), seems like there's something off there. |
|
@martinpitt for autopkgtest, you probably want to use "lxd-images import ubuntu SERIES ARCH --alias SOME-NAME --sync" which will get you the official cloud images rather than the unofficial images our Jenkins builds. The --sync combined with the cronjob we ship with LXD in Ubuntu will also mean that the image will be updated for you every hour by cron. |
|
(and yes, we know it's a bit confusing right now with the two ways to get Ubuntu images, we will merge simplestream support directly in LXD in the next couple of months which will make the lxd-images script go away and hopefully simplify things a bit) |
martinpitt
commented
Dec 1, 2015
|
TBH, your images are much better than the cloud images -- they have tons of stuff on them which I don't want and which is even detrimental for testing. I have a big list of Thanks for the hint with importing! However, will that actually give me any benefit over the lazy downloading with specifying a remote image source? The nice thing there is that I get exactly the images that are needed, and I don't need any extra maintenance/cron jobs to sync images explicitly. |
martinpitt
commented
Dec 1, 2015
Ah, it hasn't been 10 days yet, just 7 :-) I'll watch this and report back in 4 days when the oldest image gets 11 days old. Thanks! |
|
You can also change the value:
I've never really seen this work here but that's mostly likely due to me never having images that are unused and old enough to be pruned. Looking at the code, just reducing the expiry should trigger an immediate expiry run. |
|
And no, if you're happy with the super minimal LXC images, you can keep using them. I just thought you'd prefer the cloud images as I believe that's what's currently used for the VM based autopkgtest setup and would make sense as a way to provide a consistent environment across arches. |
|
(but for Xenial, there sure is the benefit that our own images are actually built daily, which is not yet the case with the cloud images :)) |
martinpitt
commented
Dec 1, 2015
As a basis, yes, as that's all I get to start from. But I adjust them quite a bit (http://anonscm.debian.org/cgit/autopkgtest/autopkgtest.git/tree/setup-commands/cloud-vm-setup) to downsize them again. |
My 2 cents: I totally agree. |
martinpitt
commented
Dec 3, 2015
|
I close this for now. I'm quite sure I was just missing the 10 day cleanup period. If I really still have the old images next week I'll reopen. Thanks for the hint about lowering the cache time, that's going to be useful! |
martinpitt
closed this
Dec 3, 2015
martinpitt
commented
Dec 9, 2015
|
Hmm, I checked today again and I now have images which are more than 10 days old:
So reopening. |
martinpitt
reopened this
Dec 9, 2015
|
@hallyn any idea what may be going wrong? |
|
could you shut down lxd, then do sudo sqlite3 /var/lib/lxd/lxd.db SELECT value FROM config WHERE key='images.remote_cache_expiry'; I think what's going wrong is we're not setting a default of 10 like we meant to do. |
|
Oh, I see, we're supposed to cache there being no value and return 10 in that case. |
|
There are a few little errors there. I will push a fix later today plus a real test case. |
|
Note that the specs/configuration.md file says of the expiry time: Number of days after which an unused cached remote image will be flushed There are other bugs in the code anyway (expiry date was calculated wrong) which i fixed locally, but this description would not apply to the lxd-images imported images because they are not marked as cached, and presumably are not unused. Do we want to change this to say that any image created before current date - expiry-days is deleted? |
|
No, lxd-images indeed aren't cached images and that's fine. lxd-images itself has a --sync flag which does the auto-update and garbage collection. With lxd-images going away soon, the LXD caching mechanism will then be used for the cloud images too. @martinpitt is using the LXC images I believe. |
|
ok thx, then i'll post what i have to fix. |
added a commit
to hallyn/lxd
that referenced
this issue
Dec 9, 2015
martinpitt
commented
Dec 9, 2015
|
It seems you already have this figured out, but for the record:
|
martinpitt commentedDec 1, 2015
I haven't used lxd that many times yet, and already I have quite a sizable image cache:
It's of course very desirable to cache the latest version of a particular image. But it would be nice to automatically clean up older versions of the same image type,so that they don't pile up. It seems every image inflates to roughly 400 MB in
/var/lib/lxd/images/.FTR, these were created with something like
lxc launch images:ubuntu/trusty/amd64 t1whereimages:ishttps://images.linuxcontainers.org:8443.Thanks!