From 21b9ad10b3e8d56c805eb29ea0d940415eaf8ff4 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Wed, 17 Aug 2022 10:31:57 -0300 Subject: [PATCH 1/2] Fix SQL query for uuid wrong format --- .../main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java index a925e6dc3ef1..53cc4a3540b1 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java @@ -93,7 +93,7 @@ public void updateSystemVmTemplates(Connection conn) { public void fixWrongPoolUuid(Connection conn) { LOG.debug("Replacement of faulty pool uuids"); try (PreparedStatement pstmt = conn.prepareStatement("SELECT id,uuid FROM storage_pool " - + "WHERE uuid NOT LIKE \"%-%-%-%\" AND removed IS NULL;"); ResultSet rs = pstmt.executeQuery()) { + + "WHERE uuid NOT LIKE \"%-%-%-%\" AND removed IS NULL AND hypervisor = 'VMware';"); ResultSet rs = pstmt.executeQuery()) { PreparedStatement updateStmt = conn.prepareStatement("update storage_pool set uuid = ? where id = ?"); while (rs.next()) { UUID poolUuid = new UUID( From 95ca91d5e24ee34335bd373b081678d3c200408d Mon Sep 17 00:00:00 2001 From: nvazquez Date: Thu, 18 Aug 2022 07:41:27 -0300 Subject: [PATCH 2/2] Restrict the SQL to datastorecluster --- .../java/com/cloud/upgrade/dao/Upgrade41610to41700.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java index 53cc4a3540b1..7833a0c8d020 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java @@ -61,7 +61,7 @@ public InputStream[] getPrepareScripts() { @Override public void performDataMigration(Connection conn) { - fixWrongPoolUuid(conn); + fixWrongDatastoreClusterPoolUuid(conn); } @Override @@ -90,10 +90,11 @@ public void updateSystemVmTemplates(Connection conn) { } } - public void fixWrongPoolUuid(Connection conn) { - LOG.debug("Replacement of faulty pool uuids"); + public void fixWrongDatastoreClusterPoolUuid(Connection conn) { + LOG.debug("Replacement of faulty pool uuids on datastorecluster"); try (PreparedStatement pstmt = conn.prepareStatement("SELECT id,uuid FROM storage_pool " - + "WHERE uuid NOT LIKE \"%-%-%-%\" AND removed IS NULL AND hypervisor = 'VMware';"); ResultSet rs = pstmt.executeQuery()) { + + "WHERE uuid NOT LIKE \"%-%-%-%\" AND removed IS NULL " + + "AND pool_type = 'DatastoreCluster';"); ResultSet rs = pstmt.executeQuery()) { PreparedStatement updateStmt = conn.prepareStatement("update storage_pool set uuid = ? where id = ?"); while (rs.next()) { UUID poolUuid = new UUID(