This is an automated email from the ASF dual-hosted git repository.

aonishuk 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 9732d6d  AMBARI-23680 Installing hive with "New mysql database" fails
9732d6d is described below

commit 9732d6d1180bc012473fee55b2126dbc74763109
Author: majorendre <[email protected]>
AuthorDate: Thu Apr 26 09:34:20 2018 +0200

    AMBARI-23680 Installing hive with "New mysql database" fails
---
 .../src/main/python/ambari_server/serverSetup.py   | 33 ++++++++++++++--------
 .../HIVE/0.12.0.2.0/package/scripts/hive.py        |  3 +-
 .../stacks/2.0.6/HIVE/test_hive_metastore.py       | 22 +++++++++++----
 .../python/stacks/2.0.6/HIVE/test_hive_server.py   | 12 ++++++--
 .../python/stacks/2.1/HIVE/test_hive_metastore.py  | 24 +++++++++++++---
 .../python/stacks/2.5/HIVE/test_hive_server_int.py |  6 +++-
 6 files changed, 75 insertions(+), 25 deletions(-)

diff --git a/ambari-server/src/main/python/ambari_server/serverSetup.py 
b/ambari-server/src/main/python/ambari_server/serverSetup.py
index d2e7cf0..63e254f 100644
--- a/ambari-server/src/main/python/ambari_server/serverSetup.py
+++ b/ambari-server/src/main/python/ambari_server/serverSetup.py
@@ -945,28 +945,37 @@ def _cache_jdbc_driver(args):
   custom_db_jdbc_property_name = "custom." + args.jdbc_db + ".jdbc.name"
   custom_db_jdbc_property_value = properties[custom_db_jdbc_property_name]
 
+  symlink_name = os.path.join(resources_dir, 
default_connectors_map[args.jdbc_db])
+
   if custom_db_jdbc_property_value:
     properties.process_pair("previous." + custom_db_jdbc_property_name, 
custom_db_jdbc_property_value)
   else:
-    if args.jdbc_driver.endswith(TAR_GZ_ARCHIVE_TYPE):
-      symlink_name = args.jdbc_db + "-jdbc-driver" + TAR_GZ_ARCHIVE_TYPE
-    else:
-      symlink_name = args.jdbc_db + "-jdbc-driver.jar"
-
-    if os.path.lexists(os.path.join(resources_dir, symlink_name)):
+    if os.path.lexists(symlink_name):
       properties.process_pair("previous." + custom_db_jdbc_property_name, 
default_connectors_map[args.jdbc_db])
 
   properties.process_pair(custom_db_jdbc_property_name, jdbc_name)
 
-  if os.path.isfile(os.path.join(resources_dir, jdbc_name)):
-    os.remove(os.path.join(resources_dir, jdbc_name))
+  dest = os.path.join(resources_dir, jdbc_name)
+  if os.path.isfile(dest):
+    os.remove(dest)
+
+  try:
+    shutil.copy(args.jdbc_driver, dest)
+    print "Copying {0} to {1}".format(args.jdbc_driver, dest)
+  except Exception, e:
+    err = "Cannot copy file {0} to {1} due to: {2} . Please check file " \
+          "permissions and free disk space.".format(args.jdbc_driver, dest, 
str(e))
+    raise FatalException(1, err)
 
   try:
-    shutil.copy(args.jdbc_driver, resources_dir)
-    print "Copying {0} to {1}".format(args.jdbc_driver, resources_dir)
+    if (dest != symlink_name):
+      if os.path.isfile(symlink_name):
+        os.remove(symlink_name)
+      os.symlink(dest, symlink_name)
+      print "Creating symlink {0} to {1}".format(dest, symlink_name)
   except Exception, e:
-    err = "Can not copy file {0} to {1} due to: {2} . Please check file " \
-          "permissions and free disk space.".format(args.jdbc_driver, 
resources_dir, str(e))
+    err = "Cannot create symlink {0} to {1} due to: {2} . Please check file " \
+          "permissions and free disk space.".format(dest, symlink_name, str(e))
     raise FatalException(1, err)
 
   update_properties(properties)
diff --git 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
index 3cb7753..d023339 100644
--- 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
+++ 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
@@ -504,7 +504,8 @@ def jdbc_connector(target, hive_previous_jdbc_jar):
 
   else:
     #for default hive db (Mysql)
-    Execute(('cp', '--remove-destination', 
format('/usr/share/java/{jdbc_jar_name}'), target),
+    File(params.downloaded_custom_connector, content = 
DownloadSource(params.driver_curl_source))
+    Execute(('cp', '--remove-destination', params.downloaded_custom_connector, 
target),
             #creates=target, TODO: uncomment after ranger_hive_plugin will not 
provide jdbc
             path=["/bin", "/usr/bin/"],
             sudo=True
diff --git 
a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py 
b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
index ed8a72d..dcbb4a4 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
@@ -256,10 +256,14 @@ class TestHiveMetastore(RMFTestCase):
                               create_parents = True,
                               cd_access = 'a',
                               )
-    
+
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
                                           '--remove-destination',
-                                          
'/usr/share/java/mysql-connector-java.jar',
+                                          '/tmp/mysql-connector-java.jar',
                                           
'/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
                               path = ['/bin', '/usr/bin/'],
                               sudo = True,
@@ -382,9 +386,13 @@ class TestHiveMetastore(RMFTestCase):
                               create_parents = True,
                               cd_access = 'a',
                               )
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
                                           '--remove-destination',
