Skip to content

Commit 8a91aa9

Browse files
koushik-dasyadvr
authored andcommitted
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 (cherry picked from commit 513adab) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
1 parent b2c2402 commit 8a91aa9

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.apache.log4j.Logger;
4747

4848
import org.apache.cloudstack.alert.AlertService;
49-
import org.apache.cloudstack.alert.AlertService.AlertType;
5049
import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
5150
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
5251
import org.apache.cloudstack.api.command.admin.router.UpgradeRouterTemplateCmd;
@@ -61,7 +60,6 @@
6160
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
6261
import org.apache.cloudstack.utils.identity.ManagementServerNode;
6362
import org.apache.cloudstack.utils.usage.UsageUtils;
64-
import org.apache.log4j.Logger;
6563

6664
import com.cloud.agent.AgentManager;
6765
import com.cloud.agent.Listener;
@@ -4312,10 +4310,22 @@ public boolean preStateTransitionEvent(State oldState, VirtualMachine.Event even
43124310

43134311
@Override
43144312
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
4315-
if (oldState == State.Stopped && event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
4313+
if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
43164314
if (vo.getType() == VirtualMachine.Type.DomainRouter) {
4317-
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");
4318-
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
4315+
if (opaque != null && opaque instanceof Pair<?, ?>) {
4316+
Pair<?, ?> pair = (Pair<?, ?>)opaque;
4317+
Object first = pair.first();
4318+
Object second = pair.second();
4319+
if (first != null && second != null && first instanceof Long && second instanceof Long) {
4320+
Long hostId = (Long)first;
4321+
Long powerHostId = (Long)second;
4322+
// If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement
4323+
if (hostId.longValue() != powerHostId.longValue()) {
4324+
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");
4325+
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
4326+
}
4327+
}
4328+
}
43194329
}
43204330
}
43214331
return true;

‎server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,4 +1521,11 @@ public boolean stopRemoteAccessVpn(RemoteAccessVpn vpn, VirtualRouter router) th
15211521

15221522
return true;
15231523
}
1524+
1525+
@Override
1526+
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
1527+
// Without this VirtualNetworkApplianceManagerImpl.postStateTransitionEvent() gets called twice as part of listeners -
1528+
// once from VpcVirtualNetworkApplianceManagerImpl and once from VirtualNetworkApplianceManagerImpl itself
1529+
return true;
1530+
}
15241531
}

0 commit comments

Comments
 (0)