Skip to content

Commit

Permalink
AMBARI-18804. Manage Ambari principals should be set to off when upgr…
Browse files Browse the repository at this point in the history
…ading Ambari from versions < 2.4.0 (rlevas)

(cherry picked from commit fb86a2b)

Change-Id: Id1343c58cb969612fa72b66084619ae7dab81f55
  • Loading branch information
rlevas authored and horton-works-spark committed Nov 9, 2016
1 parent ee6806c commit f28d376
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package org.apache.ambari.server.upgrade;

import com.google.common.collect.Lists;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -48,7 +46,6 @@
import org.apache.ambari.server.orm.dao.RoleAuthorizationDAO;
import org.apache.ambari.server.orm.dao.UserDAO;
import org.apache.ambari.server.orm.dao.ViewInstanceDAO;
import org.apache.ambari.server.orm.dao.WidgetDAO;
import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
import org.apache.ambari.server.orm.entities.ArtifactEntity;
import org.apache.ambari.server.orm.entities.ClusterEntity;
Expand All @@ -64,7 +61,6 @@
import org.apache.ambari.server.orm.entities.UserEntity;
import org.apache.ambari.server.orm.entities.ViewEntityEntity;
import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
import org.apache.ambari.server.orm.entities.WidgetEntity;
import org.apache.ambari.server.security.authorization.ResourceType;
import org.apache.ambari.server.security.authorization.User;
import org.apache.ambari.server.security.authorization.Users;
Expand All @@ -87,8 +83,6 @@
import org.apache.ambari.server.state.kerberos.KerberosKeytabDescriptor;
import org.apache.ambari.server.state.kerberos.KerberosPrincipalDescriptor;
import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor;
import org.apache.ambari.server.state.stack.WidgetLayout;
import org.apache.ambari.server.state.stack.WidgetLayoutInfo;
import org.apache.ambari.server.view.DefaultMasker;
import org.apache.ambari.view.ClusterType;
import org.apache.ambari.view.MaskException;
Expand All @@ -100,9 +94,6 @@
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Type;
import java.sql.Clob;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -2216,10 +2207,17 @@ protected void updateKerberosConfigs() throws AmbariException {
// Update the kerberos-env properties to change kdc_host to kdc_hosts
config = cluster.getDesiredConfigByType("kerberos-env");
if (config != null) {
Map<String, String> updates = new HashMap<String, String>();
Set<String> removes = new HashSet<String>();

// Rename kdc_host to kdc_hosts
String value = config.getProperties().get("kdc_host");
Map<String, String> updates = Collections.singletonMap("kdc_hosts", value);
Set<String> removes = Collections.singleton("kdc_host");
updates.put("kdc_hosts", value);
removes.add("kdc_host");

// Ensure create_ambari_principal is set to "false" since it is expected that Ambari's
// principal, keytab file, and JAAS file has already been manually configured.
updates.put("create_ambari_principal", "false");

updateConfigurationPropertiesForCluster(cluster, "kerberos-env", updates, removes, true, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1547,10 +1547,13 @@ protected void configure() {
Assert.assertNotNull(capturedCRProperties);
Assert.assertFalse(capturedCRProperties.containsKey("kdc_host"));
Assert.assertTrue(capturedCRProperties.containsKey("kdc_hosts"));
Assert.assertTrue(capturedCRProperties.containsKey("create_ambari_principal"));

for (String property : propertiesKerberosEnv.keySet()) {
if ("kdc_host".equals(property)) {
Assert.assertEquals(property, propertiesKerberosEnv.get(property), capturedCRProperties.get("kdc_hosts"));
} else if ("create_ambari_principal".equals(property)) {
Assert.assertEquals(property, propertiesKerberosEnv.get(property), "false");
} else {
Assert.assertEquals(property, propertiesKerberosEnv.get(property), capturedCRProperties.get(property));
}
Expand Down Expand Up @@ -1679,10 +1682,13 @@ protected void configure() {
Assert.assertNotNull(capturedCRProperties);
Assert.assertFalse(capturedCRProperties.containsKey("kdc_host"));
Assert.assertTrue(capturedCRProperties.containsKey("kdc_hosts"));
Assert.assertTrue(capturedCRProperties.containsKey("create_ambari_principal"));

for (String property : propertiesKerberosEnv.keySet()) {
if ("kdc_host".equals(property)) {
Assert.assertEquals(property, propertiesKerberosEnv.get(property), capturedCRProperties.get("kdc_hosts"));
} else if ("create_ambari_principal".equals(property)) {
Assert.assertEquals(property, propertiesKerberosEnv.get(property), "false");
} else {
Assert.assertEquals(property, propertiesKerberosEnv.get(property), capturedCRProperties.get(property));
}
Expand Down

0 comments on commit f28d376

Please sign in to comment.