[ambari] branch branch-2.7 updated: [AMBARI-25186] Kerberos Client is unnecessarily installed via Blueprints when kerberos-env/kdc-type is none (payert) (#2866)

2019-03-20 Thread benyoka
This is an automated email from the ASF dual-hosted git repository.

benyoka pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
 new 97c84a7  [AMBARI-25186] Kerberos Client is unnecessarily installed via 
Blueprints when kerberos-env/kdc-type is none (payert) (#2866)
97c84a7 is described below

commit 97c84a7205c23a5efd17c2f0cab4e223d832b6c3
Author: payert <35402259+pay...@users.noreply.github.com>
AuthorDate: Wed Mar 20 18:18:22 2019 +0100

[AMBARI-25186] Kerberos Client is unnecessarily installed via Blueprints 
when kerberos-env/kdc-type is none (payert) (#2866)

* AMBARI-25186 add Kerberos client only if kdc_type is not none (payert)

Change-Id: I3921f9dabeec26878c3c63a916234a188d37e322

* AMBARI-25186 Refactor to extract isKerberosClientInstallAllowed() common 
method.

Change-Id: Ifebac4341160a24a375e915dc604abff650eccf8

* AMBARI-25186 fix import related checkstyle errors

Change-Id: Id5e1018cf4ea57b61432b91f6d36ce2694cd0375

* AMBARI-25186 fix imports

Change-Id: I05579f5ac8afa4fb1959724fe4d5f4e9c95ab54f

* AMBARI-25186 unit tests added

Change-Id: I07a3bde016e3c0c435ba98fe89185f8593032de0

* AMBARI-25186 constant is used for "none" kdc_type value

Change-Id: I03a2c432b1fa77b421350e9e2ad2b98fd0a0945c
---
 .../ambari/server/topology/TopologyManager.java| 28 ++--
 .../server/topology/TopologyManagerTest.java   | 84 --
 2 files changed, 103 insertions(+), 9 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index 7ca1c1d..ca6c902 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -43,6 +43,7 @@ import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariServer;
+import org.apache.ambari.server.controller.KerberosHelper;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
 import org.apache.ambari.server.controller.internal.BaseClusterRequest;
@@ -71,6 +72,7 @@ import org.apache.ambari.server.orm.dao.SettingDAO;
 import org.apache.ambari.server.orm.entities.SettingEntity;
 import org.apache.ambari.server.orm.entities.StageEntity;
 import org.apache.ambari.server.security.authorization.AuthorizationHelper;
+import org.apache.ambari.server.serveraction.kerberos.KDCType;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.host.HostImpl;
@@ -205,13 +207,12 @@ public class TopologyManager {
   replayRequests(persistedState.getAllRequests());
   // ensure KERBEROS_CLIENT is present in each hostgroup even if it's 
not in original BP
   for(ClusterTopology clusterTopology : clusterTopologyMap.values()) {
-if (clusterTopology.isClusterKerberosEnabled()) {
-  addKerberosClient(clusterTopology);
+if (clusterTopology.isClusterKerberosEnabled() && 
isKerberosClientInstallAllowed(clusterTopology)) {
+addKerberosClient(clusterTopology);
 }
   }
   isInitialized = true;
 }
-
   }
 }
   }
@@ -292,7 +293,10 @@ public class TopologyManager {
 
 if (securityConfiguration != null && securityConfiguration.getType() == 
SecurityType.KERBEROS) {
   securityType = SecurityType.KERBEROS;
-  addKerberosClient(topology);
+
+  if (isKerberosClientInstallAllowed(topology)) {
+addKerberosClient(topology);
+  }
 
   // refresh default stack config after adding KERBEROS_CLIENT component 
to topology
   
topology.getBlueprint().getConfiguration().setParentConfiguration(stack.getConfiguration(topology.getBlueprint().getServices()));
@@ -356,6 +360,22 @@ public class TopologyManager {
 return getRequestStatus(logicalRequest.getRequestId());
   }
 
+  /**
+   * The Kerberos Client component is unnecessarily installed via Blueprints 
when kerberos-env/kdc-type is "none".
+   * The Blueprint TopologyManager should only force the Kerberos client to be 
installed if Kerberos is enabled
+   * and kerberos_env/kdc_type is not "none" or when 
kerberos_env/manage_identities is true.
+   *
+   * @param topology the Cluster Topology which provides the topology's 
Configuration object.
+   * @return true if kerberos_env/kdc_type is not "none" or when 

[ambari] branch branch-2.7 updated: AMBARI-25198. MYSQL connector exception while upgrading ambari to ambari-2.7.3. (mpapirkovskyy) (#2877)

2019-03-20 Thread mpapirkovskyy
This is an automated email from the ASF dual-hosted git repository.

mpapirkovskyy pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
 new ed80f7a  AMBARI-25198. MYSQL connector exception while upgrading 
ambari to ambari-2.7.3. (mpapirkovskyy) (#2877)
ed80f7a is described below

commit ed80f7add8a4cc02192671647d7cda2c8f938797
Author: Myroslav Papirkovskyi 
AuthorDate: Wed Mar 20 17:51:16 2019 +0200

AMBARI-25198. MYSQL connector exception while upgrading ambari to 
ambari-2.7.3. (mpapirkovskyy) (#2877)
---
 .../apache/ambari/server/orm/DBAccessorImpl.java| 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
index 34f44f6..b52c3b8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
@@ -39,6 +39,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 import org.apache.ambari.server.configuration.Configuration;
@@ -76,6 +77,11 @@ import com.google.inject.Singleton;
 @Singleton
 public class DBAccessorImpl implements DBAccessor {
   private static final Logger LOG = 
LoggerFactory.getLogger(DBAccessorImpl.class);
+  public static final String USER = "user";
+  public static final String PASSWORD = "password";
+  public static final String NULL_CATALOG_MEANS_CURRENT = 
"nullCatalogMeansCurrent";
+  public static final String TRUE = "true";
+  public static final int SUPPORT_CONNECTOR_VERSION = 5;
   private final DatabasePlatform databasePlatform;
   private final Connection connection;
   private final DbmsHelper dbmsHelper;
@@ -92,9 +98,7 @@ public class DBAccessorImpl implements DBAccessor {
 try {
   Class.forName(configuration.getDatabaseDriver());
 
-  connection = DriverManager.getConnection(configuration.getDatabaseUrl(),
-  configuration.getDatabaseUser(),
-  configuration.getDatabasePassword());
+  connection = getNewConnection();
 
   connection.setAutoCommit(true); //enable autocommit
 
@@ -153,9 +157,14 @@ public class DBAccessorImpl implements DBAccessor {
   @Override
   public Connection getNewConnection() {
 try {
-  return DriverManager.getConnection(configuration.getDatabaseUrl(),
-  configuration.getDatabaseUser(),
-  configuration.getDatabasePassword());
+  Properties properties = new Properties();
+  properties.setProperty(USER, configuration.getDatabaseUser());
+  properties.setProperty(PASSWORD, configuration.getDatabasePassword());
+  if (configuration.getDatabaseUrl().contains("mysql")
+  && 
DriverManager.getDriver(configuration.getDatabaseUrl()).getMajorVersion() > 
SUPPORT_CONNECTOR_VERSION) {
+properties.setProperty(NULL_CATALOG_MEANS_CURRENT, TRUE);// jdbc mysql 
connector 8.x turn on legacy behaviour
+  }
+  return 
DriverManager.getConnection(configuration.getDatabaseUrl(),properties);
 } catch (SQLException e) {
   throw new RuntimeException("Unable to connect to database", e);
 }



[ambari] branch trunk updated: [AMBARI-25197] NullPointerException if there is no proper HDP/HDF rep… (#2873)

2019-03-20 Thread ncole
This is an automated email from the ASF dual-hosted git repository.

ncole pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
 new 2bc4779  [AMBARI-25197] NullPointerException if there is no proper 
HDP/HDF rep… (#2873)
2bc4779 is described below

commit 2bc4779a1e6aabe638101fc8b0e28cd1963d6b13
Author: amarnathreddy pappu 
AuthorDate: Wed Mar 20 05:42:22 2019 -0700

[AMBARI-25197] NullPointerException if there is no proper HDP/HDF rep… 
(#2873)
---
 .../server/stack/UpdateActiveRepoVersionOnStartup.java  | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/UpdateActiveRepoVersionOnStartup.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/UpdateActiveRepoVersionOnStartup.java
index 6ba1f94..7af2c93 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/UpdateActiveRepoVersionOnStartup.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/UpdateActiveRepoVersionOnStartup.java
@@ -88,10 +88,15 @@ public class UpdateActiveRepoVersionOnStartup {
 
   StackId stackId = repositoryVersion.getStackId();
   StackInfo stack = stackManager.getStack(stackId.getStackName(), 
stackId.getStackVersion());
-
-  if (updateRepoVersion(stack, repositoryVersion)) {
-repositoryVersionDao.merge(repositoryVersion);
-  }
+
+  if (stack !=null) {
+if (updateRepoVersion(stack, repositoryVersion)) {
+  repositoryVersionDao.merge(repositoryVersion);
+}
+  } else {
+   throw new AmbariException(String.format("Stack %s %s was not found 
on the file system. In the event that it was removed, " +
+  "please ensure that it exists before starting Ambari Server.",  
stackId.getStackName(), stackId.getStackVersion()));
+  } 
 }
   }
 }