You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2017/09/26 05:20:11 UTC
[20/50] [abbrv] ambari git commit: AMBARI-22030. OOZIE/OOZIE_SERVER
restart failed saying AttributeError: 'NoneType' object has no attribute
'upper' during EU (ncole)
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/f9c0c909
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f9c0c909
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f9c0c909
Branch: refs/heads/branch-feature-AMBARI-14714
Commit: f9c0c909be405ecfe3607ad4e07d3aa6eb6cf3df
Parents: f095b95
Author: Nate Cole <nc...@hortonworks.com>
Authored: Thu Sep 21 17:13:12 2017 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Thu Sep 21 17:13:27 2017 -0400
----------------------------------------------------------------------
.../libraries/functions/upgrade_summary.py | 16 +++++
.../4.0.0.2.0/package/scripts/params_linux.py | 18 +++++-
.../stacks/2.0.6/OOZIE/test_oozie_server.py | 66 ++++++++++++++++++++
3 files changed, 98 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f9c0c909/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 849ac8a..f8a46c0 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/f9c0c909/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 44c88b7..e856c01 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
@@ -19,8 +19,10 @@ limitations under the License.
"""
from ambari_commons.constants import AMBARI_SUDO_BINARY
from resource_management.libraries.functions import format
-from resource_management.libraries.functions import conf_select, stack_select
-from resource_management.libraries.functions.constants import StackFeature
+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
@@ -33,8 +35,10 @@ from resource_management.libraries.functions.expect import expect
from resource_management.libraries.resources.hdfs_resource import HdfsResource
from resource_management.libraries.functions.get_architecture import get_architecture
from resource_management.libraries.functions.stack_features import get_stack_feature_version
+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
@@ -65,6 +69,16 @@ agent_stack_retry_on_unavailability = config['hostLevelParams']['agent_stack_ret
agent_stack_retry_count = expect("/hostLevelParams/agent_stack_retry_count", int)
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)
+
stack_version_unformatted = status_params.stack_version_unformatted
stack_version_formatted = status_params.stack_version_formatted
major_stack_version = get_major_version(stack_version_formatted)
http://git-wip-us.apache.org/repos/asf/ambari/blob/f9c0c909/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")