Github user nathanejohnson commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1956#discussion_r102295771
  
    --- Diff: 
engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java ---
    @@ -744,14 +744,17 @@ protected boolean checkWorkItems(final VMInstanceVO 
vm, final State state) throw
     
         protected <T extends VMInstanceVO> boolean changeState(final T vm, 
final Event event, final Long hostId, final ItWorkVO work, final Step step) 
throws NoTransitionException {
             // FIXME: We should do this better.
    -        final Step previousStep = work.getStep();
    -        _workDao.updateStep(work, step);
    +        Step previousStep = null;
    +        if (work != null) {
    +            previousStep = work.getStep();
    --- End diff --
    
    Most of this code I didn't write, but I can make some guesses:
    
    _workDao.updateStep(work, previousStep) line is in the finally block, which 
will execute even if an exception is thrown in stateTransitTo (like 
NoTransitException for instance).  So if stateTransitTo a) returns a false, or 
b) throw an exception, then result will be false, and line 758 will run.  So if 
something happens that the state isn't transitioned, someone wanted the work 
reverted to its previous step value.  Sort of a rollback maybe?
    
    In the case of the VM hung in starting, my desired side effect is I want 
stateTransitTo to be called and set the state to Stopped , i.e., 
Event.AgentReportStopped -> State.Stopped .  The work has already expired at 
this point, so it is null.  I was trying to preserve the same behavior as 
before when work was not null.
    
    Sorry if this wasn't very clear.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to