-                                          
'/usr/share/java/mysql-connector-java.jar',
+                                          '/tmp/mysql-connector-java.jar',
                                           
'/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
                               path = ['/bin', '/usr/bin/'],
                               sudo = True,
@@ -522,10 +530,14 @@ class TestHiveMetastore(RMFTestCase):
                               mode = 0755,
                               create_parents = True,
                               cd_access = 'a')
-    
+
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
                                           '--remove-destination',
-                                          
'/usr/share/java/mysql-connector-java.jar',
+                                          '/tmp/mysql-connector-java.jar',
                                           
'/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
                               path = ['/bin', '/usr/bin/'],
                               sudo = True)
diff --git 
a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py 
b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
index 025fde6..9bf4658 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
@@ -429,9 +429,13 @@ class TestHiveServer(RMFTestCase):
                               create_parents = True,
                               cd_access='a',
     )
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
                                           '--remove-destination',
-                                          
'/usr/share/java/mysql-connector-java.jar',
+                                          '/tmp/mysql-connector-java.jar',
                                           
'/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
                               path=['/bin', '/usr/bin/'],
                               sudo=True,
@@ -643,9 +647,13 @@ class TestHiveServer(RMFTestCase):
                               create_parents = True,
                               cd_access='a',
     )
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
                                           '--remove-destination',
-                                          
'/usr/share/java/mysql-connector-java.jar',
+                                          '/tmp/mysql-connector-java.jar',
                                           
'/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
                               path=['/bin', '/usr/bin/'],
                               sudo=True,
diff --git 
a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py 
b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
index ca86f7e..ee932e5 100644
--- a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
+++ b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
@@ -281,9 +281,13 @@ class TestHiveMetastore(RMFTestCase):
                               create_parents = True,
                               cd_access = 'a',
                               )
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
      '--remove-destination',
-     '/usr/share/java/mysql-connector-java.jar',
+     '/tmp/mysql-connector-java.jar',
      '/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
         path = ['/bin', '/usr/bin/'],
         sudo = True,
@@ -394,9 +398,13 @@ class TestHiveMetastore(RMFTestCase):
                               create_parents = True,
                               cd_access = 'a',
                               )
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
      '--remove-destination',
-     '/usr/share/java/mysql-connector-java.jar',
+     '/tmp/mysql-connector-java.jar',
      '/usr/hdp/current/hive-server2/lib/mysql-connector-java.jar'),
         path = ['/bin', '/usr/bin/'],
         sudo = True,
@@ -685,9 +693,13 @@ class TestHiveMetastore(RMFTestCase):
     self.assertResourceCalledIgnoreEarlier('Directory', '/var/lib/hive', owner 
= 'hive', group = 'hadoop',
       mode = 0755, create_parents = True, cd_access = 'a')
 
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
      '--remove-destination',
-     '/usr/share/java/mysql-connector-java.jar',
+     '/tmp/mysql-connector-java.jar',
      '/usr/hdp/2.3.2.0-2950/hive/lib/mysql-connector-java.jar'),
         path = ['/bin', '/usr/bin/'],
         sudo = True,
@@ -712,9 +724,13 @@ class TestHiveMetastore(RMFTestCase):
                               mode=0777
                               )
 
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+                              )
     self.assertResourceCalled('Execute', ('cp',
      '--remove-destination',
-     '/usr/share/java/mysql-connector-java.jar',
+     '/tmp/mysql-connector-java.jar',
      u'/usr/hdp/2.3.2.0-2950/hive/lib/mysql-connector-java.jar'),
         path = ['/bin', '/usr/bin/'],
         sudo = True,
diff --git 
a/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py 
b/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py
index 77ec85e..4eef7cf 100644
--- a/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py
+++ b/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py
@@ -714,9 +714,13 @@ class TestHiveServerInteractive(RMFTestCase):
                               group='root',
                               mode=0644,
     )
+    self.assertResourceCalled('File',
+                              '/tmp/mysql-connector-java.jar',
+                              
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources/mysql-connector-java.jar'),
+    )
     self.assertResourceCalled('Execute', ('cp',
                                           '--remove-destination',
-                                          
'/usr/share/java/mysql-connector-java.jar',
+                                          '/tmp/mysql-connector-java.jar',
                                           
'/usr/hdp/current/hive-server2-hive2/lib/mysql-connector-java.jar'),
                               path=['/bin', '/usr/bin/'],
                               sudo=True,

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to