mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7994: Network rules are not configured in VR after out-of-band movement due to host crash
Ensure that VR is re-booted when it is moved to another host out-of-band. This is necessary to re-program all network rules
This commit is contained in:
parent
21b0ad4a62
commit
513adab51b
|
|
@ -244,6 +244,7 @@ import com.cloud.vm.dao.NicIpAliasVO;
|
|||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
import org.apache.cloudstack.alert.AlertService;
|
||||
import org.apache.cloudstack.alert.AlertService.AlertType;
|
||||
import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
|
||||
|
|
@ -266,6 +267,7 @@ import org.apache.log4j.Logger;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -4459,10 +4461,22 @@ VirtualMachineGuru, Listener, Configurable, StateListener<State, VirtualMachine.
|
|||
|
||||
@Override
|
||||
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
|
||||
if (oldState == State.Stopped && event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
|
||||
if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
|
||||
if (vo.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band. we need to reboot to refresh network rules");
|
||||
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
|
||||
if (opaque != null && opaque instanceof Pair<?, ?>) {
|
||||
Pair<?, ?> pair = (Pair<?, ?>)opaque;
|
||||
Object first = pair.first();
|
||||
Object second = pair.second();
|
||||
if (first != null && second != null && first instanceof Long && second instanceof Long) {
|
||||
Long hostId = (Long)first;
|
||||
Long powerHostId = (Long)second;
|
||||
// If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement
|
||||
if (hostId.longValue() != powerHostId.longValue()) {
|
||||
s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band. we need to reboot to refresh network rules");
|
||||
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1481,4 +1481,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
|
||||
// Without this VirtualNetworkApplianceManagerImpl.postStateTransitionEvent() gets called twice as part of listeners -
|
||||
// once from VpcVirtualNetworkApplianceManagerImpl and once from VirtualNetworkApplianceManagerImpl itself
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue