This is an automated email from the ASF dual-hosted git repository.

nvazquez pushed a commit to branch 4.17
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.17 by this push:
     new 9b50e417f7 Add upgrade path for 4.17.1
9b50e417f7 is described below

commit 9b50e417f7760553b763990d6eedb43173e85832
Author: nvazquez <[email protected]>
AuthorDate: Mon Jun 6 12:33:19 2022 -0300

    Add upgrade path for 4.17.1
---
 .../com/cloud/upgrade/DatabaseUpgradeChecker.java  |  2 ++
 .../com/cloud/upgrade/dao/Upgrade41610to41700.java |  2 +-
 ...e41610to41700.java => Upgrade41700to41710.java} | 38 +++-------------------
 .../META-INF/db/schema-41700to41710-cleanup.sql    | 20 ++++++++++++
 .../resources/META-INF/db/schema-41700to41710.sql  | 20 ++++++++++++
 5 files changed, 48 insertions(+), 34 deletions(-)

diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java 
b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
index 1a189c0d29..e44cc33d6f 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@ -32,6 +32,7 @@ import javax.inject.Inject;
 import com.cloud.upgrade.dao.Upgrade41510to41520;
 import com.cloud.upgrade.dao.Upgrade41600to41610;
 import com.cloud.upgrade.dao.Upgrade41610to41700;
+import com.cloud.upgrade.dao.Upgrade41700to41710;
 import org.apache.cloudstack.utils.CloudStackVersion;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
@@ -205,6 +206,7 @@ public class DatabaseUpgradeChecker implements 
SystemIntegrityChecker {
                 .next("4.15.2.0", new Upgrade41520to41600())
                 .next("4.16.0.0", new Upgrade41600to41610())
                 .next("4.16.1.0", new Upgrade41610to41700())
+                .next("4.17.0.0", new Upgrade41700to41710())
                 .build();
     }
 
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 a925e6dc3e..be1e42cb5d 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
@@ -30,7 +30,7 @@ import java.util.UUID;
 
 public class Upgrade41610to41700 implements DbUpgrade, 
DbUpgradeSystemVmTemplate {
 
-    final static Logger LOG = Logger.getLogger(Upgrade41610to41700.class);
+    final static Logger LOG = Logger.getLogger(Upgrade41700to41710.class);
     private SystemVmTemplateRegistration systemVmTemplateRegistration;
 
     @Override
diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java 
b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41700to41710.java
similarity index 62%
copy from 
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java
copy to 
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41700to41710.java
index a925e6dc3e..6841e7de3b 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41610to41700.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41700to41710.java
@@ -21,26 +21,21 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import org.apache.log4j.Logger;
 
 import java.io.InputStream;
-import java.math.BigInteger;
 import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.UUID;
 
-public class Upgrade41610to41700 implements DbUpgrade, 
DbUpgradeSystemVmTemplate {
+public class Upgrade41700to41710 implements DbUpgrade, 
DbUpgradeSystemVmTemplate {
 
     final static Logger LOG = Logger.getLogger(Upgrade41610to41700.class);
     private SystemVmTemplateRegistration systemVmTemplateRegistration;
 
     @Override
     public String[] getUpgradableVersionRange() {
-        return new String[] {"4.16.1.0", "4.17.0.0"};
+        return new String[] {"4.17.0.0", "4.17.1.0"};
     }
 
     @Override
     public String getUpgradedVersion() {
-        return "4.17.0.0";
+        return "4.17.1.0";
     }
 
     @Override
@@ -50,7 +45,7 @@ public class Upgrade41610to41700 implements DbUpgrade, 
DbUpgradeSystemVmTemplate
 
     @Override
     public InputStream[] getPrepareScripts() {
-        final String scriptFile = "META-INF/db/schema-41610to41700.sql";
+        final String scriptFile = "META-INF/db/schema-41700to41710.sql";
         final InputStream script = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
         if (script == null) {
             throw new CloudRuntimeException("Unable to find " + scriptFile);
@@ -61,12 +56,11 @@ public class Upgrade41610to41700 implements DbUpgrade, 
DbUpgradeSystemVmTemplate
 
     @Override
     public void performDataMigration(Connection conn) {
-        fixWrongPoolUuid(conn);
     }
 
     @Override
     public InputStream[] getCleanupScripts() {
-        final String scriptFile = 
"META-INF/db/schema-41610to41700-cleanup.sql";
+        final String scriptFile = 
"META-INF/db/schema-41700to41710-cleanup.sql";
         final InputStream script = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
         if (script == null) {
             throw new CloudRuntimeException("Unable to find " + scriptFile);
@@ -89,26 +83,4 @@ public class Upgrade41610to41700 implements DbUpgrade, 
DbUpgradeSystemVmTemplate
             throw new CloudRuntimeException("Failed to find / register 
SystemVM template(s)");
         }
     }
-
-    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()) {
-            PreparedStatement updateStmt = conn.prepareStatement("update 
storage_pool set uuid = ? where id = ?");
-            while (rs.next()) {
-                    UUID poolUuid = new UUID(
-                            new BigInteger(rs.getString(2).substring(0, 16), 
16).longValue(),
-                            new BigInteger(rs.getString(2).substring(16), 
16).longValue()
-                    );
-                    updateStmt.setLong(2, rs.getLong(1));
-                    updateStmt.setString(1, poolUuid.toString());
-                    updateStmt.addBatch();
-            }
-            updateStmt.executeBatch();
-        } catch (SQLException ex) {
-            String errorMsg = "fixWrongPoolUuid:Exception while updating 
faulty pool uuids";
-            LOG.error(errorMsg,ex);
-            throw new CloudRuntimeException(errorMsg, ex);
-        }
-    }
 }
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-41700to41710-cleanup.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-41700to41710-cleanup.sql
new file mode 100644
index 0000000000..667168bc83
--- /dev/null
+++ 
b/engine/schema/src/main/resources/META-INF/db/schema-41700to41710-cleanup.sql
@@ -0,0 +1,20 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade cleanup from 4.16.1.0 to 4.17.0.0
+--;
\ No newline at end of file
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql
new file mode 100644
index 0000000000..e6139cb175
--- /dev/null
+++ b/engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql
@@ -0,0 +1,20 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade from 4.17.0.0 to 4.17.1.0
+--;
\ No newline at end of file

Reply via email to