Repository: ambari Updated Branches: refs/heads/trunk c903e0f70 -> 92b75ea44
AMBARI-9756 - Oozie Service Check Fails During Upgrade Due To Incorrect Example Directory (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/92b75ea4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/92b75ea4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/92b75ea4 Branch: refs/heads/trunk Commit: 92b75ea44e811db7a807e30d97b185178ebacc8c Parents: c903e0f Author: Jonathan Hurley <jhur...@hortonworks.com> Authored: Mon Feb 23 16:16:28 2015 -0500 Committer: Jonathan Hurley <jhur...@hortonworks.com> Committed: Mon Feb 23 21:38:21 2015 -0500 ---------------------------------------------------------------------- .../4.0.0.2.0/package/files/oozieSmoke2.sh | 35 +++++++++----------- .../OOZIE/4.0.0.2.0/package/scripts/oozie.py | 22 ++++++++---- .../OOZIE/4.0.0.2.0/package/scripts/params.py | 4 +-- .../4.0.0.2.0/package/scripts/service_check.py | 21 ++++++------ .../stacks/2.0.6/OOZIE/test_oozie_server.py | 4 +-- .../stacks/2.0.6/OOZIE/test_service_check.py | 2 +- 6 files changed, 47 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/92b75ea4/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/files/oozieSmoke2.sh ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/files/oozieSmoke2.sh b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/files/oozieSmoke2.sh index bdd4e26..0695701 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/files/oozieSmoke2.sh +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/files/oozieSmoke2.sh @@ -20,8 +20,16 @@ # # -os_family=$1 -shift +export oozie_lib_dir=$1 +export oozie_conf_dir=$2 +export oozie_bin_dir=$3 +export hadoop_conf_dir=$4 +export hadoop_bin_dir=$5 +export smoke_test_user=$6 +export security_enabled=$7 +export smoke_user_keytab=$8 +export kinit_path_local=$9 +export smokeuser_principal=$10 function getValueFromField { xmllint $1 | grep "<name>$2</name>" -C 2 | grep '<value>' | cut -d ">" -f2 | cut -d "<" -f1 @@ -57,32 +65,19 @@ function checkOozieJobStatus { return $rc } -export oozie_conf_dir=$1 -export oozie_bin_dir=$2 -export hadoop_conf_dir=$3 -export hadoop_bin_dir=$4 -export smoke_test_user=$5 -export security_enabled=$6 -export smoke_user_keytab=$7 -export kinit_path_local=$8 -export smokeuser_principal=$9 - export OOZIE_EXIT_CODE=0 export JOBTRACKER=`getValueFromField ${hadoop_conf_dir}/yarn-site.xml yarn.resourcemanager.address` export NAMENODE=`getValueFromField ${hadoop_conf_dir}/core-site.xml fs.defaultFS` export OOZIE_SERVER=`getValueFromField ${oozie_conf_dir}/oozie-site.xml oozie.base.url | tr '[:upper:]' '[:lower:]'` -if [ "$os_family" == "ubuntu" ] ; then - LIST_PACKAGE_FILES_CMD='dpkg-query -L' -else - LIST_PACKAGE_FILES_CMD='rpm -ql' -fi - - -export OOZIE_EXAMPLES_DIR=`$LIST_PACKAGE_FILES_CMD oozie-client | grep 'oozie-examples.tar.gz$' | xargs dirname` +# search for the oozie examples JAR and, if found, store the directory name +export OOZIE_EXAMPLES_DIR=`find "${oozie_lib_dir}/" -name "oozie-examples.tar.gz" | xargs dirname` if [[ -z "$OOZIE_EXAMPLES_DIR" ]] ; then export OOZIE_EXAMPLES_DIR='/usr/hdp/current/oozie-client/doc/' +else + echo "Located Oozie examples JAR at $OOZIE_EXAMPLES_DIR" fi + cd $OOZIE_EXAMPLES_DIR sudo tar -zxf oozie-examples.tar.gz http://git-wip-us.apache.org/repos/asf/ambari/blob/92b75ea4/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py index 7d8322c..2065f4a 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py @@ -19,10 +19,20 @@ limitations under the License. """ import os -from resource_management import * - -def oozie(is_server=False # TODO: see if see can remove this - ): +from resource_management.core.resources import Directory +from resource_management.core.resources import File +from resource_management.core.resources.system import Execute +from resource_management.core.source import DownloadSource +from resource_management.core.source import InlineTemplate +from resource_management.core.source import Template +from resource_management.libraries.functions import format +from resource_management.libraries.functions import compare_versions +from resource_management.libraries.resources.xml_config import XmlConfig +from resource_management.core.resources.packaging import Package + + +# TODO: see if see can remove this +def oozie(is_server=False): import params if is_server: @@ -121,8 +131,8 @@ def oozie_server_specific(): not_if="ls {pid_file} >/dev/null 2>&1 && !(ps `cat {pid_file}` >/dev/null 2>&1)" ) - oozie_server_directorties = [format("{oozie_home}/{oozie_tmp_dir}"), params.oozie_pid_dir, params.oozie_log_dir, params.oozie_tmp_dir, params.oozie_data_dir, params.oozie_lib_dir, params.oozie_webapps_dir, params.oozie_webapps_conf_dir, params.oozie_server_dir] - Directory( oozie_server_directorties, + oozie_server_directories = [format("{oozie_home}/{oozie_tmp_dir}"), params.oozie_pid_dir, params.oozie_log_dir, params.oozie_tmp_dir, params.oozie_data_dir, params.oozie_lib_dir, params.oozie_webapps_dir, params.oozie_webapps_conf_dir, params.oozie_server_dir] + Directory( oozie_server_directories, owner = params.oozie_user, group = params.user_group, mode = 0755, http://git-wip-us.apache.org/repos/asf/ambari/blob/92b75ea4/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py index 2dc78be..efe11f5 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py @@ -62,7 +62,7 @@ if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0: oozie_root = server_role_dir_mapping[command_role] # using the correct oozie root dir, format the correct location - oozie_lib_dir = format("/usr/hdp/current/{oozie_root}/") + oozie_lib_dir = format("/usr/hdp/current/{oozie_root}") oozie_setup_sh = format("/usr/hdp/current/{oozie_root}/bin/oozie-setup.sh") oozie_webapps_dir = format("/usr/hdp/current/{oozie_root}/oozie-server/webapps") oozie_webapps_conf_dir = format("/usr/hdp/current/{oozie_root}/oozie-server/conf") @@ -76,7 +76,7 @@ if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0: else: hadoop_bin_dir = "/usr/bin" hadoop_lib_home = "/usr/lib/hadoop/lib" - oozie_lib_dir = "/var/lib/oozie/" + oozie_lib_dir = "/var/lib/oozie" oozie_setup_sh = "/usr/lib/oozie/bin/oozie-setup.sh" oozie_webapps_dir = "/var/lib/oozie/oozie-server/webapps/" oozie_webapps_conf_dir = "/var/lib/oozie/oozie-server/conf" http://git-wip-us.apache.org/repos/asf/ambari/blob/92b75ea4/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py index cac6ede..471cd35 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py @@ -17,8 +17,12 @@ See the License for the specific language governing permissions and limitations under the License. """ - -from resource_management import * +from resource_management.core.resources.system import Execute +from resource_management.core.resources import File +from resource_management.core.source import StaticFile +from resource_management.core.system import System +from resource_management.libraries.functions import format +from resource_management.libraries.script import Script class OozieServiceCheck(Script): def service_check(self, env): @@ -29,10 +33,9 @@ class OozieServiceCheck(Script): smoke_test_file_name = 'oozieSmoke2.sh' oozie_smoke_shell_file( smoke_test_file_name) - -def oozie_smoke_shell_file( - file_name -): + + +def oozie_smoke_shell_file(file_name): import params File( format("{tmp_dir}/{file_name}"), @@ -40,12 +43,10 @@ def oozie_smoke_shell_file( mode = 0755 ) - os_family = System.get_instance().os_family - if params.security_enabled: - sh_cmd = format("{tmp_dir}/{file_name} {os_family} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled} {smokeuser_keytab} {kinit_path_local} {smokeuser_principal}") + sh_cmd = format("{tmp_dir}/{file_name} {oozie_lib_dir} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled} {smokeuser_keytab} {kinit_path_local} {smokeuser_principal}") else: - sh_cmd = format("{tmp_dir}/{file_name} {os_family} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled}") + sh_cmd = format("{tmp_dir}/{file_name} {oozie_lib_dir} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled}") Execute( format("{tmp_dir}/{file_name}"), command = sh_cmd, http://git-wip-us.apache.org/repos/asf/ambari/blob/92b75ea4/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 b988e4e..45e9dc4 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 @@ -237,7 +237,7 @@ class TestOozieServer(RMFTestCase): mode = 0755, cd_access='a' ) - self.assertResourceCalled('Directory', '/var/lib/oozie/', + self.assertResourceCalled('Directory', '/var/lib/oozie', owner = 'oozie', group = 'hadoop', recursive = True, @@ -390,7 +390,7 @@ class TestOozieServer(RMFTestCase): mode = 0755, cd_access='a' ) - self.assertResourceCalled('Directory', '/var/lib/oozie/', + self.assertResourceCalled('Directory', '/var/lib/oozie', owner = 'oozie', group = 'hadoop', recursive = True, http://git-wip-us.apache.org/repos/asf/ambari/blob/92b75ea4/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py index 59ab5c6..a478b57 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py @@ -57,7 +57,7 @@ class TestServiceCheck(RMFTestCase): self.assertResourceCalled('Execute', '/tmp/oozieSmoke2.sh', logoutput = True, tries = 3, - command = '/tmp/oozieSmoke2.sh suse /etc/oozie/conf /usr/bin /etc/hadoop/conf /usr/bin ambari-qa False', + command = '/tmp/oozieSmoke2.sh /var/lib/oozie /etc/oozie/conf /usr/bin /etc/hadoop/conf /usr/bin ambari-qa False', path = ['/usr/bin:/usr/bin'], try_sleep = 5, )