Kaynağa Gözat

AMBARI-6636. Error on YARN Service Check after RM HA enabling.(vbrodetskyi)

Vitaly Brodetskyi 11 yıl önce
ebeveyn
işleme
73be90ac0a

+ 32 - 27
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/files/validateYarnComponentStatus.py

@@ -42,28 +42,29 @@ def getResponse(path, address, ssl_enabled):
     url = 'http://' + address + path
       
   command_with_flags = [command,httpGssnegotiate,userpswd,insecure,url]
-  try:
-    proc = subprocess.Popen(command_with_flags, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    (stdout, stderr) = proc.communicate()
-    response = json.loads(stdout)
-    if response == None:
-      print 'There is no response for url: ' + str(url)
-      exit(1)
-    return response
-  except Exception as e:
-    print 'Error getting response for url:' + str(url), e
-    exit(1)
+
+  proc = subprocess.Popen(command_with_flags, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  (stdout, stderr) = proc.communicate()
+  response = json.loads(stdout)
+  if response == None:
+    print 'There is no response for url: ' + str(url)
+    raise Exception('There is no response for url: ' + str(url))
+  return response
 
 #Verify that REST api is available for given component
-def validateAvailability(component, path, address, ssl_enabled):
+def validateAvailability(component, path, addresses, ssl_enabled):
+  responses = {}
+  for address in addresses.split(','):
+    try:
+      responses[address] = getResponse(path, address, ssl_enabled)
+    except Exception as e:
+      print 'Error checking availability status of component.', e
+
+  if not responses:
+    exit(1)
 
-  try:
-    response = getResponse(path, address, ssl_enabled)
-    is_valid = validateAvailabilityResponse(component, response)
-    if not is_valid:
-      exit(1)
-  except Exception as e:
-    print 'Error checking availability status of component', e
+  is_valid = validateAvailabilityResponse(component, responses.values()[0])
+  if not is_valid:
     exit(1)
 
 #Validate component-specific response
@@ -96,15 +97,19 @@ def validateAvailabilityResponse(component, response):
     return False
 
 #Verify that component has required resources to work
-def validateAbility(component, path, address, ssl_enabled):
+def validateAbility(component, path, addresses, ssl_enabled):
+  responses = {}
+  for address in addresses.split(','):
+    try:
+      responses[address] = getResponse(path, address, ssl_enabled)
+    except Exception as e:
+      print 'Error checking ability of component.', e
+
+  if not responses:
+    exit(1)
 
-  try:
-    response = getResponse(path, address, ssl_enabled)
-    is_valid = validateAbilityResponse(component, response)
-    if not is_valid:
-      exit(1)
-  except Exception as e:
-    print 'Error checking ability of component', e
+  is_valid = validateAbilityResponse(component, responses.values()[0])
+  if not is_valid:
     exit(1)
 
 #Validate component-specific response that it has required resources to work

+ 10 - 3
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/params.py

@@ -38,7 +38,8 @@ security_enabled = ( not is_empty(_authentication) and _authentication == 'kerbe
 smoke_user_keytab = config['configurations']['hadoop-env']['smokeuser_keytab']
 yarn_executor_container_group = config['configurations']['yarn-site']['yarn.nodemanager.linux-container-executor.group']
 kinit_path_local = functions.get_kinit_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
-rm_host = config['clusterHostInfo']['rm_host'][0]
+rm_hosts = config['clusterHostInfo']['rm_host']
+rm_host = rm_hosts[0]
 rm_port = config['configurations']['yarn-site']['yarn.resourcemanager.webapp.address'].split(':')[-1]
 rm_https_port = "8090"
 # TODO UPGRADE default, update site during upgrade
@@ -61,8 +62,14 @@ mapred_log_dir_prefix = config['configurations']['mapred-env']['mapred_log_dir_p
 mapred_env_sh_template = config['configurations']['mapred-env']['content']
 yarn_env_sh_template = config['configurations']['yarn-env']['content']
 
-rm_webui_address = format("{rm_host}:{rm_port}")
-rm_webui_https_address = format("{rm_host}:{rm_https_port}")
+if len(rm_hosts) > 1:
+  additional_rm_host = rm_hosts[1]
+  rm_webui_address = format("{rm_host}:{rm_port},{additional_rm_host}:{rm_port}")
+  rm_webui_https_address = format("{rm_host}:{rm_https_port},{additional_rm_host}:{rm_https_port}")
+else:
+  rm_webui_address = format("{rm_host}:{rm_port}")
+  rm_webui_https_address = format("{rm_host}:{rm_https_port}")
+
 nm_webui_address = config['configurations']['yarn-site']['yarn.nodemanager.webapp.address']
 hs_webui_address = config['configurations']['mapred-site']['mapreduce.jobhistory.webapp.address']
 

+ 34 - 29
ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/YARN/package/files/validateYarnComponentStatus.py

@@ -40,30 +40,31 @@ def getResponse(path, address, ssl_enabled):
     url = 'https://' + address + path
   else:
     url = 'http://' + address + path
-      
+
   command_with_flags = [command,httpGssnegotiate,userpswd,insecure,url]
-  try:
-    proc = subprocess.Popen(command_with_flags, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    (stdout, stderr) = proc.communicate()
-    response = json.loads(stdout)
-    if response == None:
-      print 'There is no response for url: ' + str(url)
-      exit(1)
-    return response
-  except Exception as e:
-    print 'Error getting response for url:' + str(url), e
-    exit(1)
+
+  proc = subprocess.Popen(command_with_flags, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  (stdout, stderr) = proc.communicate()
+  response = json.loads(stdout)
+  if response == None:
+    print 'There is no response for url: ' + str(url)
+    raise Exception('There is no response for url: ' + str(url))
+  return response
 
 #Verify that REST api is available for given component
-def validateAvailability(component, path, address, ssl_enabled):
+def validateAvailability(component, path, addresses, ssl_enabled):
+  responses = {}
+  for address in addresses.split(','):
+    try:
+      responses[address] = getResponse(path, address, ssl_enabled)
+    except Exception as e:
+      print 'Error checking availability status of component.', e
+
+  if not responses:
+    exit(1)
 
-  try:
-    response = getResponse(path, address, ssl_enabled)
-    is_valid = validateAvailabilityResponse(component, response)
-    if not is_valid:
-      exit(1)
-  except Exception as e:
-    print 'Error checking availability status of component', e
+  is_valid = validateAvailabilityResponse(component, responses.values()[0])
+  if not is_valid:
     exit(1)
 
 #Validate component-specific response
@@ -96,15 +97,19 @@ def validateAvailabilityResponse(component, response):
     return False
 
 #Verify that component has required resources to work
-def validateAbility(component, path, address, ssl_enabled):
+def validateAbility(component, path, addresses, ssl_enabled):
+  responses = {}
+  for address in addresses.split(','):
+    try:
+      responses[address] = getResponse(path, address, ssl_enabled)
+    except Exception as e:
+      print 'Error checking ability of component.', e
+
+  if not responses:
+    exit(1)
 
-  try:
-    response = getResponse(path, address, ssl_enabled)
-    is_valid = validateAbilityResponse(component, response)
-    if not is_valid:
-      exit(1)
-  except Exception as e:
-    print 'Error checking ability of component', e
+  is_valid = validateAbilityResponse(component, responses.values()[0])
+  if not is_valid:
     exit(1)
 
 #Validate component-specific response that it has required resources to work
@@ -143,7 +148,7 @@ def main():
   (options, args) = parser.parse_args()
 
   component = args[0]
-  
+
   address = options.address
   ssl_enabled = (options.ssl_enabled) in 'true'
   if component == RESOURCEMANAGER:

+ 10 - 3
ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/YARN/package/scripts/params.py

@@ -38,7 +38,8 @@ security_enabled = ( not is_empty(_authentication) and _authentication == 'kerbe
 smoke_user_keytab = config['configurations']['global']['smokeuser_keytab']
 yarn_executor_container_group = config['configurations']['yarn-site']['yarn.nodemanager.linux-container-executor.group']
 kinit_path_local = functions.get_kinit_path([default("kinit_path_local",None), "/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
-rm_host = config['clusterHostInfo']['rm_host'][0]
+rm_hosts = config['clusterHostInfo']['rm_host']
+rm_host = rm_hosts[0]
 rm_port = config['configurations']['yarn-site']['yarn.resourcemanager.webapp.address'].split(':')[-1]
 rm_https_port = "8090"
 rm_nodes_exclude_path = config['configurations']['yarn-site']['yarn.resourcemanager.nodes.exclude-path']
@@ -57,8 +58,14 @@ yarn_pid_dir_prefix = status_params.yarn_pid_dir_prefix
 mapred_pid_dir_prefix = status_params.mapred_pid_dir_prefix
 mapred_log_dir_prefix = config['configurations']['global']['mapred_log_dir_prefix']
 
-rm_webui_address = format("{rm_host}:{rm_port}")
-rm_webui_https_address = format("{rm_host}:{rm_https_port}")
+if len(rm_hosts) > 1:
+  additional_rm_host = rm_hosts[1]
+  rm_webui_address = format("{rm_host}:{rm_port},{additional_rm_host}:{rm_port}")
+  rm_webui_https_address = format("{rm_host}:{rm_https_port},{additional_rm_host}:{rm_https_port}")
+else:
+  rm_webui_address = format("{rm_host}:{rm_port}")
+  rm_webui_https_address = format("{rm_host}:{rm_https_port}")
+
 nm_webui_address = config['configurations']['yarn-site']['yarn.nodemanager.webapp.address']
 hs_webui_address = config['configurations']['mapred-site']['mapreduce.jobhistory.webapp.address']