You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2015/12/06 16:26:43 UTC
ambari git commit: AMBARI-14232. Kerberization fails if Hive is not
installed but Spark is installed without Spark TS (Sebastian Toader via
smohanty)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 cf03a2ba7 -> d13cd352d
AMBARI-14232. Kerberization fails if Hive is not installed but Spark is installed without Spark TS (Sebastian Toader via smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d13cd352
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d13cd352
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d13cd352
Branch: refs/heads/branch-2.2
Commit: d13cd352ddb093881020ffe6ea029fa12bae5dfb
Parents: cf03a2b
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Sun Dec 6 07:26:28 2015 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Sun Dec 6 07:26:28 2015 -0800
----------------------------------------------------------------------
.../server/controller/KerberosHelperImpl.java | 56 ++++++++++++++++++--
.../org/apache/ambari/server/state/Cluster.java | 6 +++
.../server/state/cluster/ClusterImpl.java | 22 ++++++++
.../server/controller/KerberosHelperTest.java | 6 ++-
4 files changed, 83 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/d13cd352/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
index 06e65e3..2ab3125 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
@@ -37,6 +37,7 @@ import java.util.regex.Pattern;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.Role;
import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.ServiceComponentNotFoundException;
import org.apache.ambari.server.actionmanager.ActionManager;
import org.apache.ambari.server.actionmanager.RequestFactory;
import org.apache.ambari.server.actionmanager.Stage;
@@ -97,6 +98,7 @@ import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.SecurityState;
import org.apache.ambari.server.state.SecurityType;
import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.state.State;
@@ -410,7 +412,7 @@ public class KerberosHelperImpl implements KerberosHelper {
for (KerberosServiceDescriptor service : services.values()) {
if (installedServices.containsKey(service.getName())) {
-
+ Service svc = installedServices.get(service.getName());
addIdentities(authToLocalBuilder, service.getIdentities(true), null, existingConfigurations);
authToLocalProperties = service.getAuthToLocalProperties();
@@ -420,13 +422,57 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, KerberosComponentDescriptor> components = service.getComponents();
if (components != null) {
+ Map<String,ServiceComponent> serviceComponents = svc.getServiceComponents();
+
for (KerberosComponentDescriptor component : components.values()) {
- addIdentities(authToLocalBuilder, component.getIdentities(true), null, existingConfigurations);
+ // When the cluster is provisioned by a Blueprint service components with
+ // cardinality 0+ might be left out from the Blueprint thus we have to check
+ // if they exist
+ ServiceComponent svcComp = null;
+ if (!serviceComponents.containsKey(component.getName()))
+ continue;
+
+ svcComp = serviceComponents.get(component.getName());
+
+ boolean addSvcCompIdentities = false;
+
+ if (cluster.isBluePrintDeployed())
+ {
+ if (svcComp.getDesiredState() == State.INSTALLED || svcComp.getDesiredState() == State.STARTED)
+ addSvcCompIdentities = true;
+ }
+ else {
+
+ // Since when the cluster is deployed through the UI ALL service components of the selected services are created
+ // with desired state INSTALLED regardless whether the service components were associated with hosts or not thus
+ // we can not determine if the component is installed or not.
+ // We rather look at service compoent hosts
+ for (ServiceComponentHost svcCompHost: svcComp.getServiceComponentHosts().values()) {
+ if (svcCompHost.getDesiredState() != State.UNKNOWN
+ && svcCompHost.getDesiredState() != State.UNINSTALLING
+ && svcCompHost.getDesiredState() != State.UNINSTALLED
+ && svcCompHost.getDesiredState() != State.INSTALL_FAILED
+ && svcCompHost.getDesiredState() != State.WIPING_OUT) {
+
+ // If there is at least a host that contains the component add the identities
+ addSvcCompIdentities = true;
+ break;
+ }
+ }
+ }
+
+ if (addSvcCompIdentities) {
+ LOG.info("Adding identity for " + component.getName() + " to auth to local mapping");
+ addIdentities(authToLocalBuilder, component.getIdentities(true), null, existingConfigurations);
+
+ authToLocalProperties = component.getAuthToLocalProperties();
+ if (authToLocalProperties != null) {
+ authToLocalPropertiesToSet.addAll(authToLocalProperties);
- authToLocalProperties = component.getAuthToLocalProperties();
- if (authToLocalProperties != null) {
- authToLocalPropertiesToSet.addAll(authToLocalProperties);
+ }
}
+
+
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d13cd352/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index c3cc8b8..3aaa9a5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -613,4 +613,10 @@ public interface Cluster {
* Clear cluster caches and re-read data from database
*/
void invalidateData();
+
+ /**
+ * Returns whether this cluster was provisioned by a Blueprint or not.
+ * @return true if the cluster was deployed with a Blueprint otherwise false.
+ */
+ boolean isBluePrintDeployed();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d13cd352/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 8035d4d..a556db8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -22,6 +22,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -86,6 +87,7 @@ import org.apache.ambari.server.orm.entities.RequestScheduleEntity;
import org.apache.ambari.server.orm.entities.ResourceEntity;
import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.orm.entities.TopologyRequestEntity;
import org.apache.ambari.server.security.authorization.AuthorizationHelper;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.ClusterHealthReport;
@@ -118,6 +120,7 @@ import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
import org.apache.ambari.server.state.scheduler.RequestExecution;
import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostSummary;
+import org.apache.ambari.server.topology.TopologyRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -3176,6 +3179,25 @@ public class ClusterImpl implements Cluster {
}
}
+ /**
+ * Returns whether this cluster was provisioned by a Blueprint or not.
+ * @return true if the cluster was deployed with a Blueprint otherwise false.
+ */
+ @Override
+ public boolean isBluePrintDeployed() {
+
+ List<TopologyRequestEntity> topologyRequests = topologyRequestDAO.findByClusterId(getClusterId());
+
+ // Iterate through the topology requests associated with this cluster and look for PROVISION request
+ for (TopologyRequestEntity topologyRequest: topologyRequests) {
+ TopologyRequest.Type requestAction = TopologyRequest.Type.valueOf(topologyRequest.getAction());
+ if (requestAction == TopologyRequest.Type.PROVISION)
+ return true;
+ }
+
+ return false;
+ }
+
private ClusterEntity getClusterEntity() {
if (!clusterDAO.isManaged(clusterEntity)) {
clusterEntity = clusterDAO.findById(clusterEntity.getClusterId());
http://git-wip-us.apache.org/repos/asf/ambari/blob/d13cd352/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
index 35a3a74..cf6bc93 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
@@ -1851,7 +1851,7 @@ public class KerberosHelperTest extends EasyMockSupport {
// expect(identityDescriptor3.getName()).andReturn("3").times(1);
final KerberosServiceDescriptor serviceDescriptor1 = createMock(KerberosServiceDescriptor.class);
- expect(serviceDescriptor1.getName()).andReturn("SERVICE1").times(1);
+ expect(serviceDescriptor1.getName()).andReturn("SERVICE1").times(2);
expect(serviceDescriptor1.getIdentities(true)).andReturn(Arrays.asList(
identityDescriptor1,
identityDescriptor2,
@@ -2189,7 +2189,7 @@ public class KerberosHelperTest extends EasyMockSupport {
final Service service3 = createMockService("SERVICE3",
new HashMap<String, ServiceComponent>() {
{
- put("COMPONENT2A", createMockComponent("COMPONENT3A", true,
+ put("COMPONENT3A", createMockComponent("COMPONENT3A", true,
new HashMap<String, ServiceComponentHost>() {
{
put("hostA", createMockServiceComponentHost());
@@ -2212,6 +2212,7 @@ public class KerberosHelperTest extends EasyMockSupport {
put("SERVICE3", service3);
}
}).anyTimes();
+ expect(cluster.isBluePrintDeployed()).andReturn(false).atLeastOnce();
final Map<String, Map<String, String>> existingConfigurations = new HashMap<String, Map<String, String>>() {
{
@@ -3620,6 +3621,7 @@ public class KerberosHelperTest extends EasyMockSupport {
private ServiceComponentHost createMockServiceComponentHost() {
ServiceComponentHost serviceComponentHost = createMock(ServiceComponentHost.class);
+ expect(serviceComponentHost.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
return serviceComponentHost;
}