ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject [05/21] ambari git commit: AMBARI-21480. NPE during "Update Kerberos Descriptor" (rlevas)
Date Wed, 19 Jul 2017 12:38:58 GMT
AMBARI-21480. NPE during "Update Kerberos Descriptor" (rlevas)


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

Branch: refs/heads/branch-feature-AMBARI-20859
Commit: 0a8c397bd1944b8787befdff08bf6b95b9afb225
Parents: 4e1da58
Author: Robert Levas <rlevas@hortonworks.com>
Authored: Fri Jul 14 16:42:16 2017 -0400
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Fri Jul 14 16:42:16 2017 -0400

----------------------------------------------------------------------
 .../KerberosDescriptorUpdateHelper.java         |  9 ++-
 .../KerberosDescriptorUpdateHelperTest.java     | 70 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0a8c397b/ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelper.java
index f05b62b..dd865be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelper.java
@@ -340,6 +340,11 @@ public class KerberosDescriptorUpdateHelper {
   /**
    * Processes a {@link KerberosIdentityDescriptor} to change the user-supplied data based
on the changes
    * observed between the previous stack version's data and the new stack version's data.
+   * <p>
+   * It is expected that <code>newStackIdentities</code> and <code>userIdentities</code>
are not null.
+   * However, <code>previousStackIdentities</code> may be null in the event the
user added a Kerberos
+   * identity that was then added in the new Kerberos descriptor.  In this case, the user's
values
+   * for the principal name and keytab file are kept while adding any other changes from
tne new stack.
    *
    * @param previousStackIdentity a {@link KerberosIdentityDescriptor} from the previous
stack version's Kerberos descriptor
    * @param newStackIdentity      a {@link KerberosIdentityDescriptor} from the new stack
version's Kerberos descriptor
@@ -357,7 +362,7 @@ public class KerberosDescriptorUpdateHelper {
     // If the new identity definition is a reference and no longer has a principal definition,
     // Ignore any user changes to the old principal definition.
     if (updatedValuePrincipal != null) {
-      KerberosPrincipalDescriptor oldValuePrincipal = previousStackIdentity.getPrincipalDescriptor();
+      KerberosPrincipalDescriptor oldValuePrincipal = (previousStackIdentity == null) ? null
: previousStackIdentity.getPrincipalDescriptor();
       String previousValuePrincipalValue = null;
       KerberosPrincipalDescriptor userValuePrincipal = userIdentity.getPrincipalDescriptor();
       String userValuePrincipalValue = null;
@@ -380,7 +385,7 @@ public class KerberosDescriptorUpdateHelper {
     // If the new identity definition is a reference and no longer has a keytab definition,
     // Ignore any user changes to the old keytab definition.
     if (updatedValueKeytab != null) {
-      KerberosKeytabDescriptor oldValueKeytab = previousStackIdentity.getKeytabDescriptor();
+      KerberosKeytabDescriptor oldValueKeytab = (previousStackIdentity == null) ? null :
previousStackIdentity.getKeytabDescriptor();
       String previousValueKeytabFile = null;
       KerberosKeytabDescriptor userValueKeytab = userIdentity.getKeytabDescriptor();
       String userValueKeytabFile = null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a8c397b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java
index 247d17e..e717190 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java
@@ -272,6 +272,16 @@ public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport
{
             "      \"keytab\": {" +
             "        \"file\": \"${keytab_dir}/ambari.server.keytab\"" +
             "      }" +
+            "    }," +
+            "    {" +
+            "      \"name\": \"future_identity\"," +
+            "      \"principal\": {" +
+            "        \"value\": \"CHANGED_future${principal_suffix}@${realm}\"," +
+            "        \"type\": \"user\"" +
+            "      }," +
+            "      \"keytab\": {" +
+            "        \"file\": \"${keytab_dir}/future.user.keytab\"" +
+            "      }" +
             "    }" +
             "  ]" +
             "}");
@@ -328,6 +338,26 @@ public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport
{
             "      \"keytab\": {" +
             "        \"file\": \"${keytab_dir}/ambari.server.keytab\"" +
             "      }" +
+            "    }," +
+            "    {" +
+            "      \"name\": \"custom_identity\"," +
+            "      \"principal\": {" +
+            "        \"value\": \"custom${principal_suffix}@${realm}\"," +
+            "        \"type\": \"user\"" +
+            "      }," +
+            "      \"keytab\": {" +
+            "        \"file\": \"${keytab_dir}/custom.user.keytab\"" +
+            "      }" +
+            "    }," +
+            "    {" +
+            "      \"name\": \"future_identity\"," +
+            "      \"principal\": {" +
+            "        \"value\": \"future${principal_suffix}@${realm}\"," +
+            "        \"type\": \"user\"" +
+            "      }," +
+            "      \"keytab\": {" +
+            "        \"file\": \"${keytab_dir}/future.user.keytab\"" +
+            "      }" +
             "    }" +
             "  ]" +
             "}");
@@ -343,6 +373,26 @@ public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport
{
             "{\n" +
                 "  \"identities\": [\n" +
                 "    {\n" +
+                "      \"name\": \"future_identity\",\n" +
+                "      \"principal\": {\n" +
+                "        \"value\": \"future${principal_suffix}@${realm}\",\n" +
+                "        \"type\": \"user\"\n" +
+                "      },\n" +
+                "      \"keytab\": {\n" +
+                "        \"file\": \"${keytab_dir}/future.user.keytab\"\n" +
+                "      }\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"name\": \"custom_identity\",\n" +
+                "      \"principal\": {\n" +
+                "        \"value\": \"custom${principal_suffix}@${realm}\",\n" +
+                "        \"type\": \"user\"\n" +
+                "      },\n" +
+                "      \"keytab\": {\n" +
+                "        \"file\": \"${keytab_dir}/custom.user.keytab\"\n" +
+                "      }\n" +
+                "    },\n" +
+                "    {\n" +
                 "      \"name\": \"spnego\",\n" +
                 "      \"principal\": {\n" +
                 "        \"value\": \"CHANGED_HTTP/_HOST@${realm}\",\n" +
@@ -405,6 +455,26 @@ public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport
{
                 "      }\n" +
                 "    },\n" +
                 "    {\n" +
+                "      \"name\": \"custom_identity\",\n" +
+                "      \"principal\": {\n" +
+                "        \"value\": \"custom${principal_suffix}@${realm}\",\n" +
+                "        \"type\": \"user\"\n" +
+                "      },\n" +
+                "      \"keytab\": {\n" +
+                "        \"file\": \"${keytab_dir}/custom.user.keytab\"\n" +
+                "      }\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"name\": \"future_identity\",\n" +
+                "      \"principal\": {\n" +
+                "        \"value\": \"future${principal_suffix}@${realm}\",\n" +
+                "        \"type\": \"user\"\n" +
+                "      },\n" +
+                "      \"keytab\": {\n" +
+                "        \"file\": \"${keytab_dir}/future.user.keytab\"\n" +
+                "      }\n" +
+                "    },\n" +
+                "    {\n" +
                 "      \"name\": \"spnego\",\n" +
                 "      \"principal\": {\n" +
                 "        \"value\": \"CHANGED_HTTP/_HOST@${realm}\",\n" +


Mime
View raw message