You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/09/18 21:27:40 UTC

ambari git commit: AMBARI-13150. Install of packages for newer HDP version is failing (ncole)

Repository: ambari
Updated Branches:
  refs/heads/trunk abd3e5bd0 -> 950616d48


AMBARI-13150. Install of packages for newer HDP version is failing (ncole)


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

Branch: refs/heads/trunk
Commit: 950616d48522fdb91f5f9dfaf64dc9ae9d5538a7
Parents: abd3e5b
Author: Nate Cole <nc...@hortonworks.com>
Authored: Fri Sep 18 13:20:25 2015 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Fri Sep 18 15:26:47 2015 -0400

----------------------------------------------------------------------
 .../controller/AmbariActionExecutionHelper.java | 17 +++++++++++------
 .../AmbariManagementControllerTest.java         | 20 ++++++++++++++------
 2 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/950616d4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index a13e86d..1c110fc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -214,8 +214,7 @@ public class AmbariActionExecutionHelper {
    *
    * @throws AmbariException if the task can not be added
    */
-  public void addExecutionCommandsToStage(
-final ActionExecutionContext actionContext, Stage stage)
+  public void addExecutionCommandsToStage(final ActionExecutionContext actionContext, Stage stage)
       throws AmbariException {
 
     String actionName = actionContext.getActionName();
@@ -343,11 +342,17 @@ final ActionExecutionContext actionContext, Stage stage)
           actionContext.isFailureAutoSkipped());
 
       Map<String, String> commandParams = new TreeMap<String, String>();
-      int maxTaskTimeout = Integer.parseInt(configs.getDefaultAgentTaskTimeout(false));
-      if(maxTaskTimeout < actionContext.getTimeout()) {
-        commandParams.put(COMMAND_TIMEOUT, Integer.toString(maxTaskTimeout));
-      } else {
+
+      int taskTimeout = Integer.parseInt(configs.getDefaultAgentTaskTimeout(false));
+
+      // use the biggest of all these:
+      // if the action context timeout is bigger than the default, use the context
+      // if the action context timeout is smaller than the default, use the default
+      // if the action context timeout is undefined, use the default
+      if (null != actionContext.getTimeout() && actionContext.getTimeout() > taskTimeout) {
         commandParams.put(COMMAND_TIMEOUT, actionContext.getTimeout().toString());
+      } else {
+        commandParams.put(COMMAND_TIMEOUT, Integer.toString(taskTimeout));
       }
 
       commandParams.put(SCRIPT, actionName + ".py");

http://git-wip-us.apache.org/repos/asf/ambari/blob/950616d4/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index de141eb..12bca8c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -4154,10 +4154,9 @@ public class AmbariManagementControllerTest {
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h2").persist();
 
-    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
-        "a1", ActionType.SYSTEM, "test,[optional1]", "", "", "Does file exist",
-        TargetHostType.SPECIFIC, Short.valueOf("100")));
-
+    ActionDefinition a1 = new ActionDefinition("a1", ActionType.SYSTEM,
+        "test,[optional1]", "", "", "Does file exist", TargetHostType.SPECIFIC, Short.valueOf("100"));
+    controller.getAmbariMetaInfo().addActionDefinition(a1);
     controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
         "a2", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
         TargetHostType.ALL, Short.valueOf("1000")));
@@ -4199,9 +4198,18 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("HDFS", cmd.getServiceName());
     Assert.assertEquals("DATANODE", cmd.getComponentName());
     Assert.assertNotNull(hostParametersStage.get("jdk_location"));
-    Assert.assertEquals("100", cmd.getCommandParams().get("command_timeout"));
+    Assert.assertEquals("900", cmd.getCommandParams().get("command_timeout"));
     Assert.assertEquals(requestProperties.get(REQUEST_CONTEXT_PROPERTY), response.getRequestContext());
 
+    // !!! test that the action execution helper is using the right timeout
+    a1.setDefaultTimeout((short) 1800);
+    actionRequest = new ExecuteActionRequest("c1", null, "a1", resourceFilters, null, params, false);
+    response = controller.createAction(actionRequest, requestProperties);
+
+    List<HostRoleCommand> storedTasks1 = actionDB.getRequestTasks(response.getRequestId());
+    cmd = storedTasks1.get(0).getExecutionCommandWrapper().getExecutionCommand();
+    Assert.assertEquals("1800", cmd.getCommandParams().get("command_timeout"));
+
     resourceFilters.clear();
     resourceFilter = new RequestResourceFilter("", "", null);
     resourceFilters.add(resourceFilter);
@@ -6432,7 +6440,7 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(nnCommand);
     ExecutionCommand cmd = nnCommand.getExecutionCommandWrapper().getExecutionCommand();
     Assert.assertEquals("a1", cmd.getRole());
-    Assert.assertEquals("900", cmd.getCommandParams().get("command_timeout"));
+    Assert.assertEquals("10010", cmd.getCommandParams().get("command_timeout"));
     Type type = new TypeToken<Map<String, String>>(){}.getType();
     for (Stage stage : actionDB.getAllStages(response.getRequestId())){
       Map<String, String> commandParamsStage = StageUtils.getGson().fromJson(stage.getCommandParamsStage(), type);