Images Not Being Deleted Automatically

Trying to get unused LXC images to be deleted on a daily basis. We have the following settings in place:

# lxc config show
config:
  images.auto_update_cached: "false"
  images.auto_update_interval: "0"
  images.remote_cache_expiry: "1"

We have no containers currently running. However, we have images showing with lxc image list that have been unused for weeks.

Example:

#lxc image info d0e84947eda4
Fingerprint: d0e84947eda42b8d258d162edf53ff7e3f05b7cd76c852e7dcbcbc88c6025b83
Size: 16273.32MB
Architecture: x86_64
Public: no
Timestamps:
    Uploaded: 2019/06/08 16:51 UTC
    Expires: never
    Last used: never
Properties:
Aliases:
Cached: no
Auto update: disabled

How do we get LXD to remove such images automatically?

From the doc:

The image will be kept locally as a private image until either it's been unused
(no new container spawned) for the number of days set in
`images.remote_cache_expiry` or until the image's expiry is reached
whichever comes first.

your image has never been used, so the remote_cache_expiry parameter is not relevant.

Looks like the ones being left with a “never” used date are snapshots created by nova-lxd. They remain even after both the instance and glance snapshot have been deleted. I don’t think they should be on compute in the first place unless I’m overlooking something.

Side note - is there a way to trigger an image cache cleanup manually?

Reloading lxd would cause an image expiry to trigger I believe (systemctl reload snap.lxd.daemon).

Only images that are marked as cached will be affected by auto-expiry. Use lxc image info to check.

Thank you. Looks like none of these are cached. If I’m not mistaken, they are either images from glance used by nova-lxd to launch containers or snapshots created by nova-lxd. Any idea if a method currently exists to clean them up on the compute node automatically? And is there a way outside of patching nova-lxd to bypass LXC’s default local snapshots and only use snapshots stored by glance? At the moment it seems to keep a local snapshot and send one to glance. If I delete the local one, restoring no longer works.

Not sure if there’s something in lxc config or profiles that would accomplish what we’re trying to do.

LXD itself isn’t aware nor does anything directly for nova-lxd/glance, so I think your best bet is to get nova-lxd to do what you want there. Cleaning things up behind its back is likely to result in unexpected problems.