From ef02d1ae8736ec635d3178309864fe67c5937ec8 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Mon, 20 Aug 2012 11:10:28 -0700 Subject: [PATCH] add recreate.systemvm.enabled parameter to control recreating systemvm --- server/src/com/cloud/configuration/Config.java | 1 + .../consoleproxy/AgentBasedConsoleProxyManager.java | 8 -------- .../cloud/consoleproxy/ConsoleProxyManagerImpl.java | 8 -------- .../network/lb/ElasticLoadBalancerManagerImpl.java | 8 -------- .../router/VirtualNetworkApplianceManagerImpl.java | 13 ------------- server/src/com/cloud/storage/StorageManager.java | 2 +- .../src/com/cloud/storage/StorageManagerImpl.java | 9 +++++++-- .../secondary/SecondaryStorageManagerImpl.java | 9 --------- server/src/com/cloud/vm/UserVmManagerImpl.java | 7 ------- server/src/com/cloud/vm/VirtualMachineGuru.java | 2 -- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 10 ++-------- server/test/com/cloud/vm/MockUserVmManagerImpl.java | 8 -------- 12 files changed, 11 insertions(+), 74 deletions(-) diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index e4c7362c37e..d5306c2561b 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -225,6 +225,7 @@ public enum Config { SortKeyAlgorithm("Advanced", ManagementServer.class, Boolean.class, "sortkey.algorithm", "false", "Sort algorithm for those who use sort key(template, disk offering, service offering, network offering), true means ascending sort while false means descending sort", null), EnableEC2API("Advanced", ManagementServer.class, Boolean.class, "enable.ec2.api", "false", "enable EC2 API on CloudStack", null), EnableS3API("Advanced", ManagementServer.class, Boolean.class, "enable.s3.api", "false", "enable Amazon S3 API on CloudStack", null), + RecreateSystemVmEnabled("Advanced", ManagementServer.class, Boolean.class, "recreate.systemvm.enabled", "false", "If true, will recreate system vm root disk whenever starting system vm", "true,false"), // Ovm OvmPublicNetwork("Hidden", ManagementServer.class, String.class, "ovm.public.network.device", null, "Specify the public bridge on host for public network", null), diff --git a/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java index f94baa81e14..3c6716ca64d 100755 --- a/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java +++ b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java @@ -367,12 +367,4 @@ public class AgentBasedConsoleProxyManager implements ConsoleProxyManager, Virtu @Override public void prepareStop(VirtualMachineProfile profile) { } - - @Override - public boolean recreateNeeded( - VirtualMachineProfile profile, long hostId, - Commands cmds, ReservationContext context) { - // TODO Auto-generated method stub - return false; - } } diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 8e8fdf19bc3..28e8fb37a07 100755 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -2010,12 +2010,4 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx @Override public void prepareStop(VirtualMachineProfile profile) { } - - @Override - public boolean recreateNeeded( - VirtualMachineProfile profile, long hostId, - Commands cmds, ReservationContext context) { - // TODO Auto-generated method stub - return false; - } } diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 037ce5830a4..e5cdcd18fb7 100644 --- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -1003,12 +1003,4 @@ public class ElasticLoadBalancerManagerImpl implements public void prepareStop(VirtualMachineProfile profile) { } - - @Override - public boolean recreateNeeded( - VirtualMachineProfile profile, long hostId, - Commands cmds, ReservationContext context) { - // TODO Auto-generated method stub - return false; - } } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 4182c29c19e..d850ad3b75d 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -3477,17 +3477,4 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian } } } - - @Override - public boolean recreateNeeded( - VirtualMachineProfile profile, long hostId, - Commands cmds, ReservationContext context) { - // asssume that if failed to ssh into router, meaning router is crashed - CheckSshAnswer answer = (CheckSshAnswer) cmds.getAnswer("checkSsh"); - if (answer == null || !answer.getResult()) { - return true; - } - - return false; - } } diff --git a/server/src/com/cloud/storage/StorageManager.java b/server/src/com/cloud/storage/StorageManager.java index b8f89fa766e..386d8c7a8e9 100755 --- a/server/src/com/cloud/storage/StorageManager.java +++ b/server/src/com/cloud/storage/StorageManager.java @@ -176,7 +176,7 @@ public interface StorageManager extends StorageService, Manager { void createCapacityEntry(StoragePoolVO storagePool, short capacityType, long allocated); - void prepare(VirtualMachineProfile vm, DeployDestination dest, boolean recreate) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException; + void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException; void release(VirtualMachineProfile profile); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 25ab1ed0ae3..e64d129e69f 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -348,6 +348,8 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag private int _customDiskOfferingMinSize = 1; private int _customDiskOfferingMaxSize = 1024; + private boolean _recreateSystemVmEnabled; + public boolean share(VMInstanceVO vm, List vols, HostVO host, boolean cancelPreviousShare) throws StorageUnavailableException { // if pool is in maintenance and it is the ONLY pool available; reject @@ -954,6 +956,9 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag String time = configs.get("storage.cleanup.interval"); _storageCleanupInterval = NumbersUtil.parseInt(time, 86400); + value = configDao.getValue(Config.RecreateSystemVmEnabled.key()); + _recreateSystemVmEnabled = Boolean.parseBoolean(value); + s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", template cleanup enabled: " + _templateCleanupEnabled); String workers = configs.get("expunge.workers"); @@ -3192,7 +3197,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag } @Override - public void prepare(VirtualMachineProfile vm, DeployDestination dest, boolean recreate) throws StorageUnavailableException, InsufficientStorageCapacityException { + public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException { if (dest == null) { if (s_logger.isDebugEnabled()) { @@ -3204,7 +3209,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag if (s_logger.isDebugEnabled()) { s_logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm); } - + boolean recreate = _recreateSystemVmEnabled; List recreateVols = new ArrayList(vols.size()); for (VolumeVO vol : vols) { diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index ec7f3e14e89..e93be77d8ef 100755 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -1467,13 +1467,4 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V public void prepareStop(VirtualMachineProfile profile) { } - - @Override - public boolean recreateNeeded( - VirtualMachineProfile profile, long hostId, - Commands cmds, ReservationContext context) { - // TODO Auto-generated method stub - return false; - } - } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 2ca94e22402..8869412e52d 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -3796,11 +3796,4 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager @Override public void prepareStop(VirtualMachineProfile profile) { } - @Override - public boolean recreateNeeded(VirtualMachineProfile profile, - long hostId, Commands cmds, ReservationContext context) { - // TODO Auto-generated method stub - return false; - } - } diff --git a/server/src/com/cloud/vm/VirtualMachineGuru.java b/server/src/com/cloud/vm/VirtualMachineGuru.java index c3d8cc76f48..82e42dd2af7 100644 --- a/server/src/com/cloud/vm/VirtualMachineGuru.java +++ b/server/src/com/cloud/vm/VirtualMachineGuru.java @@ -65,8 +65,6 @@ public interface VirtualMachineGuru { void finalizeExpunge(T vm); - boolean recreateNeeded(VirtualMachineProfile profile, long hostId, Commands cmds, ReservationContext context); - /** * Returns the id parsed from the name. If it cannot parse the name, * then return null. This method is used to determine if this is diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 26f78b3fd50..69c931dcb5b 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -652,7 +652,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene DataCenterDeployment originalPlan = plan; int retry = _retry; - boolean recreate = false; while (retry-- != 0) { // It's != so that it can match -1. if(reuseVolume){ @@ -747,8 +746,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene } _networkMgr.prepare(vmProfile, dest, ctx); if (vm.getHypervisorType() != HypervisorType.BareMetal) { - _storageMgr.prepare(vmProfile, dest, recreate); - recreate = false; + _storageMgr.prepare(vmProfile, dest); } //since StorageMgr succeeded in volume creation, reuse Volume for further tries until current cluster has capacity if(!reuseVolume){ @@ -808,11 +806,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene _haMgr.scheduleStop(vm, destHostId, WorkType.ForceStop); throw new ExecutionException("Unable to stop " + vm + " so we are unable to retry the start operation"); } - if (vmGuru.recreateNeeded(vmProfile, destHostId, cmds, ctx)) { - recreate = true; - } else { - throw new ExecutionException("Unable to start " + vm + " due to error in finalizeStart, not retrying"); - } + throw new ExecutionException("Unable to start " + vm + " due to error in finalizeStart, not retrying"); } } s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + (startAnswer == null ? " no start answer" : startAnswer.getDetails())); diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java index 90ab35ff6a2..9d4f0ea69a7 100644 --- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java +++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java @@ -288,14 +288,6 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana return null; } - - @Override - public boolean recreateNeeded(VirtualMachineProfile profile, - long hostId, Commands cmds, ReservationContext context) { - // TODO Auto-generated method stub - return false; - } - @Override public UserVm startVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { // TODO Auto-generated method stub