Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8AD8018846 for ; Thu, 18 Jun 2015 14:42:29 +0000 (UTC) Received: (qmail 5083 invoked by uid 500); 18 Jun 2015 14:42:29 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 5050 invoked by uid 500); 18 Jun 2015 14:42:29 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 5040 invoked by uid 99); 18 Jun 2015 14:42:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jun 2015 14:42:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3F15CE3C8E; Thu, 18 Jun 2015 14:42:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: dahn@apache.org To: commits@cloudstack.apache.org Message-Id: <60365d01ffb049f385329832de28bf34@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to b9dd67c Date: Thu, 18 Jun 2015 14:42:29 +0000 (UTC) Repository: cloudstack Updated Branches: refs/heads/master 931cb9502 -> b9dd67c38 CLOUDSTACK-8545 port of the fix to not reboot routers on out of band migration persé Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b9dd67c3 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b9dd67c3 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b9dd67c3 Branch: refs/heads/master Commit: b9dd67c383874ef7273205e0eac831de497bb02d Parents: 931cb95 Author: Daan Hoogland Authored: Thu Jun 18 16:42:08 2015 +0200 Committer: Daan Hoogland Committed: Thu Jun 18 16:42:08 2015 +0200 ---------------------------------------------------------------------- .../router/VirtualNetworkApplianceManager.java | 7 +++ .../VirtualNetworkApplianceManagerImpl.java | 64 ++++++++++++-------- 2 files changed, 47 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9dd67c3/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java index a502018..20ee2a1 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -44,6 +44,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA static final String RouterTemplateOvm3CK = "router.template.ovm3"; static final String SetServiceMonitorCK = "network.router.EnableServiceMonitoring"; static final String RouterAlertsCheckIntervalCK = "router.alerts.check.interval"; + static final String RouterReprovisionOnOutOfBandMigrationCK = "router.reboot.when.outofband.migrated"; static final ConfigKey RouterTemplateXen = new ConfigKey(String.class, RouterTemplateXenCK, "Advanced", "SystemVM Template (XenServer)", "Name of the default router template on Xenserver.", true, ConfigKey.Scope.Zone, null); @@ -63,6 +64,12 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA static final ConfigKey RouterAlertsCheckInterval = new ConfigKey(Integer.class, RouterAlertsCheckIntervalCK, "Advanced", "1800", "Interval (in seconds) to check for alerts in Virtual Router.", false, ConfigKey.Scope.Global, null); + static final ConfigKey routerVersionCheckEnabled = new ConfigKey("Advanced", Boolean.class, "router.version.check", "true", + "If true, router minimum required version is checked before sending command", false); + static final ConfigKey UseExternalDnsServers = new ConfigKey(Boolean.class, "use.external.dns", "Advanced", "false", + "Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null); + static final ConfigKey RouterReprovisionOnOutOfBandMigration = new ConfigKey(Boolean.class, RouterReprovisionOnOutOfBandMigrationCK, "Advanced", "false", + "Reboot routers when they are migrated out of band in order to reprovision", true, ConfigKey.Scope.Zone, null); public static final int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9dd67c3/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 2a518e4..8dab44d 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -2604,7 +2604,7 @@ Configurable, StateListener { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] { UseExternalDnsServers, routerVersionCheckEnabled, SetServiceMonitor, RouterAlertsCheckInterval }; + return new ConfigKey[] { UseExternalDnsServers, routerVersionCheckEnabled, SetServiceMonitor, RouterAlertsCheckInterval, RouterReprovisionOnOutOfBandMigration }; } @Override @@ -2615,36 +2615,52 @@ Configurable, StateListener { @Override public boolean postStateTransitionEvent(final StateMachine2.Transition transition, final VirtualMachine vo, final boolean status, final Object opaque) { + final State oldState = transition.getCurrentState(); final State newState = transition.getToState(); final VirtualMachine.Event event = transition.getEvent(); - if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) { - if (vo.getType() == VirtualMachine.Type.DomainRouter) { - // opaque -> - if (opaque != null && opaque instanceof Pair) { - final Pair pair = (Pair)opaque; - final Object first = pair.first(); - final Object second = pair.second(); - // powerHostId cannot be null in case of out-of-band VM movement - if (second != null && second instanceof Long) { - final Long powerHostId = (Long)second; - Long hostId = null; - if (first != null && first instanceof Long) { - hostId = (Long)first; - } - // The following scenarios are due to out-of-band VM movement - // 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 - if (hostId == null || hostId.longValue() != powerHostId.longValue()) { - 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"); - _rebootRouterExecutor.execute(new RebootTask(vo.getId())); - } - } - } + boolean reprovision_out_of_band = RouterReprovisionOnOutOfBandMigration.value(); + if ( + (vo.getType() == VirtualMachine.Type.DomainRouter) && + ((oldState == State.Stopped) || (reprovision_out_of_band && isOutOfBandMigrated(opaque))) && + (event == VirtualMachine.Event.FollowAgentPowerOnReport) && + (newState == State.Running)) { + 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"); + _rebootRouterExecutor.execute(new RebootTask(vo.getId())); + } else { + if (isOutOfBandMigrated(opaque)) { + final String title = "Router has been migrated out of band: " + vo.getInstanceName(); + final String context = + "An out of band migration of router " + vo.getInstanceName() + "(" + vo.getUuid() + ") was detected. No automated action was performed."; + _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_DOMAIN_ROUTER, vo.getDataCenterId(), vo.getPodIdToDeployIn(), title, context); } } + return true; } + private boolean isOutOfBandMigrated(final Object opaque) { + if (opaque != null && opaque instanceof Pair) { + final Pair pair = (Pair)opaque; + final Object first = pair.first(); + final Object second = pair.second(); + // powerHostId cannot be null in case of out-of-band VM movement + if (second != null && second instanceof Long) { + final Long powerHostId = (Long)second; + Long hostId = null; + if (first != null && first instanceof Long) { + hostId = (Long)first; + } + // The following scenarios are due to out-of-band VM movement + // 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 + if (hostId == null || hostId.longValue() != powerHostId.longValue()) { + return true; + } + } + } + return false; + } + protected class RebootTask extends ManagedContextRunnable { long _routerId;