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/19e6518d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/19e6518d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/19e6518d Branch: refs/heads/branch-3.0-perf Commit: 19e6518d42170a33ca2e0161ec2d3abb5190f976 Parents: ff08592 Author: Doroszlai, Attila <adorosz...@hortonworks.com> Authored: Wed Nov 29 19:02:32 2017 +0100 Committer: Doroszlai, Attila <adorosz...@hortonworks.com> Committed: Thu Nov 30 09:02:46 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/19e6518d/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 7b693cd..191e86c 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 @@ -297,7 +297,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/19e6518d/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 fb84df5..f12c701 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 @@ -312,8 +312,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<>(); @@ -334,6 +333,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)); } @@ -346,6 +356,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);