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 8449410461 for ; Tue, 4 Jun 2013 13:23:47 +0000 (UTC) Received: (qmail 46468 invoked by uid 500); 4 Jun 2013 13:23:47 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 46288 invoked by uid 500); 4 Jun 2013 13:23:46 -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 46281 invoked by uid 99); 4 Jun 2013 13:23:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Jun 2013 13:23:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7B058545F6; Tue, 4 Jun 2013 13:23:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: muralireddy@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to cb595ca Date: Tue, 4 Jun 2013 13:23:45 +0000 (UTC) Updated Branches: refs/heads/master ee3043b88 -> cb595cafc CLOUDSTACK-2390:[GSLB] After removeFromGSLBRule, still CloudStack things that lb rule is active removing the GSLB rule to Lb rule mapping once rules are applied on the GSLB service provider Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cb595caf Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cb595caf Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cb595caf Branch: refs/heads/master Commit: cb595cafc7b4fad56e7da6b4f3a1e71402648d44 Parents: ee3043b Author: Murali Reddy Authored: Tue Jun 4 15:51:31 2013 +0530 Committer: Murali Reddy Committed: Tue Jun 4 18:53:17 2013 +0530 ---------------------------------------------------------------------- .../gslb/GlobalLoadBalancingRulesServiceImpl.java | 47 +++++++++++--- 1 files changed, 37 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb595caf/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java index 02c7720..7c46d4a 100644 --- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java +++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java @@ -260,7 +260,13 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR s_logger.debug("Configuring gslb rule configuration on the gslb service providers in the participating zones"); // apply the gslb rule on to the back end gslb service providers on zones participating in gslb - applyGlobalLoadBalancerRuleConfig(gslbRuleId, false); + if (!applyGlobalLoadBalancerRuleConfig(gslbRuleId, false)) { + s_logger.warn("Failed to add load balancer rules " + newLbRuleIds + " to global load balancer rule id " + + gslbRuleId); + CloudRuntimeException ex = new CloudRuntimeException( + "Failed to add load balancer rules to GSLB rule "); + throw ex; + } // on success set state to Active gslbRule.setState(GlobalLoadBalancerRule.State.Active); @@ -269,7 +275,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR success = true; } catch (ResourceUnavailableException e) { - throw new CloudRuntimeException("Failed to apply gslb config"); + throw new CloudRuntimeException("Failed to apply new GSLB configuration while assigning new LB rules to GSLB rule."); } return success; @@ -359,11 +365,28 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR s_logger.debug("Attempting to configure global load balancer rule configuration on the gslb service providers "); // apply the gslb rule on to the back end gslb service providers - applyGlobalLoadBalancerRuleConfig(gslbRuleId, false); + if (!applyGlobalLoadBalancerRuleConfig(gslbRuleId, false)) { + s_logger.warn("Failed to remove load balancer rules " + lbRuleIdsToremove + " from global load balancer rule id " + + gslbRuleId); + CloudRuntimeException ex = new CloudRuntimeException( + "Failed to remove load balancer rule ids from GSLB rule "); + throw ex; + } - // on success set state to Active + txn.start(); + + // remove the mappings of gslb rule to Lb rule that are in revoked state + for (Long lbRuleId : lbRuleIdsToremove) { + GlobalLoadBalancerLbRuleMapVO removeGslbLbMap = _gslbLbMapDao.findByGslbRuleIdAndLbRuleId(gslbRuleId, lbRuleId); + _gslbLbMapDao.remove(removeGslbLbMap.getId()); + } + + // on success set state back to Active gslbRule.setState(GlobalLoadBalancerRule.State.Active); _gslbRuleDao.update(gslbRule.getId(), gslbRule); + + txn.commit(); + success = true; } catch (ResourceUnavailableException e) { throw new CloudRuntimeException("Failed to update removed load balancer details from gloabal load balancer"); @@ -402,8 +425,16 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule); - if (gslbRule.getState() == GlobalLoadBalancerRule.State.Revoke) { - throw new InvalidParameterValueException("global load balancer rule id: " + gslbRuleId + " is already in revoked state"); + if (gslbRule.getState() == com.cloud.region.ha.GlobalLoadBalancerRule.State.Staged) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Rule Id: " + gslbRuleId + " is still in Staged state so just removing it."); + } + _gslbRuleDao.remove(gslbRuleId); + return; + } else if (gslbRule.getState() == GlobalLoadBalancerRule.State.Add || gslbRule.getState() == GlobalLoadBalancerRule.State.Active) { + //mark the GSlb rule to be in revoke state + gslbRule.setState(GlobalLoadBalancerRule.State.Revoke); + _gslbRuleDao.update(gslbRuleId, gslbRule); } Transaction txn = Transaction.currentTxn(); @@ -418,10 +449,6 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR } } - //mark the GSlb rule to be in revoke state - gslbRule.setState(GlobalLoadBalancerRule.State.Revoke); - _gslbRuleDao.update(gslbRuleId, gslbRule); - txn.commit(); boolean success = false;