Skip to content

Commit 50f311e

Browse files
committed
CLOUDSTACK-5928: disable host delta sync when new VM sync is enabled
1 parent 0679af3 commit 50f311e

4 files changed

Lines changed: 75 additions & 52 deletions

File tree

‎engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public void setHostAllocators(List<HostAllocator> _hostAllocators) {
337337

338338
// TODO, remove it after transient period is over
339339
static final ConfigKey<Boolean> VmJobEnabled = new ConfigKey<Boolean>("Advanced",
340-
Boolean.class, "vm.job.enabled", "false",
340+
Boolean.class, "vm.job.enabled", "true",
341341
"True to enable new VM sync model. false to use the old way", false);
342342

343343
static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced",
@@ -2944,12 +2944,14 @@ public boolean processCommands(long agentId, long seq, Command[] cmds) {
29442944
if (cmd instanceof PingRoutingCommand) {
29452945
PingRoutingCommand ping = (PingRoutingCommand)cmd;
29462946
if (ping.getNewStates() != null && ping.getNewStates().size() > 0) {
2947-
Commands commands = deltaHostSync(agentId, ping.getNewStates());
2948-
if (commands.size() > 0) {
2949-
try {
2950-
_agentMgr.send(agentId, commands, this);
2951-
} catch (final AgentUnavailableException e) {
2952-
s_logger.warn("Agent is now unavailable", e);
2947+
if (!VmJobEnabled.value()) {
2948+
Commands commands = deltaHostSync(agentId, ping.getNewStates());
2949+
if (commands.size() > 0) {
2950+
try {
2951+
_agentMgr.send(agentId, commands, this);
2952+
} catch (final AgentUnavailableException e) {
2953+
s_logger.warn("Agent is now unavailable", e);
2954+
}
29532955
}
29542956
}
29552957
}
@@ -3973,6 +3975,8 @@ private void HandlePowerStateReport(String subject, String senderAddress, Object
39733975
s_logger.warn("VM " + vmId + " no longer exists when processing VM state report");
39743976
}
39753977
} else {
3978+
s_logger.info("There is pending job working on the VM. vm id: " + vmId + ", postpone power-change report by resetting power-change counters");
3979+
39763980
// reset VM power state tracking so that we won't lost signal when VM has
39773981
// been translated to
39783982
_vmDao.resetVmPowerStateTracking(vmId);
@@ -3981,19 +3985,23 @@ private void HandlePowerStateReport(String subject, String senderAddress, Object
39813985

39823986
private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
39833987
//
3984-
// 1) handle left-over transitional VM states
3988+
// 1) handle left-over transitional VM states
39853989
// 2) handle out of band VM live migration
39863990
// 3) handle out of sync stationary states, marking VM from Stopped to Running with
39873991
// alert messages
39883992
//
39893993
switch (vm.getState()) {
39903994
case Starting:
3995+
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
3996+
39913997
try {
39923998
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
39933999
} catch (NoTransitionException e) {
39944000
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
39954001
}
39964002

4003+
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
4004+
39974005
// we need to alert admin or user about this risky state transition
39984006
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
39994007
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName()
@@ -4008,10 +4016,13 @@ private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
40084016
} catch (NoTransitionException e) {
40094017
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
40104018
}
4019+
40114020
break;
40124021

40134022
case Stopping:
40144023
case Stopped:
4024+
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
4025+
40154026
try {
40164027
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
40174028
} catch (NoTransitionException e) {
@@ -4020,6 +4031,8 @@ private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
40204031
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
40214032
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState()
40224033
+ " -> Running) from out-of-context transition. VM network environment may need to be reset");
4034+
4035+
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
40234036
break;
40244037

40254038
case Destroyed:
@@ -4029,11 +4042,13 @@ private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
40294042
break;
40304043

40314044
case Migrating:
4045+
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it");
40324046
try {
40334047
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId());
40344048
} catch (NoTransitionException e) {
40354049
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
40364050
}
4051+
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
40374052
break;
40384053

40394054
case Error:
@@ -4046,7 +4061,7 @@ private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
40464061

40474062
private void handlePowerOffReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
40484063

4049-
// 1) handle left-over transitional VM states
4064+
// 1) handle left-over transitional VM states
40504065
// 2) handle out of sync stationary states, schedule force-stop to release resources
40514066
//
40524067
switch (vm.getState()) {
@@ -4055,14 +4070,19 @@ private void handlePowerOffReportWithNoPendingJobsOnVM(VMInstanceVO vm) {
40554070
case Running:
40564071
case Stopped:
40574072
case Migrating:
4073+
s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-off report while there is no pending jobs on it");
40584074
try {
40594075
stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOffReport, vm.getPowerHostId());
40604076
} catch (NoTransitionException e) {
40614077
s_logger.warn("Unexpected VM state transition exception, race-condition?", e);
40624078
}
4079+
40634080
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(),
40644081
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState()
40654082
+ " -> Stopped) from out-of-context transition.");
4083+
4084+
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Stopped state according to power-on report from hypervisor");
4085+
40664086
// TODO: we need to forcely release all resource allocation
40674087
break;
40684088

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java‎

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132
public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener, VmwareDatacenterService {
133133
private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class);
134134

135-
private static final int STARTUP_DELAY = 60000; // 60 seconds
136-
private static final long DEFAULT_HOST_SCAN_INTERVAL = 600000; // every 10 minutes
135+
private static final int STARTUP_DELAY = 60000; // 60 seconds
136+
private static final long DEFAULT_HOST_SCAN_INTERVAL = 600000; // every 10 minutes
137137

138138
private long _hostScanInterval = DEFAULT_HOST_SCAN_INTERVAL;
139139
int _timeout;
@@ -173,7 +173,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
173173
String _managemetPortGroupName;
174174
String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
175175
String _recycleHungWorker = "false";
176-
long _hungWorkerTimeout = 7200000; // 2 hour
176+
long _hungWorkerTimeout = 7200000; // 2 hour
177177
int _additionalPortRangeStart;
178178
int _additionalPortRangeSize;
179179
int _routerExtraPublicNics = 2;
@@ -296,10 +296,10 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
296296
if(_recycleHungWorker == null || _recycleHungWorker.isEmpty()) {
297297
_recycleHungWorker = "false";
298298
}
299-
299+
300300
value = _configDao.getValue(Config.VmwareHungWorkerTimeout.key());
301301
if(value != null)
302-
_hungWorkerTimeout = Long.parseLong(value) * 1000;
302+
_hungWorkerTimeout = Long.parseLong(value) * 1000;
303303

304304
_rootDiskController = _configDao.getValue(Config.VmwareRootDiskControllerType.key());
305305
if(_rootDiskController == null || _rootDiskController.isEmpty()) {
@@ -459,7 +459,7 @@ private ManagedObjectReference addHostToVCenterCluster(VmwareContext serviceCont
459459
hostSpec.setUserName(userName);
460460
hostSpec.setPassword(password);
461461
hostSpec.setHostName(host);
462-
hostSpec.setForce(true); // forcely take over the host
462+
hostSpec.setForce(true); // forcely take over the host
463463

464464
ManagedObjectReference morTask = serviceContext.getService().addHostTask(morCluster, hostSpec, true, null, null);
465465
boolean taskResult = vclient.waitForTask(morTask);
@@ -547,49 +547,49 @@ public VmwareStorageManager getStorageManager() {
547547
public void gcLeftOverVMs(VmwareContext context) {
548548
VmwareCleanupMaid.gcLeftOverVMs(context);
549549
}
550-
550+
551551
@Override
552552
public boolean needRecycle(String workerTag) {
553-
if(s_logger.isInfoEnabled())
554-
s_logger.info("Check to see if a worker VM with tag " + workerTag + " needs to be recycled");
555-
556-
if(workerTag == null || workerTag.isEmpty()) {
557-
s_logger.error("Invalid worker VM tag " + workerTag);
558-
return false;
559-
}
560-
561-
String tokens[] = workerTag.split("-");
562-
if(tokens.length != 3) {
563-
s_logger.error("Invalid worker VM tag " + workerTag);
564-
return false;
565-
}
566-
567-
long startTick = Long.parseLong(tokens[0]);
568-
long msid = Long.parseLong(tokens[1]);
569-
long runid = Long.parseLong(tokens[2]);
570-
553+
if (s_logger.isInfoEnabled())
554+
s_logger.info("Check to see if a worker VM with tag " + workerTag + " needs to be recycled");
555+
556+
if (workerTag == null || workerTag.isEmpty()) {
557+
s_logger.error("Invalid worker VM tag " + workerTag);
558+
return false;
559+
}
560+
561+
String tokens[] = workerTag.split("-");
562+
if (tokens.length != 3) {
563+
s_logger.error("Invalid worker VM tag " + workerTag);
564+
return false;
565+
}
566+
567+
long startTick = Long.parseLong(tokens[0]);
568+
long msid = Long.parseLong(tokens[1]);
569+
long runid = Long.parseLong(tokens[2]);
570+
571571
if(_mshostPeerDao.countStateSeenInPeers(msid, runid, ManagementServerHost.State.Down) > 0) {
572-
if(s_logger.isInfoEnabled())
573-
s_logger.info("Worker VM's owner management server node has been detected down from peer nodes, recycle it");
574-
return true;
572+
if (s_logger.isInfoEnabled())
573+
s_logger.info("Worker VM's owner management server node has been detected down from peer nodes, recycle it");
574+
return true;
575575
}
576-
576+
577577
if(msid == _clusterMgr.getManagementNodeId() && runid != _clusterMgr.getCurrentRunId()) {
578-
if(s_logger.isInfoEnabled())
579-
s_logger.info("Worker VM's owner management server has changed runid, recycle it");
580-
return true;
578+
if (s_logger.isInfoEnabled())
579+
s_logger.info("Worker VM's owner management server has changed runid, recycle it");
580+
return true;
581581
}
582-
582+
583583
// disable time-out check until we have found out a VMware API that can check if
584584
// there are pending tasks on the subject VM
585-
/*
586-
if(System.currentTimeMillis() - startTick > _hungWorkerTimeout) {
587-
if(s_logger.isInfoEnabled())
588-
s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000);
589-
return true;
590-
}
591-
*/
592-
return false;
585+
/*
586+
if(System.currentTimeMillis() - startTick > _hungWorkerTimeout) {
587+
if(s_logger.isInfoEnabled())
588+
s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000);
589+
return true;
590+
}
591+
*/
592+
return false;
593593
}
594594

595595
@Override
@@ -619,6 +619,9 @@ public void prepareSecondaryStorageStore(String storageUrl) {
619619
", destination: " + destIso.getAbsolutePath());
620620
try {
621621
FileUtil.copyfile(srcIso, destIso);
622+
623+
s_logger.info("System VM patch ISO file is copied to secondary storage. source ISO: " + srcIso.getAbsolutePath() +
624+
", destination: " + destIso.getAbsolutePath());
622625
} catch(IOException e) {
623626
s_logger.error("Unexpected exception ", e);
624627

‎server/src/com/cloud/storage/VolumeApiServiceImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
333333

334334
// TODO
335335
static final ConfigKey<Boolean> VmJobEnabled = new ConfigKey<Boolean>("Advanced",
336-
Boolean.class, "vm.job.enabled", "false",
336+
Boolean.class, "vm.job.enabled", "true",
337337
"True to enable new VM sync model. false to use the old way", false);
338338
static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced",
339339
Long.class, "vm.job.check.interval", "3000",

‎server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
136136

137137
// TODO
138138
static final ConfigKey<Boolean> VmJobEnabled = new ConfigKey<Boolean>("Advanced",
139-
Boolean.class, "vm.job.enabled", "false",
139+
Boolean.class, "vm.job.enabled", "true",
140140
"True to enable new VM sync model. false to use the old way", false);
141141
static final ConfigKey<Long> VmJobCheckInterval = new ConfigKey<Long>("Advanced",
142142
Long.class, "vm.job.check.interval", "3000",

0 commit comments

Comments
 (0)