Skip to content

Commit df3dea5

Browse files
committed
CLOUDSTACK-6139: Fix regression, allow zone level systemvm localstorage config
From b3f18e7, the zone level systemvm local storage setting never worked as it needed to be moved to config depot. (cherry picked from commit 279efb0) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
1 parent fdea7eb commit df3dea5

9 files changed

Lines changed: 36 additions & 40 deletions

File tree

api/src/com/cloud/dc/DataCenter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@
1616
// under the License.
1717
package com.cloud.dc;
1818

19-
import java.util.Map;
20-
19+
import com.cloud.org.Grouping;
2120
import org.apache.cloudstack.acl.InfrastructureEntity;
2221
import org.apache.cloudstack.api.Identity;
2322
import org.apache.cloudstack.api.InternalIdentity;
23+
import org.apache.cloudstack.framework.config.ConfigKey;
2424

25-
import com.cloud.org.Grouping;
25+
import java.util.Map;
2626

2727
/**
2828
*
2929
*/
3030
public interface DataCenter extends InfrastructureEntity, Grouping, Identity, InternalIdentity {
31+
public static final String SystemVMUseLocalStorageCK = "system.vm.use.local.storage";
32+
public static final ConfigKey<Boolean> UseSystemVMLocalStorage = new ConfigKey<Boolean>(Boolean.class, SystemVMUseLocalStorageCK, "Advanced", "false",
33+
"Indicates whether to use local storage pools or shared storage pools for system VMs.", true, ConfigKey.Scope.Zone, null);
34+
3135
public enum NetworkType {
3236
Basic, Advanced,
3337
}

plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
290290
}
291291
_mgmtCidr = _configDao.getValue(Config.ManagementNetwork.key());
292292

293-
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
293+
boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK));
294294

295295
_elasticLbVmRamSize = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmMemory.key()), DEFAULT_ELB_VM_RAMSIZE);
296296
_elasticLbvmCpuMHz = NumbersUtil.parseInt(configs.get(Config.ElasticLoadBalancerVmCpuMhz.key()), DEFAULT_ELB_VM_CPU_MHZ);

plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
380380

381381
//if offering wasn't set, try to get the default one
382382
if (_internalLbVmOfferingId == 0L) {
383-
final boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
383+
final boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK));
384384
ServiceOfferingVO newOff =
385385
new ServiceOfferingVO("System Offering For Internal LB VM", 1, InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_RAMSIZE,
386386
InternalLoadBalancerVMManager.DEFAULT_INTERNALLB_VM_CPU_MHZ, null, null, true, null,

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,6 @@ public enum Config {
686686
"The mount point on the Management Server for Secondary Storage.",
687687
null),
688688
// UpgradeURL("Advanced", ManagementServer.class, String.class, "upgrade.url", "http://example.com:8080/client/agent/update.zip", "The upgrade URL is the URL of the management server that agents will connect to in order to automatically upgrade.", null),
689-
SystemVMUseLocalStorage(
690-
"Advanced",
691-
ManagementServer.class,
692-
Boolean.class,
693-
"system.vm.use.local.storage",
694-
"false",
695-
"Indicates whether to use local storage pools or shared storage pools for system VMs.",
696-
null, ConfigKey.Scope.Zone.toString()),
697689
SystemVMAutoReserveCapacity(
698690
"Advanced",
699691
ManagementServer.class,
@@ -2025,16 +2017,6 @@ public enum Config {
20252017
VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "1800", "In second, timeout for create vm snapshot", null),
20262018

20272019
CloudDnsName("Advanced", ManagementServer.class, String.class, "cloud.dns.name", null, "DNS name of the cloud for the GSLB service", null),
2028-
2029-
BlacklistedRoutes(
2030-
"Advanced",
2031-
VpcManager.class,
2032-
String.class,
2033-
"blacklisted.routes",
2034-
null,
2035-
"Routes that are blacklisted, can not be used for Static Routes creation for the VPC Private Gateway",
2036-
"routes",
2037-
ConfigKey.Scope.Zone.toString()),
20382020
InternalLbVmServiceOfferingId(
20392021
"Advanced",
20402022
ManagementServer.class,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,11 @@ public String updateConfiguration(long userId, String name, String category, Str
575575
} catch (Throwable e) {
576576
throw new CloudRuntimeException("Failed to update storage.network.device2 in host_details due to exception ", e);
577577
}
578-
} else if (Config.SystemVMUseLocalStorage.key().equalsIgnoreCase(name)) {
578+
} else if (DataCenter.SystemVMUseLocalStorageCK.equalsIgnoreCase(name)) {
579579
if (s_logger.isDebugEnabled()) {
580580
s_logger.debug("Config 'system.vm.use.local.storage' changed to value:" + value + ", need to update System VM offerings");
581581
}
582-
boolean useLocalStorage = Boolean.parseBoolean(_configDao.getValue(Config.SystemVMUseLocalStorage.key()));
582+
boolean useLocalStorage = Boolean.parseBoolean(_configDao.getValue(DataCenter.SystemVMUseLocalStorageCK));
583583
ServiceOfferingVO serviceOffering = _serviceOfferingDao.findByName(ServiceOffering.consoleProxyDefaultOffUniqueName);
584584
if (serviceOffering != null) {
585585
serviceOffering.setUseLocalStorage(useLocalStorage);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
12081208
_disableRpFilter = true;
12091209
}
12101210

1211-
value = configs.get(Config.SystemVMUseLocalStorage.key());
1211+
value = configs.get(DataCenter.SystemVMUseLocalStorageCK);
12121212
if (value != null && value.equalsIgnoreCase("true")) {
12131213
_useLvm = true;
12141214
}
@@ -1238,7 +1238,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
12381238

12391239
_itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);
12401240

1241-
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
1241+
boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK));
12421242

