CLOUDSTACK-8140: CS fails to start after secstorage/consoleproxy.service.offering is set to uuid
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/84c44b63 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/84c44b63 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/84c44b63 Branch: refs/heads/vmware-disk-controllers Commit: 84c44b63140e8acf2336549040bda9c0a8f2ff66 Parents: 2c9cc1e Author: Wei Zhou <w.z...@tech.leaseweb.com> Authored: Tue Jan 6 10:23:44 2015 +0100 Committer: Wei Zhou <w.z...@tech.leaseweb.com> Committed: Tue Jan 6 10:23:44 2015 +0100 ---------------------------------------------------------------------- server/src/com/cloud/configuration/Config.java | 6 +++--- .../consoleproxy/ConsoleProxyManagerImpl.java | 18 ++++++++---------- .../SecondaryStorageManagerImpl.java | 20 +++++++++++++------- setup/db/db/schema-442to450.sql | 2 ++ 4 files changed, 26 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84c44b63/server/src/com/cloud/configuration/Config.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index af4da6a..f9e9bdd 100644 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -1804,7 +1804,7 @@ public enum Config { ConsoleProxyServiceOffering( "Advanced", ManagementServer.class, - Long.class, + String.class, "consoleproxy.service.offering", null, "Uuid of the service offering used by console proxy; if NULL - system offering will be used", @@ -1812,10 +1812,10 @@ public enum Config { SecondaryStorageServiceOffering( "Advanced", ManagementServer.class, - Long.class, + String.class, "secstorage.service.offering", null, - "Service offering used by secondary storage; if NULL - system offering will be used", + "Uuid of the service offering used by secondary storage; if NULL - system offering will be used", null), 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), ImplicitHostTags( http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84c44b63/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 65930aa..bb64fa3 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -91,7 +91,6 @@ import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; import com.cloud.network.rules.RulesManager; -import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering; import com.cloud.offering.ServiceOffering; import com.cloud.offerings.dao.NetworkOfferingDao; @@ -105,7 +104,6 @@ import com.cloud.storage.Storage; import com.cloud.storage.StoragePoolStatus; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.user.Account; import com.cloud.user.AccountManager; @@ -196,8 +194,6 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy @Inject private ServiceOfferingDao _offeringDao; @Inject - private DiskOfferingDao _diskOfferingDao; - @Inject private NetworkOfferingDao _networkOfferingDao; @Inject private PrimaryDataStoreDao _storagePoolDao; @@ -1267,13 +1263,15 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy //check if there is a default service offering configured String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key()); if (cpvmSrvcOffIdStr != null) { - DiskOffering diskOffering = _diskOfferingDao.findByUuid(cpvmSrvcOffIdStr); - if (diskOffering == null) { - diskOffering = _diskOfferingDao.findById(Long.parseLong(cpvmSrvcOffIdStr)); + _serviceOffering = _offeringDao.findByUuid(cpvmSrvcOffIdStr); + if (_serviceOffering == null) { + try { + _serviceOffering = _offeringDao.findById(Long.parseLong(cpvmSrvcOffIdStr)); + } catch (NumberFormatException ex) { + s_logger.debug("The system service offering specified by global config is not id, but uuid=" + cpvmSrvcOffIdStr + " for console proxy vm"); + } } - if (diskOffering != null) { - _serviceOffering = _offeringDao.findById(diskOffering.getId()); - } else { + if (_serviceOffering == null) { s_logger.warn("Can't find system service offering specified by global config, uuid=" + cpvmSrvcOffIdStr + " for console proxy vm"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84c44b63/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 3ba4242..ccf3dcd 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -853,14 +853,20 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar //check if there is a default service offering configured String ssvmSrvcOffIdStr = configs.get(Config.SecondaryStorageServiceOffering.key()); if (ssvmSrvcOffIdStr != null) { - Long ssvmSrvcOffId = Long.parseLong(ssvmSrvcOffIdStr); - _serviceOffering = _offeringDao.findById(ssvmSrvcOffId); - if (_serviceOffering == null || !_serviceOffering.getSystemUse()) { - String msg = "Can't find system service offering id=" + ssvmSrvcOffId + " for secondary storage vm"; - s_logger.error(msg); - throw new ConfigurationException(msg); + _serviceOffering = _offeringDao.findByUuid(ssvmSrvcOffIdStr); + if (_serviceOffering == null) { + try { + _serviceOffering = _offeringDao.findById(Long.parseLong(ssvmSrvcOffIdStr)); + } catch (NumberFormatException ex) { + s_logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); + } } - } else { + if (_serviceOffering == null) { + s_logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); + } + } + + if(_serviceOffering == null || !_serviceOffering.getSystemUse()){ int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE); int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ); _useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key())); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84c44b63/setup/db/db/schema-442to450.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql index b5006c2..9498481 100644 --- a/setup/db/db/schema-442to450.sql +++ b/setup/db/db/schema-442to450.sql @@ -1005,3 +1005,5 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis 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'); +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'; +