Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-18456 d6a847154 -> 5dff9acdc


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/10c7595a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/10c7595a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/10c7595a

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 10c7595a4ac858ac5a095f2caf8770f1ea685c1c
Parents: 9b0f631
Author: Tim Thorpe <ttho...@apache.org>
Authored: Fri Oct 14 08:39:17 2016 -0700
Committer: Tim Thorpe <ttho...@apache.org>
Committed: Fri Oct 14 08:39:17 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/10c7595a/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/10c7595a/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