Переглянути джерело

AMBARI-2589. Oozie smoke test failing with custom principal names. (swagle)

Siddharth Wagle 12 роки тому
батько
коміт
c77a03cdb6

+ 4 - 4
ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke.sh

@@ -59,8 +59,8 @@ export smoke_test_user=$3
 export security_enabled=$4
 export security_enabled=$4
 export smoke_user_keytab=$5
 export smoke_user_keytab=$5
 export realm=$6
 export realm=$6
-export JTHOST=$7
-export NNHOST=$8
+export JTPRINC=$7
+export NNPRINC=$8
 export kinit_path_local=$9
 export kinit_path_local=$9
 
 
 export OOZIE_EXIT_CODE=0
 export OOZIE_EXIT_CODE=0
@@ -79,8 +79,8 @@ sed -i "s|oozie.wf.application.path=hdfs://localhost:9000|oozie.wf.application.p
 
 
 if [[ $security_enabled == "true" ]]; then
 if [[ $security_enabled == "true" ]]; then
   kinitcmd="${kinit_path_local} -kt ${smoke_user_keytab} ${smoke_test_user}; "
   kinitcmd="${kinit_path_local} -kt ${smoke_user_keytab} ${smoke_test_user}; "
-  echo "dfs.namenode.kerberos.principal=nn/`echo ${NNHOST} | tr '[:upper:]' '[:lower:]'`@${realm}" >> examples/apps/map-reduce/job.properties
-  echo "mapreduce.jobtracker.kerberos.principal=jt/`echo ${JTHOST} | tr '[:upper:]' '[:lower:]'`@${realm}" >> examples/apps/map-reduce/job.properties
+  echo "dfs.namenode.kerberos.principal=${NNPRINC}" >> examples/apps/map-reduce/job.properties
+  echo "mapreduce.jobtracker.kerberos.principal=${JTPRINC}" >> examples/apps/map-reduce/job.properties
 else 
 else 
   kinitcmd=""
   kinitcmd=""
 fi
 fi

+ 3 - 3
ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/oozie/service_check.pp

@@ -36,8 +36,6 @@ define hdp-oozie::smoke_shell_file()
   $conf_dir = $hdp::params::oozie_conf_dir
   $conf_dir = $hdp::params::oozie_conf_dir
   $hadoopconf_dir = $hdp::params::hadoop_conf_dir 
   $hadoopconf_dir = $hdp::params::hadoop_conf_dir 
   $security_enabled=$hdp::params::security_enabled
   $security_enabled=$hdp::params::security_enabled
-  $jt_host=$hdp::params::jtnode_host
-  $nn_host=$hdp::params::namenode_host
   if ($security_enabled == true) {
   if ($security_enabled == true) {
     $security = "true"
     $security = "true"
   } else {
   } else {
@@ -46,6 +44,8 @@ define hdp-oozie::smoke_shell_file()
   $smoke_user_keytab = $hdp::params::smokeuser_keytab
   $smoke_user_keytab = $hdp::params::smokeuser_keytab
   $realm=$hdp::params::kerberos_domain
   $realm=$hdp::params::kerberos_domain
   $kinit_path = $hdp::params::kinit_path_local
   $kinit_path = $hdp::params::kinit_path_local
+  $nn_principal = $hdp::params::nn_principal
+  $jt_principal = $hdp::params::jt_principal
 
 
   file { '/tmp/oozieSmoke.sh':
   file { '/tmp/oozieSmoke.sh':
     ensure => present,
     ensure => present,
@@ -54,7 +54,7 @@ define hdp-oozie::smoke_shell_file()
   }
   }
 
 
   exec { '/tmp/oozieSmoke.sh':
   exec { '/tmp/oozieSmoke.sh':
-    command   => "sh /tmp/oozieSmoke.sh ${conf_dir} ${hadoopconf_dir} ${smoke_test_user} ${security} ${smoke_user_keytab} ${realm} $jt_host $nn_host $kinit_path",
+    command   => "sh /tmp/oozieSmoke.sh ${conf_dir} ${hadoopconf_dir} ${smoke_test_user} ${security} ${smoke_user_keytab} ${realm} $jt_principal $nn_principal $kinit_path",
     tries     => 3,
     tries     => 3,
     try_sleep => 5,
     try_sleep => 5,
     require   => File['/tmp/oozieSmoke.sh'],
     require   => File['/tmp/oozieSmoke.sh'],

+ 48 - 0
ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_to_lowercase.rb

@@ -0,0 +1,48 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+module Puppet::Parser::Functions
+  newfunction(:hdp_to_lowercase, :type => :rvalue, :doc => <<-EOS
+Converts the case of a string or all strings in an array to lower case.
+    EOS
+  ) do |arguments|
+
+    raise(Puppet::ParseError, "downcase(): Wrong number of arguments " +
+      "given (#{arguments.size} for 1)") if arguments.size < 1
+
+    value = arguments[0]
+    klass = value.class
+
+    unless [Array, String].include?(klass)
+      raise(Puppet::ParseError, 'downcase(): Requires either ' +
+        'array or string to work with')
+    end
+
+    if value.is_a?(Array)
+      # Numbers in Puppet are often string-encoded which is troublesome ...
+      result = value.collect { |i| i.is_a?(String) ? i.downcase : i }
+    else
+      result = value.downcase
+    end
+
+    return result
+  end
+end

+ 14 - 1
ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp

@@ -44,7 +44,7 @@ class hdp::params()
   $cluster_client_state = hdp_default("cluster_client_state","installed_and_configured")
   $cluster_client_state = hdp_default("cluster_client_state","installed_and_configured")
 
 
   ## Hostname defaults
   ## Hostname defaults
-  $hostname = hdp_default("myhostname", $::fqdn)
+  $hostname = hdp_to_lowercase(hdp_default("myhostname", $::fqdn))
   $public_hostname = hdp_default("public_hostname")
   $public_hostname = hdp_default("public_hostname")
 
 
   ##### for secure install
   ##### for secure install
@@ -65,6 +65,19 @@ class hdp::params()
   $jtnode_host = hdp_default("jtnode_host")
   $jtnode_host = hdp_default("jtnode_host")
   $slave_hosts = hdp_default("slave_hosts")
   $slave_hosts = hdp_default("slave_hosts")
 
 
+  $nn_principal_str = hdp_default("hdfs-site/dfs.namenode.kerberos.principal", "nn/_HOST@EXAMPLE.COM")
+  if ("_HOST" in $nn_principal_str) {
+    $nn_principal = regsubst($nn_principal_str, "_HOST", hdp_to_lowercase($namenode_host[0]))
+  } else {
+    $nn_principal = $nn_principal_str
+  }
+  $jt_principal_str = hdp_default("mapred-site/mapreduce.jobtracker.kerberos.principal", "jt/_HOST@EXAMPLE.COM")
+  if ("_HOST" in $jt_principal_str) {
+    $jt_principal = regsubst($jt_principal_str, "_HOST", hdp_to_lowercase($jtnode_host[0]))
+  } else {
+    $jt_principal = $jt_principal_str
+  }
+
   $rm_host = hdp_default("rm_host")
   $rm_host = hdp_default("rm_host")
   $nm_hosts = hdp_default("nm_hosts")
   $nm_hosts = hdp_default("nm_hosts")
   $hs_host = hdp_default("hs_host")
   $hs_host = hdp_default("hs_host")