canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.38k stars 930 forks source link

Update storage pool cache if LXD is clustered #14046

Open roosterfish opened 2 months ago

roosterfish commented 2 months ago

When MicroCloud bootstraps a new LXD cluster and you invoke any lxc * command on any of the cluster members for the first time you get the following message:

If this is your first time running LXD on this machine, you should also run: lxd init

This might be misleading as MicroCloud has already setup storage, networking and the cluster between the nodes.

When querying the /1.0 endpoint the storage_version value doesn't show any storage pool even though MicroCloud has already active storage pools.

It's because when you create a storage pool on a single node LXD, the storagePoolCreateGlobal func is calling dbStoragePoolCreateAndUpdateCache down the line which runs storagePoolDriversCacheUpdate and updates the global var storagePoolUsedDriversCacheVal.

But the same isn't happening when creating a storage pool within a LXD cluster using storagePoolsPostCluster. This causes the cache not being updated.

roosterfish commented 2 months ago

Maybe the cache update can be moved a few levels up in the API handler storagePoolsPost.

tomponline commented 2 months ago

Maybe the cache update can be moved a few levels up in the API handler storagePoolsPost.

Maybe, but this is only going to update the local member's cache.

We may need to do this, and incorporate a cluster notification to update the cache.

@hamistao want to look at this one as its non-trivial?

hamistao commented 2 months ago

Sure, I will assign to myself.