ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-22030. OOZIE/OOZIE_SERVER restart failed saying AttributeError: 'NoneType' object has no attribute 'upper' during EU (ncole)
Date Thu, 21 Sep 2017 21:04:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 a04774865 -> fb9ef3c39


AMBARI-22030. OOZIE/OOZIE_SERVER restart failed saying AttributeError: 'NoneType' object has
no attribute 'upper' during EU (ncole)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fb9ef3c3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fb9ef3c3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fb9ef3c3

Branch: refs/heads/branch-2.6
Commit: fb9ef3c39f0db8a32688c669f95a6b5329b5e844
Parents: a047748
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Sep 21 11:47:10 2017 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Thu Sep 21 17:02:29 2017 -0400

----------------------------------------------------------------------
 .../libraries/functions/upgrade_summary.py      | 16 +++++
 .../4.0.0.2.0/package/scripts/params_linux.py   |  5 ++
 .../stacks/2.0.6/OOZIE/test_oozie_server.py     | 66 ++++++++++++++++++++
 3 files changed, 87 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fb9ef3c3/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
b/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
index 507bc42..c5494f8 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/upgrade_summary.py
@@ -25,6 +25,22 @@ from resource_management.libraries.functions.constants import Direction
 UpgradeSummary = namedtuple("UpgradeSummary", "type direction orchestration is_revert services")
 UpgradeServiceSummary = namedtuple("UpgradeServiceSummary", "service_name source_stack source_version
target_stack target_version")
 
+
+def get_source_stack(service_name):
+  """
+  Gets the source stack (from) version of a service participating in an upgrade. If there
is no
+  upgrade or the specific service is not participating, this will return None.
+  :param service_name:  the service name to check for, or None to extract it from the command
+  :return:  the stack that the service is upgrading from or None if there is no upgrade or
+  the service is not included in the upgrade.
+  """
+  service_summary = _get_service_summary(service_name)
+  if service_summary is None:
+    return None
+
+  return service_summary.source_stack
+
+
 def get_source_version(service_name = None, default_version=None):
   """
   Gets the source (from) version of a service participating in an upgrade. If there is no

http://git-wip-us.apache.org/repos/asf/ambari/blob/fb9ef3c3/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
index 2f474a1..4326527 100644
--- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
+++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py
@@ -23,6 +23,7 @@ from resource_management.libraries.functions import format
 from resource_management.libraries.functions import conf_select
 from resource_management.libraries.functions import stack_select
 from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions import upgrade_summary
 from resource_management.libraries.functions.stack_features import check_stack_feature
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.functions import get_kinit_path
@@ -37,6 +38,7 @@ from resource_management.libraries.functions.stack_features import get_stack_fea
 from resource_management.libraries.functions.stack_tools import get_stack_name
 from resource_management.libraries.functions.version import get_major_version
 
+
 from resource_management.core.utils import PasswordString
 from ambari_commons.credential_store_helper import get_password_from_credential_store
 from urlparse import urlparse
@@ -70,6 +72,9 @@ stack_root = status_params.stack_root
 # The source stack will be present during a cross-stack upgrade.
 # E.g., BigInsights-4.2.5 or HDP-2.6
 source_stack = default("/commandParams/source_stack", None)
+if source_stack is None:
+  source_stack = upgrade_summary.get_source_stack("OOZIE")
+
 # This variable name is important, do not change
 source_stack_name = get_stack_name(source_stack)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fb9ef3c3/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
index dfa22fd..a5dac6c 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py
@@ -1280,6 +1280,72 @@ class TestOozieServer(RMFTestCase):
     self.assertResourceCalled('File', '/usr/hdp/current/oozie-server/libext/ext-2.2.zip',
mode = 0644)
     self.assertNoMoreResources()
 
+  @patch("os.path.isdir")
+  @patch("os.path.exists")
+  @patch("os.path.isfile")
+  @patch("os.remove")
+  @patch("shutil.rmtree", new = MagicMock())
+  @patch("glob.iglob")
+  @patch("shutil.copy2", new = MagicMock())
+  def test_upgrade_23_with_type(self, glob_mock, remove_mock,
+      isfile_mock, exists_mock, isdir_mock):
+
+    def exists_mock_side_effect(path):
+      if path == '/tmp/oozie-upgrade-backup/oozie-conf-backup.tar':
+        return True
+
+      return False
+
+    isdir_mock.return_value = True
+    exists_mock.side_effect = exists_mock_side_effect
+    isfile_mock.return_value = True
+    glob_mock.return_value = ["/usr/hdp/2.2.1.0-2187/hadoop/lib/hadoop-lzo-0.6.0.2.2.1.0-2187.jar"]
+
+    prepare_war_stdout = """INFO: Adding extension: libext/mysql-connector-java.jar
+    New Oozie WAR file with added 'JARs' at /var/lib/oozie/oozie-server/webapps/oozie.war"""
+
+    config_file = self.get_src_folder()+"/test/python/stacks/2.2/configs/oozie-upgrade.json"
+
+    with open(config_file, "r") as f:
+      json_content = json.load(f)
+
+    version = '2.3.0.0-1234'
+    json_content['commandParams']['version'] = version
+    json_content['upgradeSummary'] = {
+      'services': { 'OOZIE': { 'sourceStackId': 'HDP-2.3' }},
+      'direction': 'UPGRADE',
+      'type': 'rolling_upgrade',
+      'orchestration': 'STANDARD'
+    }
+
+    mocks_dict = {}
+    self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/oozie_server.py",
+     classname = "OozieServer", command = "pre_upgrade_restart", config_dict = json_content,
+     command_args = ["rolling"],
+     config_overrides = self.CONFIG_OVERRIDES,
+     stack_version = self.UPGRADE_STACK_VERSION,
+     target = RMFTestCase.TARGET_COMMON_SERVICES,
+     call_mocks = [(0, prepare_war_stdout)],
+     mocks_dict = mocks_dict)
+
+    self.assertTrue(isfile_mock.called)
+    self.assertEqual(isfile_mock.call_count,2)
+    isfile_mock.assert_called_with('/usr/share/HDP-oozie/ext-2.2.zip')
+
+    self.assertTrue(glob_mock.called)
+    self.assertEqual(glob_mock.call_count,1)
+    glob_mock.assert_called_with('/usr/hdp/2.3.0.0-1234/hadoop/lib/hadoop-lzo*.jar')
+
+    self.assertResourceCalled('Execute', ('ambari-python-wrap', '/usr/bin/hdp-select', 'set',
'oozie-client', '2.3.0.0-1234'), sudo = True)
+    self.assertResourceCalled('Execute', ('ambari-python-wrap', '/usr/bin/hdp-select', 'set',
'oozie-server', '2.3.0.0-1234'), sudo = True)
+
+    self.assertResourceCalled('Directory', '/usr/hdp/current/oozie-server/libext', mode =
0777)
+
+    self.assertResourceCalled('Execute', ('cp', '/usr/share/HDP-oozie/ext-2.2.zip', '/usr/hdp/current/oozie-server/libext'),
sudo=True)
+    self.assertResourceCalled('Execute', ('chown', 'oozie:hadoop', '/usr/hdp/current/oozie-server/libext/ext-2.2.zip'),
sudo=True)
+    self.assertResourceCalled('File', '/usr/hdp/current/oozie-server/libext/ext-2.2.zip',
mode = 0644)
+    self.assertNoMoreResources()
+
 
   @patch("os.path.isdir")
   @patch("os.path.exists")


Mime
View raw message