Merge "Fix closing HTTP session in Ambari plugin" into stable/icehouse
This commit is contained in:
commit
1625465493
|
@ -260,10 +260,11 @@ class AmbariPlugin(p.ProvisioningPluginBase):
|
|||
cluster, self._map_to_user_inputs(
|
||||
cluster.hadoop_version, cluster.cluster_configs))
|
||||
|
||||
client.start_services(cluster.name, cluster_spec,
|
||||
self.cluster_ambari_mapping[cluster.name])
|
||||
|
||||
client.cleanup(self.cluster_ambari_mapping[cluster.name])
|
||||
try:
|
||||
client.start_services(cluster.name, cluster_spec,
|
||||
self.cluster_ambari_mapping[cluster.name])
|
||||
finally:
|
||||
client.cleanup(self.cluster_ambari_mapping[cluster.name])
|
||||
|
||||
def get_title(self):
|
||||
return 'Hortonworks Data Platform'
|
||||
|
|
|
@ -21,6 +21,7 @@ import pkg_resources as pkg
|
|||
import requests
|
||||
|
||||
from sahara import context
|
||||
from sahara import exceptions as exc
|
||||
from sahara.plugins.general import exceptions as ex
|
||||
from sahara.plugins.hdp import clusterspec as cs
|
||||
from sahara.plugins.hdp import configprovider as cfgprov
|
||||
|
@ -562,7 +563,10 @@ class AmbariClient():
|
|||
self.handler.install_swift_integration(servers)
|
||||
|
||||
def cleanup(self, ambari_info):
|
||||
ambari_info.host.remote().close_http_sessions()
|
||||
try:
|
||||
ambari_info.host.remote().close_http_session(ambari_info.port)
|
||||
except exc.NotFoundException:
|
||||
LOG.info("HTTP session is not cached")
|
||||
|
||||
def _get_services_in_state(self, cluster_name, ambari_info, state):
|
||||
services_url = 'http://{0}/api/v1/clusters/{1}/services?' \
|
||||
|
|
|
@ -21,6 +21,7 @@ from oslo.config import cfg
|
|||
import pkg_resources as pkg
|
||||
|
||||
from sahara import context
|
||||
from sahara import exceptions as exc
|
||||
from sahara.plugins.general import exceptions as ex
|
||||
from sahara.plugins.hdp import clusterspec as cs
|
||||
from sahara.plugins.hdp import configprovider as cfgprov
|
||||
|
@ -562,7 +563,10 @@ class AmbariClient():
|
|||
self.handler.install_swift_integration(servers)
|
||||
|
||||
def cleanup(self, ambari_info):
|
||||
ambari_info.host.remote().close_http_sessions()
|
||||
try:
|
||||
ambari_info.host.remote().close_http_session(ambari_info.port)
|
||||
except exc.NotFoundException:
|
||||
LOG.info("HTTP session is not cached")
|
||||
|
||||
def _get_services_in_state(self, cluster_name, ambari_info, state):
|
||||
services_url = ('http://{0}/api/v1/clusters/{1}/services?'
|
||||
|
|
|
@ -66,8 +66,8 @@ class Remote(object):
|
|||
"""Returns HTTP client for a given instance's port."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def close_http_sessions(self):
|
||||
"""Closes all cached HTTP sessions."""
|
||||
def close_http_session(self, port):
|
||||
"""Closes cached HTTP session for a given instance's port."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def execute_command(self, cmd, run_as_root=False, get_stderr=False,
|
||||
|
|
|
@ -353,12 +353,21 @@ class InstanceInteropHelper(remote.Remote):
|
|||
return _get_http_client(self.instance.management_ip, port, info,
|
||||
*args, **kwargs)
|
||||
|
||||
def close_http_sessions(self):
|
||||
def close_http_session(self, port):
|
||||
global _sessions
|
||||
|
||||
LOG.debug('closing host related http sessions')
|
||||
for session in _sessions.values():
|
||||
session.close()
|
||||
host = self.instance.management_ip
|
||||
self._log_command("Closing HTTP session for %(host)s:%(port)s" % {
|
||||
'host': host, 'port': port})
|
||||
|
||||
session = _sessions.get((host, port), None)
|
||||
if session is None:
|
||||
raise ex.NotFoundException(
|
||||
'Session for %(host)s:%(port)s not cached' % {
|
||||
'host': host, 'port': port})
|
||||
|
||||
session.close()
|
||||
del _sessions[(host, port)]
|
||||
|
||||
def execute_command(self, cmd, run_as_root=False, get_stderr=False,
|
||||
raise_when_error=True, timeout=300):
|
||||
|
|
Loading…
Reference in New Issue