Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 4d3d57b64 -> 145438eca


AMBARI-22693. UpgradeUserKerberosDescriptor is not executed during stack 
upgrade due to missing target stack data (rlevas)


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

Branch: refs/heads/branch-2.6
Commit: 145438ecaf5d7f1e1930bb5b0623e4e8b9ad6023
Parents: 4d3d57b
Author: Robert Levas <[email protected]>
Authored: Tue Jan 2 12:20:48 2018 -0500
Committer: Robert Levas <[email protected]>
Committed: Tue Jan 2 12:20:48 2018 -0500

----------------------------------------------------------------------
 .../apache/ambari/server/agent/ExecutionCommand.java  |  2 --
 .../upgrades/UpgradeUserKerberosDescriptor.java       | 14 ++------------
 .../upgrades/UpgradeUserKerberosDescriptorTest.java   |  4 ++--
 3 files changed, 4 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/145438ec/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
index ffe2ed6..c05cc47 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
@@ -480,8 +480,6 @@ public class ExecutionCommand extends AgentCommand {
     String GROUP_LIST = "group_list";
     String USER_GROUPS = "user_groups";
     String NOT_MANAGED_HDFS_PATH_LIST = "not_managed_hdfs_path_list";
-    String SOURCE_STACK = "source_stack";
-    String TARGET_STACK = "target_stack";
     String REFRESH_TOPOLOGY = "refresh_topology";
     String HOST_SYS_PREPPED = "host_sys_prepped";
     String MAX_DURATION_OF_RETRIES = "max_duration_for_retries";

http://git-wip-us.apache.org/repos/asf/ambari/blob/145438ec/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptor.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptor.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptor.java
index a8c254a..f44f872 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptor.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptor.java
@@ -26,7 +26,6 @@ import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.agent.CommandReport;
-import org.apache.ambari.server.agent.ExecutionCommand.KeyNames;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.orm.dao.ArtifactDAO;
 import org.apache.ambari.server.orm.entities.ArtifactEntity;
@@ -101,7 +100,7 @@ public class UpgradeUserKerberosDescriptor extends 
AbstractServerAction {
 
       if (userDescriptor != null) {
         StackId originalStackId = cluster.getCurrentStackVersion();
-        StackId targetStackId = 
getStackIdFromCommandParams(KeyNames.TARGET_STACK);
+        StackId targetStackId = cluster.getDesiredStackVersion();
 
         if (isDowngrade()) {
           restoreDescriptor(foreignKeys, messages, errorMessages);
@@ -128,7 +127,7 @@ public class UpgradeUserKerberosDescriptor extends 
AbstractServerAction {
             logMessage(messages, String.format("Obtaining previous stack 
Kerberos descriptor for %s.", originalStackId.toString()));
             previousDescriptor = 
ambariMetaInfo.getKerberosDescriptor(originalStackId.getStackName(), 
originalStackId.getStackVersion(), false);
 
-            if (newDescriptor == null) {
+            if (previousDescriptor == null) {
               logErrorMessage(messages, errorMessages, String.format("The 
Kerberos descriptor for the previous stack version, %s, was not found.", 
originalStackId.toString()));
             }
           }
@@ -172,15 +171,6 @@ public class UpgradeUserKerberosDescriptor extends 
AbstractServerAction {
     return 
Direction.DOWNGRADE.name().equalsIgnoreCase(getCommandParameterValue(UPGRADE_DIRECTION_KEY));
   }
 
-  private StackId getStackIdFromCommandParams(String commandParamKey) {
-    String stackId = getCommandParameterValue(commandParamKey);
-    if (stackId == null) {
-      return null;
-    } else {
-      return new StackId(stackId);
-    }
-  }
-
   private void logMessage(List<String> messages, String message) {
     LOG.info(message);
     messages.add(message);

http://git-wip-us.apache.org/repos/asf/ambari/blob/145438ec/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptorTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptorTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptorTest.java
index 69d82b2..166bfad 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptorTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeUserKerberosDescriptorTest.java
@@ -65,6 +65,7 @@ public class UpgradeUserKerberosDescriptorTest {
 
   private TreeMap<String, Field> fields = new TreeMap<>();
   private StackId HDP_24 = new StackId("HDP", "2.4");
+  private StackId HDP_25 = new StackId("HDP", "2.5");
 
   @Before
   public void setup() throws Exception {
@@ -77,6 +78,7 @@ public class UpgradeUserKerberosDescriptorTest {
     expect(clusters.getCluster((String) 
anyObject())).andReturn(cluster).anyTimes();
     expect(cluster.getClusterId()).andReturn(1l).atLeastOnce();
     expect(cluster.getCurrentStackVersion()).andReturn(HDP_24).atLeastOnce();
+    expect(cluster.getDesiredStackVersion()).andReturn(HDP_25).atLeastOnce();
     replay(clusters, cluster);
 
     prepareFields();
@@ -89,7 +91,6 @@ public class UpgradeUserKerberosDescriptorTest {
     Map<String, String> commandParams = new HashMap<>();
     commandParams.put("clusterName", "c1");
     commandParams.put("upgrade_direction", "UPGRADE");
-    commandParams.put("target_stack", "HDP-2.5");
 
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);
@@ -146,7 +147,6 @@ public class UpgradeUserKerberosDescriptorTest {
     Map<String, String> commandParams = new HashMap<>();
     commandParams.put("clusterName", "c1");
     commandParams.put("upgrade_direction", "DOWNGRADE");
-    commandParams.put("target_stack", "HDP-2.5");
 
     ExecutionCommand executionCommand = new ExecutionCommand();
     executionCommand.setCommandParams(commandParams);

Reply via email to