Skip to content

Commit 016d009

Browse files
committed
CLOUDSTACK-7994: Network rules are not configured in VR after out-of-band movement due to host crash
The last commit 513adab didn't fully fix it. Scenario #1 was not handled, only #2 was handled. Fixed #1 as part of this commit. 1. If VM is in stopped state in CS due to 'PowerMissing' report from old host (hostId is null) and then there is a 'PowerOn' report from new host 2. If VM is in running state in CS and there is a 'PowerOn' report from new host
1 parent 0af15e4 commit 016d009

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,16 +4461,23 @@ public boolean preStateTransitionEvent(State oldState, VirtualMachine.Event even
44614461
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
44624462
if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
44634463
if (vo.getType() == VirtualMachine.Type.DomainRouter) {
4464+
// opaque -> <hostId, powerHostId>
44644465
if (opaque != null && opaque instanceof Pair<?, ?>) {
44654466
Pair<?, ?> pair = (Pair<?, ?>)opaque;
44664467
Object first = pair.first();
44674468
Object second = pair.second();
4468-
if (first != null && second != null && first instanceof Long && second instanceof Long) {
4469-
Long hostId = (Long)first;
4469+
// powerHostId cannot be null in case of out-of-band VM movement
4470+
if (second != null && second instanceof Long) {
44704471
Long powerHostId = (Long)second;
4471-
// If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement
4472-
if (hostId.longValue() != powerHostId.longValue()) {
4473-
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");
4472+
Long hostId = null;
4473+
if (first != null && first instanceof Long) {
4474+
hostId = (Long)first;
4475+
}
4476+
// The following scenarios are due to out-of-band VM movement
4477+
// 1. If VM is in stopped state in CS due to 'PowerMissing' report from old host (hostId is null) and then there is a 'PowerOn' report from new host
4478+
// 2. If VM is in running state in CS and there is a 'PowerOn' report from new host
4479+
if (hostId == null || (hostId.longValue() != powerHostId.longValue())) {
4480+
s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band, need to reboot to refresh network rules");
44744481
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
44754482
}
44764483
}

0 commit comments

Comments
 (0)