diff --git a/lxd/patches.go b/lxd/patches.go index e39f1aae4a3d..dcfae0070785 100644 --- a/lxd/patches.go +++ b/lxd/patches.go @@ -1272,7 +1272,6 @@ func patchStorageUnsetInvalidBlockSettings(_ string, d *Daemon) error { } volTypeCustom := dbCluster.StoragePoolVolumeTypeCustom - volTypeVM := dbCluster.StoragePoolVolumeTypeVM poolIDNameMap := make(map[int64]string, 0) poolVolumes := make(map[int64][]*db.StorageVolume, 0) @@ -1309,7 +1308,7 @@ func patchStorageUnsetInvalidBlockSettings(_ string, d *Daemon) error { } // Get the pool's storage volumes. - volumes, err = tx.GetStoragePoolVolumes(ctx, poolID, false, db.StorageVolumeFilter{Type: &volTypeCustom}, db.StorageVolumeFilter{Type: &volTypeVM}) + volumes, err = tx.GetStoragePoolVolumes(ctx, poolID, false, db.StorageVolumeFilter{Type: &volTypeCustom}) if err != nil { return fmt.Errorf("Failed getting custom storage volumes of pool %q: %w", pool, err) } @@ -1328,12 +1327,9 @@ func patchStorageUnsetInvalidBlockSettings(_ string, d *Daemon) error { poolVolumes[poolID] = append(poolVolumes[poolID], volumes...) } - var volType int - for pool, volumes := range poolVolumes { for _, vol := range volumes { // Skip custom volumes with filesystem content type. - // VMs are always of type block. if vol.Type == dbCluster.StoragePoolVolumeTypeNameCustom && vol.ContentType == dbCluster.StoragePoolVolumeContentTypeNameFS { continue } @@ -1353,17 +1349,13 @@ func patchStorageUnsetInvalidBlockSettings(_ string, d *Daemon) error { continue } - if vol.Type == dbCluster.StoragePoolVolumeTypeNameVM { - volType = volTypeVM - } else if vol.Type == dbCluster.StoragePoolVolumeTypeNameCustom { - volType = volTypeCustom - } else { + if vol.Type != dbCluster.StoragePoolVolumeTypeNameCustom { // Should not happen. continue } err = s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error { - return tx.UpdateStoragePoolVolume(ctx, vol.Project, vol.Name, volType, pool, vol.Description, config) + return tx.UpdateStoragePoolVolume(ctx, vol.Project, vol.Name, volTypeCustom, pool, vol.Description, config) }) if err != nil { return fmt.Errorf("Failed updating volume %q in project %q on pool %q: %w", vol.Name, vol.Project, poolIDNameMap[pool], err) diff --git a/lxd/storage/drivers/driver_ceph_volumes.go b/lxd/storage/drivers/driver_ceph_volumes.go index e777faf40398..4b98a8d20f78 100644 --- a/lxd/storage/drivers/driver_ceph_volumes.go +++ b/lxd/storage/drivers/driver_ceph_volumes.go @@ -867,7 +867,7 @@ func (d *ceph) ValidateVolume(vol Volume, removeUnknownKeys bool) error { // when using custom filesystem volumes. LXD will create the filesystem // for these volumes, and use the mount options. When attaching a regular block volume to a VM, // these are not mounted by LXD and therefore don't need these config keys. - if vol.IsVMBlock() || vol.volType == VolumeTypeCustom && vol.contentType == ContentTypeBlock { + if vol.volType == VolumeTypeCustom && vol.contentType == ContentTypeBlock { delete(commonRules, "block.filesystem") delete(commonRules, "block.mount_options") } diff --git a/lxd/storage/drivers/driver_lvm_volumes.go b/lxd/storage/drivers/driver_lvm_volumes.go index ee5b9d8122b0..134bca61617a 100644 --- a/lxd/storage/drivers/driver_lvm_volumes.go +++ b/lxd/storage/drivers/driver_lvm_volumes.go @@ -329,7 +329,7 @@ func (d *lvm) ValidateVolume(vol Volume, removeUnknownKeys bool) error { // when using custom filesystem volumes. LXD will create the filesystem // for these volumes, and use the mount options. When attaching a regular block volume to a VM, // these are not mounted by LXD and therefore don't need these config keys. - if vol.IsVMBlock() || vol.volType == VolumeTypeCustom && vol.contentType == ContentTypeBlock { + if vol.volType == VolumeTypeCustom && vol.contentType == ContentTypeBlock { delete(commonRules, "block.filesystem") delete(commonRules, "block.mount_options") } diff --git a/lxd/storage/drivers/driver_powerflex_volumes.go b/lxd/storage/drivers/driver_powerflex_volumes.go index fe0764452876..a4157aa10fe9 100644 --- a/lxd/storage/drivers/driver_powerflex_volumes.go +++ b/lxd/storage/drivers/driver_powerflex_volumes.go @@ -487,7 +487,7 @@ func (d *powerflex) ValidateVolume(vol Volume, removeUnknownKeys bool) error { // when using custom filesystem volumes. LXD will create the filesystem // for these volumes, and use the mount options. When attaching a regular block volume to a VM, // these are not mounted by LXD and therefore don't need these config keys. - if vol.IsVMBlock() || vol.volType == VolumeTypeCustom && vol.contentType == ContentTypeBlock { + if vol.volType == VolumeTypeCustom && vol.contentType == ContentTypeBlock { delete(commonRules, "block.filesystem") delete(commonRules, "block.mount_options") }