Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 4ae5b834d -> cb9db0aef


AMBARI-18594 - AMBARI-18051 Breaks Stack Upgrade Checks


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cb9db0ae
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cb9db0ae
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cb9db0ae

Branch: refs/heads/branch-2.5
Commit: cb9db0aef3d2ee6c11d9d7f15c4a4709c14dd1a8
Parents: 4ae5b83
Author: Tim Thorpe <ttho...@apache.org>
Authored: Fri Oct 14 08:37:43 2016 -0700
Committer: Tim Thorpe <ttho...@apache.org>
Committed: Fri Oct 14 08:37:43 2016 -0700

----------------------------------------------------------------------
 .../controller/internal/PreUpgradeCheckResourceProvider.java  | 7 ++++++-
 .../internal/PreUpgradeCheckResourceProviderTest.java         | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cb9db0ae/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
index 7e54f83..adbd7cb 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ParentObjectNotFoundException;
 import org.apache.ambari.server.StaticallyInject;
 import org.apache.ambari.server.checks.AbstractCheckDescriptor;
 import org.apache.ambari.server.checks.UpgradeCheckRegistry;
@@ -195,11 +196,15 @@ public class PreUpgradeCheckResourceProvider extends 
ReadOnlyResourceProvider {
 
       try {
         // Register all the custom prechecks from the services
-        Map<String, ServiceInfo> services = 
getManagementController().getAmbariMetaInfo().getServices(stackName, 
upgradePack.getTarget());
+        Map<String, ServiceInfo> services = 
getManagementController().getAmbariMetaInfo().getServices(stackName, 
sourceStackVersion);
         List<AbstractCheckDescriptor> serviceLevelUpgradeChecksToRun = 
upgradeCheckRegistry.getServiceLevelUpgradeChecks(upgradePack, services);
         upgradeChecksToRun.addAll(serviceLevelUpgradeChecksToRun);
+      } catch (ParentObjectNotFoundException parentNotFoundException) {
+        LOG.error("Invalid stack version: " + stackName + "-" + 
sourceStackVersion, parentNotFoundException);
       } catch (AmbariException ambariException) {
         LOG.error("Unable to register all the custom prechecks from the 
services", ambariException);
+      } catch (Exception e) {
+        LOG.error("Failed to register custom prechecks for the services", e);
       }
 
       for (PrerequisiteCheck prerequisiteCheck : 
checkHelper.performChecks(upgradeCheckRequest, upgradeChecksToRun)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/cb9db0ae/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
index 6a0fa12..2f30215 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProviderTest.java
@@ -147,9 +147,9 @@ public class PreUpgradeCheckResourceProviderTest {
     
prerequisiteChecks.add("org.apache.ambari.server.sample.checks.SampleServiceCheck");
     expect(upgradePack.getPrerequisiteCheckConfig()).andReturn(config);
     
expect(upgradePack.getPrerequisiteChecks()).andReturn(prerequisiteChecks).anyTimes();
-    expect(upgradePack.getTarget()).andReturn("1.1").anyTimes();
+    expect(upgradePack.getTarget()).andReturn("1.1.*.*").anyTimes();
 
-    expect(ambariMetaInfo.getServices("Stack100", 
"1.1")).andReturn(allServiceInfoMap).anyTimes();
+    expect(ambariMetaInfo.getServices("Stack100", 
"1.0")).andReturn(allServiceInfoMap).anyTimes();
     String checks = 
ClassLoader.getSystemClassLoader().getResource("checks").getPath();
     expect(serviceInfo.getChecksFolder()).andReturn(new File(checks));
 

Reply via email to