lxd icon indicating copy to clipboard operation
lxd copied to clipboard

lxd: Mark images as cached consistently

Open nmezhenskyi opened this issue 2 months ago • 3 comments

Fixes https://github.com/canonical/lxd/issues/16576.

Changes:

This PR makes marking images as cached consistent among projects that have features.images disabled.

  • If features.images is disabled for the project, associate the image with the default project inside of the ensureDownloadedImageFitWithinBudget() function. This ensures that cached=yes is set for a new image downloaded implicitly using lxc init <image> <instance_name>.
  • If features.images is disabled for the project, associate the image with the default project during lxc copy. This ensures that cached=no is set for a new image downloaded explicitly using lxc image copy.

nmezhenskyi avatar Oct 06 '25 23:10 nmezhenskyi

@nmezhenskyi please can you add a test for this, ta

tomponline avatar Oct 07 '25 07:10 tomponline

please can you add a test for this

@tomponline Will do!

There's just one more edge case to handle when it comes to explicitly copying images with lxc image copy to a project with features.images=false, so I'm working on that.

I also noticed that we have features.profiles option for projects that behaves similarly by letting projects with features.profiles=false use profiles from the default project, so I'm checking whether this works correctly as well.

nmezhenskyi avatar Oct 07 '25 12:10 nmezhenskyi

please can you add a test for this

@tomponline Will do!

There's just one more edge case to handle when it comes to explicitly copying images with lxc image copy to a project with features.images=false, so I'm working on that.

I also noticed that we have features.profiles option for projects that behaves similarly by letting projects with features.profiles=false use profiles from the default project, so I'm checking whether this works correctly as well.

Nice one!

tomponline avatar Oct 07 '25 13:10 tomponline