AMBARI-20399. Unable to enable Credential store support on upgraded clusters (Madhuvanthi Radhakrishnan via smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ebd13828 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ebd13828 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ebd13828 Branch: refs/heads/branch-feature-AMBARI-12556 Commit: ebd13828f5057f8ac3813e61d6a22d706e331887 Parents: fd257ec Author: Sumit Mohanty <smoha...@hortonworks.com> Authored: Fri Mar 10 17:31:41 2017 -0800 Committer: Sumit Mohanty <smoha...@hortonworks.com> Committed: Fri Mar 10 17:32:14 2017 -0800 ---------------------------------------------------------------------- .../upgrade/StackUpgradeFinishListener.java | 14 +++++---- .../org/apache/ambari/server/state/Service.java | 7 +++++ .../apache/ambari/server/state/ServiceImpl.java | 33 ++++++++++++++++++-- .../package/scripts/hive_interactive.py | 3 +- .../upgrade/StackUpgradeFinishListenerTest.java | 1 + 5 files changed, 48 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd13828/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListener.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListener.java index b1bffef..1b3d05b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListener.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListener.java @@ -66,18 +66,20 @@ public class StackUpgradeFinishListener { Cluster cluster = event.getCluster(); - //update component info due to new stack for (Service service : cluster.getServices().values()) { - for (ServiceComponent sc : service.getServiceComponents().values()) { - try { + try { + //update service info due to new stack + service.updateServiceInfo(); + //update component info due to new stack + for (ServiceComponent sc : service.getServiceComponents().values()) { sc.updateComponentInfo(); - } catch (AmbariException e) { + } + } catch (AmbariException e) { if (LOG.isErrorEnabled()) { LOG.error("Caught AmbariException when update component info", e); } } } } - } -} + } http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd13828/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java index 70efeb5..5964e33 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java @@ -103,6 +103,13 @@ public interface Service { MaintenanceState getMaintenanceState(); /** + * Refresh Service info due to current stack + * @throws AmbariException + */ + void updateServiceInfo() throws AmbariException; + + + /** * Get a true or false value specifying * whether credential store is supported by this service. * @return true or false http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd13828/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java index 31c53d8..9caff6a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java @@ -27,6 +27,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import org.apache.ambari.server.AmbariException; +import org.apache.ambari.server.ObjectNotFoundException; import org.apache.ambari.server.ServiceComponentNotFoundException; import org.apache.ambari.server.api.services.AmbariMetaInfo; import org.apache.ambari.server.controller.ServiceResponse; @@ -67,9 +68,10 @@ public class ServiceImpl implements Service { private final Cluster cluster; private final ConcurrentMap<String, ServiceComponent> components = new ConcurrentHashMap<>(); - private final boolean isClientOnlyService; - private final boolean isCredentialStoreSupported; - private final boolean isCredentialStoreRequired; + private boolean isClientOnlyService; + private boolean isCredentialStoreSupported; + private boolean isCredentialStoreRequired; + private AmbariMetaInfo ambariMetaInfo; @Inject private ServiceConfigDAO serviceConfigDAO; @@ -108,6 +110,7 @@ public class ServiceImpl implements Service { this.stackDAO = stackDAO; this.eventPublisher = eventPublisher; this.serviceName = serviceName; + this.ambariMetaInfo = ambariMetaInfo; ClusterServiceEntity serviceEntity = new ClusterServiceEntity(); serviceEntity.setClusterId(cluster.getClusterId()); @@ -151,6 +154,7 @@ public class ServiceImpl implements Service { this.stackDAO = stackDAO; this.eventPublisher = eventPublisher; serviceName = serviceEntity.getServiceName(); + this.ambariMetaInfo = ambariMetaInfo; ServiceDesiredStateEntity serviceDesiredStateEntity = serviceEntity.getServiceDesiredStateEntity(); serviceDesiredStateEntityPK = getServiceDesiredStateEntityPK(serviceDesiredStateEntity); @@ -181,6 +185,29 @@ public class ServiceImpl implements Service { isCredentialStoreRequired = sInfo.isCredentialStoreRequired(); } + + /*** + * Refresh Service info due to current stack + * @throws AmbariException + */ + @Override + public void updateServiceInfo() throws AmbariException { + try { + ServiceInfo serviceInfo = ambariMetaInfo.getService(cluster.getDesiredStackVersion().getStackName(), + cluster.getDesiredStackVersion().getStackVersion(), getName()); + isClientOnlyService = serviceInfo.isClientOnlyService(); + isCredentialStoreSupported = serviceInfo.isCredentialStoreSupported(); + isCredentialStoreRequired = serviceInfo.isCredentialStoreRequired(); + + } catch (ObjectNotFoundException e) { + throw new RuntimeException("Trying to create a ServiceInfo" + + " not recognized in stack info" + + ", clusterName=" + cluster.getClusterName() + + ", serviceName=" + getName() + + ", stackInfo=" + cluster.getDesiredStackVersion().getStackName()); + } + } + @Override public String getName() { return serviceName; http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd13828/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_interactive.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_interactive.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_interactive.py index fa822f9..2ed3e3a 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_interactive.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_interactive.py @@ -78,7 +78,8 @@ def hive_interactive(name=None): 'hive.enforce.sorting'] # List of configs to be excluded from hive2 client, but present in Hive2 server. - exclude_list_for_hive2_client = ['javax.jdo.option.ConnectionPassword'] + exclude_list_for_hive2_client = ['javax.jdo.option.ConnectionPassword', + 'hadoop.security.credential.provider.path'] # Copy Tarballs in HDFS. if params.stack_version_formatted_major and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.stack_version_formatted_major): http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd13828/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListenerTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListenerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListenerTest.java index 1fa14df..34e3c70 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListenerTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackUpgradeFinishListenerTest.java @@ -81,6 +81,7 @@ public class StackUpgradeFinishListenerTest extends EasyMockSupport { expect(cluster.getServices()).andReturn(services); expect(service.getServiceComponents()).andReturn(components); serviceComponent.updateComponentInfo(); + service.updateServiceInfo(); } @Test