@@ -226,3 +226,60 @@ CREATE TABLE IF NOT EXISTS `cloud`.`instance_boot_group_details` (
226226 PRIMARY KEY (` id` ),
227227 CONSTRAINT ` fk_instance_boot_group_details__group_id` FOREIGN KEY (` boot_group_id` ) REFERENCES ` instance_boot_group` (` id` ) ON DELETE CASCADE
228228) ENGINE= InnoDB DEFAULT CHARSET= utf8mb4;
229+
230+ --
231+ -- Re-tag NetApp ONTAP iSCSI storage pools to the dedicated 'OntapiSCSI' pool type.
232+ --
233+ -- Up to and including 4.23.0.0 the NetApp ONTAP primary store driver registered its iSCSI
234+ -- pools under the generic 'Iscsi' StoragePoolType (originally meant for ZFS Comstar), because
235+ -- no NetApp-specific enum existed yet. 24.0.0.0 introduces 'OntapiSCSI' as a first-class pool
236+ -- type (see api/.../Storage.java::StoragePoolType) so that KVM path construction, the iSCSI
237+ -- cleanup monitor, the data-motion strategy and the UI can key off the pool type rather than
238+ -- having to probe storage_pool_details or storage_provider_name on every call.
239+ --
240+ -- These three UPDATE statements re-tag the existing rows for a NetApp ONTAP provider only
241+ -- (storage_provider_name = 'NetApp ONTAP', the string exposed as
242+ -- DataStoreProvider.ONTAP_PLUGIN_NAME). All three are naturally idempotent on re-run because
243+ -- they filter on the pre-migration value - a second attempt matches zero rows. Rows soft-
244+ -- deleted via `removed` are intentionally included so historical / un-deleted pools report
245+ -- the correct type.
246+ --
247+
248+ -- 1. The pool itself.
249+ UPDATE ` cloud` .` storage_pool`
250+ SET ` pool_type` = ' OntapiSCSI'
251+ WHERE ` storage_provider_name` = ' NetApp ONTAP'
252+ AND ` pool_type` = ' Iscsi' ;
253+
254+ -- 2. The denormalized copy on every volume that lives on such a pool.
255+ --
256+ -- The sp.pool_type IN ('Iscsi', 'OntapiSCSI') guard here is defense-in-depth, not a
257+ -- correctness requirement: it excludes volumes whose underlying storage_pool is NFS-backed
258+ -- NetApp ('NetworkFilesystem') even if, by some historical anomaly, their v.pool_type still
259+ -- reads 'Iscsi'. Flipping those to 'OntapiSCSI' would be wrong, so we gate on the pool's
260+ -- current type. The IN (...) form keeps the statement order-independent with statement 1.
261+ UPDATE ` cloud` .` volumes` v
262+ JOIN ` cloud` .` storage_pool` sp ON sp.` id` = v.` pool_id`
263+ SET v.` pool_type` = ' OntapiSCSI'
264+ WHERE sp.` storage_provider_name` = ' NetApp ONTAP'
265+ AND sp.` pool_type` IN (' Iscsi' , ' OntapiSCSI' )
266+ AND v.` pool_type` = ' Iscsi' ;
267+
268+ -- 3. Volume format realignment.
269+ --
270+ -- The ONTAP primary store driver on 24.0 returns ImageFormat.RAW for every iSCSI volume
271+ -- (OntapPrimaryDatastoreDriver::getFormat). On 4.23 volumes created against the generic
272+ -- 'Iscsi' pool type may have been persisted with the wrong format literal depending on which
273+ -- code path created them (template-backed, snapshot copies, migrated-from-NFS, etc). Force
274+ -- the full set to 'RAW' so that KVM / libvirt see the authoritative format on next grant.
275+ --
276+ -- sp.pool_type IN ('Iscsi', 'OntapiSCSI') makes this statement order-independent with
277+ -- statement 1: it works whether or not the pool has been rebranded yet. NFS-backed NetApp
278+ -- pools ('NetworkFilesystem') are deliberately excluded - they stay QCOW2.
279+ UPDATE ` cloud` .` volumes` v
280+ JOIN ` cloud` .` storage_pool` sp ON sp.` id` = v.` pool_id`
281+ SET v.` format` = ' RAW'
282+ WHERE sp.` storage_provider_name` = ' NetApp ONTAP'
283+ AND sp.` pool_type` IN (' Iscsi' , ' OntapiSCSI' )
284+ AND (v.` format` IS NULL OR v.` format` <> ' RAW' );
285+
0 commit comments