Skip to content

Commit 1e8476d

Browse files
committed
CLOUDSTACK-8140: CS fails to start after secstorage/consoleproxy.service.offering is set to uuid
(cherry picked from commit 84c44b6)
1 parent 744c1a1 commit 1e8476d

4 files changed

Lines changed: 26 additions & 20 deletions

File tree

server/src/com/cloud/configuration/Config.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,18 +1783,18 @@ public enum Config {
17831783
ConsoleProxyServiceOffering(
17841784
"Advanced",
17851785
ManagementServer.class,
1786-
Long.class,
1786+
String.class,
17871787
"consoleproxy.service.offering",
17881788
null,
17891789
"Uuid of the service offering used by console proxy; if NULL - system offering will be used",
17901790
null),
17911791
SecondaryStorageServiceOffering(
17921792
"Advanced",
17931793
ManagementServer.class,
1794-
Long.class,
1794+
String.class,
17951795
"secstorage.service.offering",
17961796
null,
1797-
"Service offering used by secondary storage; if NULL - system offering will be used",
1797+
"Uuid of the service offering used by secondary storage; if NULL - system offering will be used",
17981798
null),
17991799
HaTag("Advanced", ManagementServer.class, String.class, "ha.tag", null, "HA tag defining that the host marked with this tag can be used for HA purposes only", null),
18001800
ImplicitHostTags(

server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
import com.cloud.network.dao.NetworkDao;
9292
import com.cloud.network.dao.NetworkVO;
9393
import com.cloud.network.rules.RulesManager;
94-
import com.cloud.offering.DiskOffering;
9594
import com.cloud.offering.NetworkOffering;
9695
import com.cloud.offering.ServiceOffering;
9796
import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -105,7 +104,6 @@
105104
import com.cloud.storage.StoragePoolStatus;
106105
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
107106
import com.cloud.storage.VMTemplateVO;
108-
import com.cloud.storage.dao.DiskOfferingDao;
109107
import com.cloud.storage.dao.VMTemplateDao;
110108
import com.cloud.user.Account;
111109
import com.cloud.user.AccountManager;
@@ -196,8 +194,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
196194
@Inject
197195
private ServiceOfferingDao _offeringDao;
198196
@Inject
199-
private DiskOfferingDao _diskOfferingDao;
200-
@Inject
201197
private NetworkOfferingDao _networkOfferingDao;
202198
@Inject
203199
private PrimaryDataStoreDao _storagePoolDao;
@@ -1254,13 +1250,15 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
12541250
//check if there is a default service offering configured
12551251
String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());
12561252
if (cpvmSrvcOffIdStr != null) {
1257-
DiskOffering diskOffering = _diskOfferingDao.findByUuid(cpvmSrvcOffIdStr);
1258-
if (diskOffering == null) {
1259-
diskOffering = _diskOfferingDao.findById(Long.parseLong(cpvmSrvcOffIdStr));
1253+
_serviceOffering = _offeringDao.findByUuid(cpvmSrvcOffIdStr);
1254+
if (_serviceOffering == null) {
1255+
try {
1256+
_serviceOffering = _offeringDao.findById(Long.parseLong(cpvmSrvcOffIdStr));
1257+
} catch (NumberFormatException ex) {
1258+
s_logger.debug("The system service offering specified by global config is not id, but uuid=" + cpvmSrvcOffIdStr + " for console proxy vm");
1259+
}
12601260
}
1261-
if (diskOffering != null) {
1262-
_serviceOffering = _offeringDao.findById(diskOffering.getId());
1263-
} else {
1261+
if (_serviceOffering == null) {
12641262
s_logger.warn("Can't find system service offering specified by global config, uuid=" + cpvmSrvcOffIdStr + " for console proxy vm");
12651263
}
12661264
}

services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,20 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
842842
//check if there is a default service offering configured
843843
String ssvmSrvcOffIdStr = configs.get(Config.SecondaryStorageServiceOffering.key());
844844
if (ssvmSrvcOffIdStr != null) {
845-
Long ssvmSrvcOffId = Long.parseLong(ssvmSrvcOffIdStr);
846-
_serviceOffering = _offeringDao.findById(ssvmSrvcOffId);
847-
if (_serviceOffering == null || !_serviceOffering.getSystemUse()) {
848-
String msg = "Can't find system service offering id=" + ssvmSrvcOffId + " for secondary storage vm";
849-
s_logger.error(msg);
850-
throw new ConfigurationException(msg);
845+
_serviceOffering = _offeringDao.findByUuid(ssvmSrvcOffIdStr);
846+
if (_serviceOffering == null) {
847+
try {
848+
_serviceOffering = _offeringDao.findById(Long.parseLong(ssvmSrvcOffIdStr));
849+
} catch (NumberFormatException ex) {
850+
s_logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm");
851+
}
851852
}
852-
} else {
853+
if (_serviceOffering == null) {
854+
s_logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm");
855+
}
856+
}
857+
858+
if(_serviceOffering == null || !_serviceOffering.getSystemUse()){
853859
int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE);
854860
int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ);
855861
_useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));

setup/db/db/schema-442to450.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,3 +990,5 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis
990990

991991
INSERT IGNORE INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `default_value`, `description`) VALUES ('Advanced', 'DEFAULT', 'ManagementServer', 'xen.heartbeat.timeout' , '180', '120', 'Timeout value to send to the xenheartbeat script for guarding the self fencing functionality');
992992

993+
UPDATE `cloud`.`configuration` SET description='Uuid of the service offering used by secondary storage; if NULL - system offering will be used' where name='secstorage.service.offering';
994+

0 commit comments

Comments
 (0)