ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: Merge branch 'branch-feature-AMBARI-18634' into trunk
Date Thu, 10 Nov 2016 17:01:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 3b530582b -> ba7457b7b


Merge branch 'branch-feature-AMBARI-18634' into trunk


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

Branch: refs/heads/branch-2.5
Commit: ba7457b7b0680ed1db58d8acb93ce29904c69a5e
Parents: 3b53058
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Nov 10 11:10:37 2016 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Thu Nov 10 11:13:37 2016 -0500

----------------------------------------------------------------------
 .../ambari/server/checks/CheckDescription.java  |  6 ++-
 .../server/checks/HostMaintenanceModeCheck.java | 14 +++++-
 .../checks/HostMaintenanceModeCheckTest.java    | 47 ++++++++++++++++++++
 3 files changed, 63 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7457b7/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
index a56b08d..fbc4be1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDescription.java
@@ -66,7 +66,9 @@ public class CheckDescription {
     "Hosts in Maintenance Mode will be excluded from the upgrade.",
     new ImmutableMap.Builder<String, String>()
       .put(AbstractCheckDescriptor.DEFAULT,
-          "There are hosts in Maintenance Mode which excludes them from being upgraded.").build());
+          "There are hosts in Maintenance Mode which excludes them from being upgraded.")
+      .put(HostMaintenanceModeCheck.KEY_CANNOT_START_HOST_ORDERED,
+          "The following hosts cannot be in Maintenance Mode: {{fails}}.").build());
 
   public static CheckDescription HOSTS_MASTER_MAINTENANCE = new CheckDescription("HOSTS_MASTER_MAINTENANCE",
     PrereqCheckType.HOST,
@@ -296,7 +298,7 @@ public class CheckDescription {
     new ImmutableMap.Builder<String, String>()
       .put(AbstractCheckDescriptor.DEFAULT,
           "HiveServer2 does not currently support rolling upgrades. HiveServer2 will be upgraded,
however existing queries which have not completed will fail and need to be resubmitted after
HiveServer2 has been upgraded.").build());
-  
+
   public static CheckDescription SERVICES_STORM_ROLLING_WARNING = new CheckDescription("SERVICES_STORM_ROLLING_WARNING",
     PrereqCheckType.SERVICE,
     "Storm Downtime During Upgrade",

http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7457b7/ambari-server/src/main/java/org/apache/ambari/server/checks/HostMaintenanceModeCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/HostMaintenanceModeCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/HostMaintenanceModeCheck.java
index 5e7bdef..88d9de6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/HostMaintenanceModeCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/HostMaintenanceModeCheck.java
@@ -26,6 +26,7 @@ import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 
 import com.google.inject.Singleton;
 
@@ -42,6 +43,8 @@ import com.google.inject.Singleton;
 @UpgradeCheck(group = UpgradeCheckGroup.MAINTENANCE_MODE, order = 7.0f, required = true)
 public class HostMaintenanceModeCheck extends AbstractCheckDescriptor {
 
+  public static final String KEY_CANNOT_START_HOST_ORDERED = "cannot_upgrade_mm_hosts";
+
   /**
    * Constructor.
    */
@@ -69,8 +72,15 @@ public class HostMaintenanceModeCheck extends AbstractCheckDescriptor {
 
     // for any host in MM, produce a warning
     if (!prerequisiteCheck.getFailedOn().isEmpty()) {
-      prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING);
-      prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request));
+      PrereqCheckStatus status = request.getUpgradeType() == UpgradeType.HOST_ORDERED ?
+          PrereqCheckStatus.FAIL : PrereqCheckStatus.WARNING;
+      prerequisiteCheck.setStatus(status);
+
+      String failReason = request.getUpgradeType() == UpgradeType.HOST_ORDERED ?
+          getFailReason(KEY_CANNOT_START_HOST_ORDERED, prerequisiteCheck, request) :
+          getFailReason(prerequisiteCheck, request);
+
+      prerequisiteCheck.setFailReason(failReason);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ba7457b7/ambari-server/src/test/java/org/apache/ambari/server/checks/HostMaintenanceModeCheckTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostMaintenanceModeCheckTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostMaintenanceModeCheckTest.java
index 0e14376..0362c87 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/HostMaintenanceModeCheckTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/HostMaintenanceModeCheckTest.java
@@ -28,6 +28,7 @@ import org.apache.ambari.server.state.MaintenanceState;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
+import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -84,4 +85,50 @@ public class HostMaintenanceModeCheckTest {
     hostMaintenanceModeCheck.perform(check, new PrereqCheckRequest("cluster"));
     Assert.assertEquals(PrereqCheckStatus.WARNING, check.getStatus());
   }
+
+  @Test
+  public void testPerformHostOrdered() throws Exception {
+    final HostMaintenanceModeCheck hostMaintenanceModeCheck = new HostMaintenanceModeCheck();
+    hostMaintenanceModeCheck.clustersProvider = new Provider<Clusters>() {
+
+      @Override
+      public Clusters get() {
+        return clusters;
+      }
+    };
+
+    final Cluster cluster = Mockito.mock(Cluster.class);
+    Mockito.when(cluster.getClusterId()).thenReturn(1L);
+    Mockito.when(cluster.getCurrentStackVersion()).thenReturn(new StackId("HDP", "2.2"));
+    Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster);
+
+    final List<Host> hosts = new ArrayList<>();
+    final Host host1 = Mockito.mock(Host.class);
+    final Host host2 = Mockito.mock(Host.class);
+    final Host host3 = Mockito.mock(Host.class);
+
+    Mockito.when(host1.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+    Mockito.when(host2.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+    Mockito.when(host3.getMaintenanceState(1L)).thenReturn(MaintenanceState.OFF);
+    Mockito.when(host1.getHostName()).thenReturn("h1");
+    Mockito.when(host2.getHostName()).thenReturn("h2");
+    Mockito.when(host3.getHostName()).thenReturn("h3");
+
+    hosts.add(host1);
+    hosts.add(host2);
+    hosts.add(host3);
+
+    Mockito.when(cluster.getHosts()).thenReturn(hosts);
+
+    PrerequisiteCheck check = new PrerequisiteCheck(null, null);
+    hostMaintenanceModeCheck.perform(check, new PrereqCheckRequest("cluster"));
+    Assert.assertEquals(PrereqCheckStatus.PASS, check.getStatus());
+
+    // put a host into MM in order to trigger the warning
+    check = new PrerequisiteCheck(null, null);
+    Mockito.when(host3.getMaintenanceState(1L)).thenReturn(MaintenanceState.ON);
+    hostMaintenanceModeCheck.perform(check, new PrereqCheckRequest("cluster", UpgradeType.HOST_ORDERED));
+    Assert.assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
+    Assert.assertEquals("The following hosts cannot be in Maintenance Mode: h3.", check.getFailReason());
+  }
 }


Mime
View raw message