Merge remote-tracking branch 'origin/4.17' into main

Due to merge conflict, and schema changes in 4.17 branch the previous
4.17.1->4.18.0 DB upgrade path class was renamed to 4.17.2->4.18.0

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2022-12-13 07:50:36 +00:00
commit 72b6ab9c51
6 changed files with 94 additions and 16 deletions

View File

@ -29,11 +29,6 @@ import java.util.Date;
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 com.cloud.upgrade.dao.Upgrade41710to41800;
import org.apache.cloudstack.utils.CloudStackVersion;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@ -76,7 +71,13 @@ import com.cloud.upgrade.dao.Upgrade41300to41310;
import com.cloud.upgrade.dao.Upgrade41310to41400;
import com.cloud.upgrade.dao.Upgrade41400to41500;
import com.cloud.upgrade.dao.Upgrade41500to41510;
import com.cloud.upgrade.dao.Upgrade41510to41520;
import com.cloud.upgrade.dao.Upgrade41520to41600;
import com.cloud.upgrade.dao.Upgrade41600to41610;
import com.cloud.upgrade.dao.Upgrade41610to41700;
import com.cloud.upgrade.dao.Upgrade41700to41710;
import com.cloud.upgrade.dao.Upgrade41710to41720;
import com.cloud.upgrade.dao.Upgrade41720to41800;
import com.cloud.upgrade.dao.Upgrade420to421;
import com.cloud.upgrade.dao.Upgrade421to430;
import com.cloud.upgrade.dao.Upgrade430to440;
@ -210,8 +211,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
.next("4.16.1.1", new Upgrade41610to41700())
.next("4.17.0.0", new Upgrade41700to41710())
.next("4.17.0.1", new Upgrade41700to41710())
.next("4.17.1.0", new Upgrade41710to41800())
.next("4.17.2.0", new Upgrade41710to41800())
.next("4.17.1.0", new Upgrade41710to41720())
.next("4.17.2.0", new Upgrade41720to41800())
.build();
}

View File

@ -34,7 +34,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
public class Upgrade41700to41710 implements DbUpgrade, DbUpgradeSystemVmTemplate {
final static Logger LOG = Logger.getLogger(Upgrade41610to41700.class);
final static Logger LOG = Logger.getLogger(Upgrade41700to41710.class);
private SystemVmTemplateRegistration systemVmTemplateRegistration;
private PrimaryDataStoreDao storageDao;

View File

@ -0,0 +1,75 @@
// 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.
package com.cloud.upgrade.dao;
import com.cloud.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.log4j.Logger;
import java.io.InputStream;
import java.sql.Connection;
public class Upgrade41710to41720 implements DbUpgrade, DbUpgradeSystemVmTemplate {
final static Logger LOG = Logger.getLogger(Upgrade41710to41720.class);
private SystemVmTemplateRegistration systemVmTemplateRegistration;
@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.17.1.0", "4.17.2.0"};
}
@Override
public String getUpgradedVersion() {
return "4.17.2.0";
}
@Override
public boolean supportsRollingUpgrade() {
return false;
}
@Override
public InputStream[] getPrepareScripts() {
return null;
}
@Override
public void performDataMigration(Connection conn) {
}
@Override
public InputStream[] getCleanupScripts() {
return null;
}
private void initSystemVmTemplateRegistration() {
systemVmTemplateRegistration = new SystemVmTemplateRegistration("");
}
@Override
public void updateSystemVmTemplates(Connection conn) {
LOG.debug("Updating System Vm template IDs");
initSystemVmTemplateRegistration();
try {
systemVmTemplateRegistration.updateSystemVmTemplates(conn);
} catch (Exception e) {
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
}
}
}

View File

@ -35,14 +35,15 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Upgrade41710to41800 implements DbUpgrade, DbUpgradeSystemVmTemplate {
public class Upgrade41720to41800 implements DbUpgrade, DbUpgradeSystemVmTemplate {
final static Logger LOG = Logger.getLogger(Upgrade41720to41800.class);
final static Logger LOG = Logger.getLogger(Upgrade41710to41800.class);
private SystemVmTemplateRegistration systemVmTemplateRegistration;
@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.17.1.0", "4.18.0.0"};
return new String[] {"4.17.2.0", "4.18.0.0"};
}
@Override
@ -57,7 +58,7 @@ public class Upgrade41710to41800 implements DbUpgrade, DbUpgradeSystemVmTemplate
@Override
public InputStream[] getPrepareScripts() {
final String scriptFile = "META-INF/db/schema-41710to41800.sql";
final String scriptFile = "META-INF/db/schema-41720to41800.sql";
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
if (script == null) {
throw new CloudRuntimeException("Unable to find " + scriptFile);
@ -74,7 +75,7 @@ public class Upgrade41710to41800 implements DbUpgrade, DbUpgradeSystemVmTemplate
@Override
public InputStream[] getCleanupScripts() {
final String scriptFile = "META-INF/db/schema-41710to41800-cleanup.sql";
final String scriptFile = "META-INF/db/schema-41720to41800-cleanup.sql";
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
if (script == null) {
throw new CloudRuntimeException("Unable to find " + scriptFile);

View File

@ -16,5 +16,5 @@
-- under the License.
--;
-- Schema upgrade cleanup from 4.17.1.0 to 4.18.0.0
--;
-- Schema upgrade cleanup from 4.17.2.0 to 4.18.0.0
--;

View File

@ -16,8 +16,9 @@
-- under the License.
--;
-- Schema upgrade from 4.17.1.0 to 4.18.0.0
-- Schema upgrade from 4.17.2.0 to 4.18.0.0
--;
-- Enable CPU cap for default system offerings;
UPDATE `cloud`.`service_offering` so
SET so.limit_cpu_use = 1