12431243
//check if there is a default service offering configured
12441244
String cpvmSrvcOffIdStr = configs.get(Config.ConsoleProxyServiceOffering.key());

server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
4646
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
4747
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
48+
import org.apache.cloudstack.framework.config.ConfigKey;
49+
import org.apache.cloudstack.framework.config.Configurable;
4850
import org.apache.cloudstack.framework.messagebus.MessageBus;
4951
import org.apache.cloudstack.framework.messagebus.MessageSubscriber;
5052
import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
@@ -132,7 +134,7 @@
132134

133135
@Local(value = {DeploymentPlanningManager.class})
134136
public class DeploymentPlanningManagerImpl extends ManagerBase implements DeploymentPlanningManager, Manager, Listener,
135-
StateListener<State, VirtualMachine.Event, VirtualMachine> {
137+
StateListener<State, VirtualMachine.Event, VirtualMachine>, Configurable {
136138

137139
private static final Logger s_logger = Logger.getLogger(DeploymentPlanningManagerImpl.class);
138140
@Inject
@@ -199,8 +201,6 @@ public void setHostAllocators(List<HostAllocator> hostAllocators) {
199201
@Inject
200202
protected StoragePoolHostDao _poolHostDao;
201203

202-
@Inject
203-
protected DataCenterDao _zoneDao;
204204
@Inject
205205
protected VolumeDao _volsDao;
206206
@Inject
@@ -762,6 +762,16 @@ public Boolean doInTransaction(TransactionStatus status) {
762762
return false;
763763
}
764764

765+
@Override
766+
public String getConfigComponentName() {
767+
return DeploymentPlanningManagerImpl.class.getSimpleName();
768+
}
769+
770+
@Override
771+
public ConfigKey<?>[] getConfigKeys() {
772+
return new ConfigKey<?>[] {DataCenter.UseSystemVMLocalStorage};
773+
}
774+
765775
class HostReservationReleaseChecker extends ManagedContextTimerTask {
766776
@Override
767777
protected void runInContext() {
@@ -1290,20 +1300,21 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo
12901300
DiskProfile diskProfile = new DiskProfile(toBeCreated, diskOffering, vmProfile.getHypervisorType());
12911301
boolean useLocalStorage = false;
12921302
if (vmProfile.getType() != VirtualMachine.Type.User) {
1293-
String ssvmUseLocalStorage = _configDao.getValue(Config.SystemVMUseLocalStorage.key());
1294-
1295-
DataCenterVO zone = _zoneDao.findById(plan.getDataCenterId());
1296-
1303+
DataCenterVO zone = _dcDao.findById(plan.getDataCenterId());
12971304
// It should not happen to have a "null" zone here. There can be NO instance if there is NO zone,
12981305
// so this part of the code would never be reached if no zone has been created.
1299-
//
13001306
// Added the check and the comment just to make it clear.
13011307
boolean zoneUsesLocalStorage = zone != null ? zone.isLocalStorageEnabled() : false;
1302-
1308+
boolean ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.value();
1309+
if (zone != null) {
1310+
ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.valueIn(plan.getDataCenterId());
1311+
}
1312+
s_logger.debug("Checking if we need local storage for systemvms is needed for zone id=" + plan.getDataCenterId() + " with system.vm.use.local.storage=" + ssvmUseLocalStorage);
13031313
// Local storage is used for the NON User VMs if, and only if, the Zone is marked to use local storage AND
13041314
// the global settings (ssvmUseLocalStorage) is set to true. Otherwise, the global settings won't be applied.
1305-
if (ssvmUseLocalStorage.equalsIgnoreCase("true") && zoneUsesLocalStorage) {
1315+
if (ssvmUseLocalStorage && zoneUsesLocalStorage) {
13061316
useLocalStorage = true;
1317+
s_logger.debug("SystemVMs will use local storage for zone id=" + plan.getDataCenterId());
13071318
}
13081319
} else {
13091320
useLocalStorage = diskOffering.getUseLocalStorage();

server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
631631

632632
_agentMgr.registerForHostEvents(new SshKeysDistriMonitor(_agentMgr, _hostDao, _configDao), true, false, false);
633633

634-
final boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
635-
634+
final boolean useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK));
636635
ServiceOfferingVO offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, ProvisioningType.THIN,
637636
useLocalStorage, true, null, true, VirtualMachine.Type.DomainRouter, true);
638637
offering.setUniqueName(ServiceOffering.routerDefaultOffUniqueName);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
875875
if(_serviceOffering == null || !_serviceOffering.getSystemUse()){
876876
int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE);
877877
int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ);
878-
_useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
878+
_useLocalStorage = Boolean.parseBoolean(configs.get(DataCenter.SystemVMUseLocalStorageCK));
879879
_serviceOffering =
880880
new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, ramSize, cpuFreq, null, null, false, null,
881881
Storage.ProvisioningType.THIN, _useLocalStorage, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true);

0 commit comments

Comments
 (0)