@@ -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
0 commit comments