Repository: ambari Updated Branches: refs/heads/branch-2.6 128c7fb5f -> 6db752cb0 refs/heads/trunk ff08592a3 -> 19e6518d4
AMBARI-22550. Service install/start failure due to wrong version directory Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6db752cb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6db752cb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6db752cb Branch: refs/heads/branch-2.6 Commit: 6db752cb0c2f6b024d85a597f1385a9c2189ad2a Parents: 128c7fb Author: Doroszlai, Attila <[email protected]> Authored: Wed Nov 29 19:02:32 2017 +0100 Committer: Doroszlai, Attila <[email protected]> Committed: Thu Nov 30 09:01:05 2017 +0100 ---------------------------------------------------------------------- .../actionmanager/ExecutionCommandWrapper.java | 5 +++++ .../actionmanager/ExecutionCommandWrapperTest.java | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6db752cb/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java index 212363b..f9935bd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java @@ -302,7 +302,12 @@ public class ExecutionCommandWrapper { if (null != repositoryVersion) { // only set the version if it's not set and this is NOT an install // command + // Some stack scripts use version for path purposes. Sending unresolved version first (for + // blueprints) and then resolved one would result in various issues: duplicate directories + // (/hdp/apps/2.6.3.0 + /hdp/apps/2.6.3.0-235), parent directory not found, and file not + // found, etc. Hence requiring repositoryVersion to be resolved. if (!commandParams.containsKey(VERSION) + && repositoryVersion.isResolved() && executionCommand.getRoleCommand() != RoleCommand.INSTALL) { commandParams.put(VERSION, repositoryVersion.getVersion()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/6db752cb/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java index 7630c55..2efc7a7 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java @@ -318,8 +318,7 @@ public class ExecutionCommandWrapperTest { commandParams = processedExecutionCommand.getCommandParams(); Assert.assertFalse(commandParams.containsKey(KeyNames.VERSION)); - // now try with a START command which should populate the version even - // though the state is INSTALLING + // now try with a START command, but still unresolved executionCommand = new ExecutionCommand(); commandParams = new HashMap<>(); @@ -340,6 +339,17 @@ public class ExecutionCommandWrapperTest { processedExecutionCommand = execCommWrap.getExecutionCommand(); commandParams = processedExecutionCommand.getCommandParams(); + Assert.assertFalse(commandParams.containsKey(KeyNames.VERSION)); + + // now that the repositoryVersion is resolved, it should populate the version even + // though the state is INSTALLING + repositoryVersion.setResolved(true); + ormTestHelper.repositoryVersionDAO.merge(repositoryVersion); + execCommWrap = new ExecutionCommandWrapper(json); + injector.injectMembers(execCommWrap); + + processedExecutionCommand = execCommWrap.getExecutionCommand(); + commandParams = processedExecutionCommand.getCommandParams(); Assert.assertEquals("0.1-0000", commandParams.get(KeyNames.VERSION)); } @@ -352,6 +362,7 @@ public class ExecutionCommandWrapperTest { StackId stackId = cluster.getDesiredStackVersion(); RepositoryVersionEntity repositoryVersion = ormTestHelper.getOrCreateRepositoryVersion(stackId, "0.1-0000"); + repositoryVersion.setResolved(true); // has build number Service service = cluster.getService("HDFS"); service.setDesiredRepositoryVersion(repositoryVersion);
