Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 062a58a4c -> 91d480eb6


AMBARI-18770. Service check and Ambari Alerting for RM fails against Yarn with 
HA and SPNEGO. (Attila Magyar via stoader)


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

Branch: refs/heads/branch-2.5
Commit: 91d480eb62cc5aeb8d34c863d1443345cf0567a5
Parents: 062a58a
Author: Attila Magyar <amag...@hortonworks.com>
Authored: Mon Nov 7 16:54:48 2016 +0100
Committer: Toader, Sebastian <stoa...@hortonworks.com>
Committed: Wed Nov 9 12:57:25 2016 +0100

----------------------------------------------------------------------
 .../libraries/functions/curl_krb_request.py                 | 4 ++--
 .../YARN/2.1.0.2.0/package/scripts/service_check.py         | 4 ++--
 .../services/WEBHCAT/package/files/alert_webhcat_server.py  | 4 ++--
 .../python/stacks/2.0.6/YARN/test_yarn_service_check.py     | 9 ++++++++-
 4 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/91d480eb/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
----------------------------------------------------------------------
diff --git 
a/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
 
b/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
index 2acf871..557db58 100644
--- 
a/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
+++ 
b/ambari-common/src/main/python/resource_management/libraries/functions/curl_krb_request.py
@@ -176,11 +176,11 @@ def curl_krb_request(tmp_dir, keytab, principal, url, 
cache_file_prefix,
 
   try:
     if return_only_http_code:
-      _, curl_stdout, curl_stderr = get_user_call_output(['curl', '-L', '-k', 
'--negotiate', '-u', ':', '-b', cookie_file, '-c', cookie_file, '-w',
+      _, curl_stdout, curl_stderr = get_user_call_output(['curl', 
'--location-trusted', '-k', '--negotiate', '-u', ':', '-b', cookie_file, '-c', 
cookie_file, '-w',
                              '%{http_code}', url, '--connect-timeout', 
str(connection_timeout), '--max-time', str(maximum_timeout), '-o', '/dev/null'],
                              user=user, env=kerberos_env)
     else:
-      curl_command = ['curl', '-L', '-k', '--negotiate', '-u', ':', '-b', 
cookie_file, '-c', cookie_file,
+      curl_command = ['curl', '--location-trusted', '-k', '--negotiate', '-u', 
':', '-b', cookie_file, '-c', cookie_file,
                       url, '--connect-timeout', str(connection_timeout), 
'--max-time', str(maximum_timeout)]
       # returns response body
       if len(method) > 0 and len(body) == 0 and len(header) == 0:

http://git-wip-us.apache.org/repos/asf/ambari/blob/91d480eb/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
 
b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
index daa8e7e..1d8963d 100644
--- 
a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
+++ 
b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service_check.py
@@ -129,13 +129,13 @@ class ServiceCheckDefault(ServiceCheck):
     for rm_webapp_address in params.rm_webapp_addresses_list:
       info_app_url = params.scheme + "://" + rm_webapp_address + 
"/ws/v1/cluster/apps/" + application_name
 
-      get_app_info_cmd = "curl --negotiate -u : -ksL --connect-timeout " + 
CURL_CONNECTION_TIMEOUT + " " + info_app_url
+      get_app_info_cmd = "curl --negotiate -u : -ks --location-trusted 
--connect-timeout " + CURL_CONNECTION_TIMEOUT + " " + info_app_url
 
       return_code, stdout, _ = get_user_call_output(get_app_info_cmd,
                                             user=params.smokeuser,
                                             
path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
                                             )
-      
+
       # Handle HDP<2.2.8.1 where RM doesn't do automatic redirection from 
standby to active
       if stdout.startswith("This is standby RM. Redirecting to the current 
active RM:"):
         Logger.info(format("Skipped checking of {rm_webapp_address} since 
returned '{stdout}'"))

http://git-wip-us.apache.org/repos/asf/ambari/blob/91d480eb/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/WEBHCAT/package/files/alert_webhcat_server.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/WEBHCAT/package/files/alert_webhcat_server.py
 
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/WEBHCAT/package/files/alert_webhcat_server.py
index 7ee375e..a8d4dfe 100644
--- 
a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/WEBHCAT/package/files/alert_webhcat_server.py
+++ 
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/WEBHCAT/package/files/alert_webhcat_server.py
@@ -146,7 +146,7 @@ def execute(configurations={}, parameters={}, 
host_name=None):
         Execute(kinit_command)
 
       # make a single curl call to get just the http code
-      curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-sL', '-w',
+      curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-s', '-w', 
'--location-trusted',
         '%{http_code}', '--connect-timeout', curl_connection_timeout,
         '-o', '/dev/null', query_url], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, env=kerberos_env)
 
@@ -170,7 +170,7 @@ def execute(configurations={}, parameters={}, 
host_name=None):
 
       # now that we have the http status and it was 200, get the content
       start_time = time.time()
-      curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-sL',
+      curl = subprocess.Popen(['curl', '--negotiate', '-u', ':', '-s', 
'--location-trusted',
         '--connect-timeout', curl_connection_timeout, query_url, ],
         stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=kerberos_env)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/91d480eb/ambari-server/src/test/python/stacks/2.0.6/YARN/test_yarn_service_check.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_yarn_service_check.py 
b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_yarn_service_check.py
index ccd472c..bb671aa 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_yarn_service_check.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_yarn_service_check.py
@@ -22,9 +22,11 @@ import re
 from mock.mock import MagicMock, call, patch
 from stacks.utils.RMFTestCase import *
 
+curl_call = MagicMock(return_value=(0, "{ \"app\": {\"state\": 
\"FINISHED\",\"finalStatus\": \"SUCCEEDED\"}}",''))
+
 @patch("platform.linux_distribution", new = MagicMock(return_value="Linux"))
 @patch("sys.executable", new = '/usr/bin/python2.6')
-@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
 new = MagicMock(return_value=(0, "{ \"app\": {\"state\": 
\"FINISHED\",\"finalStatus\": \"SUCCEEDED\"}}",'')))
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
 new = curl_call)
 class TestServiceCheck(RMFTestCase):
   COMMON_SERVICES_PACKAGE_DIR = "YARN/2.1.0.2.0/package"
   STACK_VERSION = "2.0.6"
@@ -59,6 +61,7 @@ class TestServiceCheck(RMFTestCase):
                               hadoop_conf_dir = '/etc/hadoop/conf',
                               type = 'directory',
                               )
+    self.assertCurlCallForwardsCredentialsOnRedirect()
     self.assertNoMoreResources()
 
 
@@ -91,4 +94,8 @@ class TestServiceCheck(RMFTestCase):
                               hadoop_conf_dir = '/etc/hadoop/conf',
                               type = 'directory',
                               )
+    self.assertCurlCallForwardsCredentialsOnRedirect()
     self.assertNoMoreResources()
+
+  def assertCurlCallForwardsCredentialsOnRedirect(self):
+    self.assertIn('--location-trusted', curl_call.call_args[0][0])
\ No newline at end of file

Reply via email to