-
Notifications
You must be signed in to change notification settings - Fork 1.3k
server: destroy ssvm, cpvm on last host maintenance #4644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f498394
b1f74bf
620c9c5
cb80c1e
f615808
3e1b992
79adcb8
da67494
87c96ae
17edecb
092ee8f
438f4e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1006,6 +1006,13 @@ private void allocCapacity(long dataCenterId) { | |
| } | ||
|
|
||
| public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) { | ||
| List <HostVO> hosts = _hostDao.listByDataCenterId(dataCenterId); | ||
| if (CollectionUtils.isEmpty(hosts)) { | ||
| if (s_logger.isDebugEnabled()) { | ||
| s_logger.debug("Zone " + dataCenterId + " has no host available which is enabled and in Up state"); | ||
| } | ||
| return false; | ||
| } | ||
|
Comment on lines
+1009
to
+1015
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the exact same code as inSecondaryStorageManagerImpl.isZoneReady() can you factor out and reuse? |
||
| ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId); | ||
| if (zoneHostInfo != null && isZoneHostReady(zoneHostInfo)) { | ||
| VMTemplateVO template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,9 +16,32 @@ | |||||
| // under the License. | ||||||
| package com.cloud.ha; | ||||||
|
|
||||||
| import java.util.ArrayList; | ||||||
| import java.util.Date; | ||||||
| import java.util.HashMap; | ||||||
| import java.util.List; | ||||||
| import java.util.Map; | ||||||
| import java.util.concurrent.Executors; | ||||||
| import java.util.concurrent.ScheduledExecutorService; | ||||||
| import java.util.concurrent.TimeUnit; | ||||||
|
|
||||||
| import javax.inject.Inject; | ||||||
| import javax.naming.ConfigurationException; | ||||||
|
|
||||||
| import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; | ||||||
| import org.apache.cloudstack.framework.config.ConfigKey; | ||||||
| import org.apache.cloudstack.framework.config.Configurable; | ||||||
| import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | ||||||
| import org.apache.cloudstack.managed.context.ManagedContext; | ||||||
| import org.apache.cloudstack.managed.context.ManagedContextRunnable; | ||||||
| import org.apache.cloudstack.management.ManagementServerHost; | ||||||
| import org.apache.log4j.Logger; | ||||||
| import org.apache.log4j.NDC; | ||||||
|
|
||||||
| import com.cloud.agent.AgentManager; | ||||||
| import com.cloud.alert.AlertManager; | ||||||
| import com.cloud.cluster.ClusterManagerListener; | ||||||
| import com.cloud.consoleproxy.ConsoleProxyManager; | ||||||
| import com.cloud.dc.ClusterDetailsDao; | ||||||
| import com.cloud.dc.DataCenterVO; | ||||||
| import com.cloud.dc.HostPodVO; | ||||||
|
|
@@ -46,37 +69,16 @@ | |||||
| import com.cloud.storage.StorageManager; | ||||||
| import com.cloud.storage.dao.GuestOSCategoryDao; | ||||||
| import com.cloud.storage.dao.GuestOSDao; | ||||||
| import com.cloud.storage.secondary.SecondaryStorageVmManager; | ||||||
| import com.cloud.user.AccountManager; | ||||||
| import com.cloud.utils.component.ManagerBase; | ||||||
| import com.cloud.utils.concurrency.NamedThreadFactory; | ||||||
| import com.cloud.utils.exception.CloudRuntimeException; | ||||||
| import com.cloud.vm.VMInstanceVO; | ||||||
| import com.cloud.vm.VirtualMachine; | ||||||
| import com.cloud.vm.VirtualMachine.State; | ||||||
| import com.cloud.vm.VirtualMachineManager; | ||||||
| import com.cloud.vm.VirtualMachineProfile; | ||||||
| import com.cloud.vm.dao.VMInstanceDao; | ||||||
| import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; | ||||||
| import org.apache.cloudstack.framework.config.ConfigKey; | ||||||
| import org.apache.cloudstack.framework.config.Configurable; | ||||||
| import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | ||||||
| import org.apache.cloudstack.managed.context.ManagedContext; | ||||||
| import org.apache.cloudstack.managed.context.ManagedContextRunnable; | ||||||
| import org.apache.cloudstack.management.ManagementServerHost; | ||||||
| import org.apache.log4j.Logger; | ||||||
| import org.apache.log4j.NDC; | ||||||
|
|
||||||
| import java.util.ArrayList; | ||||||
| import java.util.Date; | ||||||
| import java.util.HashMap; | ||||||
| import java.util.List; | ||||||
| import java.util.Map; | ||||||
| import java.util.concurrent.Executors; | ||||||
| import java.util.concurrent.ScheduledExecutorService; | ||||||
| import java.util.concurrent.TimeUnit; | ||||||
|
|
||||||
| import javax.inject.Inject; | ||||||
| import javax.naming.ConfigurationException; | ||||||
|
|
||||||
| /** | ||||||
| * HighAvailabilityManagerImpl coordinates the HA process. VMs are registered with the HA Manager for HA. The request is stored | ||||||
|
|
@@ -125,9 +127,12 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements Configur | |||||
| HostPodDao _podDao; | ||||||
| @Inject | ||||||
| ClusterDetailsDao _clusterDetailsDao; | ||||||
|
|
||||||
| @Inject | ||||||
| ServiceOfferingDao _serviceOfferingDao; | ||||||
| @Inject | ||||||
| private ConsoleProxyManager consoleProxyManager; | ||||||
| @Inject | ||||||
| private SecondaryStorageVmManager secondaryStorageVmManager; | ||||||
|
|
||||||
| long _serverId; | ||||||
|
|
||||||
|
|
@@ -680,31 +685,51 @@ public void cancelDestroy(VMInstanceVO vm, Long hostId) { | |||||
| _haDao.delete(vm.getId(), WorkType.Destroy); | ||||||
| } | ||||||
|
|
||||||
| private void stopVMWithCleanup(VirtualMachine vm, VirtualMachine.State state) throws OperationTimedoutException, ResourceUnavailableException { | ||||||
| if (VirtualMachine.State.Running.equals(state)) { | ||||||
| _itMgr.advanceStop(vm.getUuid(), true); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private void destroyVM(VirtualMachine vm, boolean expunge) throws OperationTimedoutException, AgentUnavailableException { | ||||||
| s_logger.info("Destroying " + vm.toString()); | ||||||
| if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) { | ||||||
| consoleProxyManager.destroyProxy(vm.getId()); | ||||||
| } else if (VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType())) { | ||||||
| secondaryStorageVmManager.destroySecStorageVm(vm.getId()); | ||||||
| } else { | ||||||
| _itMgr.destroy(vm.getUuid(), expunge); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| protected Long destroyVM(final HaWorkVO work) { | ||||||
| final VirtualMachine vm = _itMgr.findById(work.getInstanceId()); | ||||||
| s_logger.info("Destroying " + vm.toString()); | ||||||
| if (vm == null) { | ||||||
| s_logger.info("No longer can find VM " + work.getInstanceId() + ". Throwing away " + work); | ||||||
| return null; | ||||||
| } | ||||||
| boolean expunge = VirtualMachine.Type.SecondaryStorageVm.equals(vm.getType()) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sureshanaparti I think |
||||||
| || VirtualMachine.Type.ConsoleProxy.equals(vm.getType()); | ||||||
| if (!expunge && VirtualMachine.State.Destroyed.equals(work.getPreviousState())) { | ||||||
| s_logger.info("VM " + vm.getUuid() + " already in " + vm.getState() + " state. Throwing away " + work); | ||||||
| return null; | ||||||
| } | ||||||
| try { | ||||||
| if (vm.getState() != State.Destroyed) { | ||||||
| s_logger.info("VM is no longer in Destroyed state " + vm.toString()); | ||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
| if (vm.getHostId() != null) { | ||||||
| _itMgr.destroy(vm.getUuid(), false); | ||||||
| s_logger.info("Successfully destroy " + vm); | ||||||
| stopVMWithCleanup(vm, work.getPreviousState()); | ||||||
| if (!VirtualMachine.State.Expunging.equals(work.getPreviousState())) { | ||||||
| destroyVM(vm, expunge); | ||||||
| return null; | ||||||
| } else { | ||||||
| if (s_logger.isDebugEnabled()) { | ||||||
| s_logger.debug(vm + " has already been stopped"); | ||||||
| } | ||||||
| return null; | ||||||
| s_logger.info("VM " + vm.getUuid() + " still in " + vm.getState() + " state."); | ||||||
| } | ||||||
| } catch (final AgentUnavailableException e) { | ||||||
| s_logger.debug("Agnet is not available" + e.getMessage()); | ||||||
| s_logger.debug("Agent is not available" + e.getMessage()); | ||||||
| } catch (OperationTimedoutException e) { | ||||||
| s_logger.debug("operation timed out: " + e.getMessage()); | ||||||
| } catch (ConcurrentOperationException e) { | ||||||
| s_logger.debug("concurrent operation: " + e.getMessage()); | ||||||
| } catch (ResourceUnavailableException e) { | ||||||
| s_logger.debug("Resource unavailable: " + e.getMessage()); | ||||||
| } | ||||||
|
|
||||||
| return (System.currentTimeMillis() >> 10) + _stopRetryInterval; | ||||||
|
|
@@ -793,9 +818,8 @@ private long getRescheduleTime(WorkType workType) { | |||||
| case Stop: | ||||||
| case CheckStop: | ||||||
| case ForceStop: | ||||||
| return ((System.currentTimeMillis() >> 10) + _stopRetryInterval); | ||||||
| case Destroy: | ||||||
| return ((System.currentTimeMillis() >> 10) + _restartRetryInterval); | ||||||
| return ((System.currentTimeMillis() >> 10) + _stopRetryInterval); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shwstppr any reason to change to stop retry interval? if you want to keep it, move the case stmt after 'ForceStop'. Alternatively, you can use different config (may be "destroy.retry.interval") for destroy operation, and set its value to the current value in "restart.retry.interval" on upgrade.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sureshanaparti clubbed |
||||||
| } | ||||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shwstppr Is bypass host maintenance applicable for volumes in managed storage as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti yes, bypasshostmaintenance flag could be true for volumes in managed stores as well if the volume is of cpvm or ssvm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @shwstppr how other drivers set this parameter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sureshanaparti other drivers don't seem to be using
DeleteCommand.PS: SamplePrimaryDataStoreDriverImpl code is commented