From 87cd9e59ddeeed536cd0d736f36e2eaaf9b47b90 Mon Sep 17 00:00:00 2001 From: Rabi Mishra Date: Thu, 22 Aug 2019 19:03:16 +0530 Subject: [PATCH] Use connect_retries when creating clients When creating session clients we should use 'connect_retries' for clients that use Adapter interface. This will allow retries when we get ConnectTimeout errors. Task: 36331 Change-Id: Ic526c8039c91353e772eee7b55f1d263470c86bb (cherry picked from commit 364716725a4767f8d9e3e5e1c76ecf4f969a6613 and c7cc740f307ce8ffdf36c29094c9cbce5a6c8d14) --- heat/engine/clients/os/aodh.py | 2 ++ heat/engine/clients/os/barbican.py | 2 ++ heat/engine/clients/os/cinder.py | 2 ++ heat/engine/clients/os/glance.py | 2 ++ heat/engine/clients/os/heat_plugin.py | 1 + heat/engine/clients/os/keystone/heat_keystoneclient.py | 2 ++ heat/engine/clients/os/magnum.py | 2 ++ heat/engine/clients/os/manila.py | 2 ++ heat/engine/clients/os/neutron/__init__.py | 4 +++- heat/engine/clients/os/nova.py | 1 + heat/engine/clients/os/sahara.py | 2 ++ heat/engine/clients/os/trove.py | 2 ++ heat/tests/clients/test_heat_client.py | 3 +++ 13 files changed, 26 insertions(+), 1 deletion(-) diff --git a/heat/engine/clients/os/aodh.py b/heat/engine/clients/os/aodh.py index f734f8778b..e8aab0957a 100644 --- a/heat/engine/clients/os/aodh.py +++ b/heat/engine/clients/os/aodh.py @@ -13,6 +13,7 @@ from aodhclient import client as ac from aodhclient import exceptions +from oslo_config import cfg from heat.engine.clients import client_plugin @@ -37,6 +38,7 @@ class AodhClientPlugin(client_plugin.ClientPlugin): session=self.context.keystone_session, interface=interface, service_type=self.ALARMING, + connect_retries=cfg.CONF.client_retry_limit, region_name=self._get_region_name()) def is_not_found(self, ex): diff --git a/heat/engine/clients/os/barbican.py b/heat/engine/clients/os/barbican.py index 76400f8c8c..ddde40dd27 100644 --- a/heat/engine/clients/os/barbican.py +++ b/heat/engine/clients/os/barbican.py @@ -14,6 +14,7 @@ from barbicanclient import exceptions from barbicanclient.v1 import client as barbican_client from barbicanclient.v1 import containers +from oslo_config import cfg from heat.common import exception from heat.engine.clients import client_plugin @@ -33,6 +34,7 @@ class BarbicanClientPlugin(client_plugin.ClientPlugin): session=self.context.keystone_session, service_type=self.KEY_MANAGER, interface=interface, + connect_retries=cfg.CONF.client_retry_limit, region_name=self._get_region_name()) return client diff --git a/heat/engine/clients/os/cinder.py b/heat/engine/clients/os/cinder.py index 7e876efd55..7ffce206cd 100644 --- a/heat/engine/clients/os/cinder.py +++ b/heat/engine/clients/os/cinder.py @@ -14,6 +14,7 @@ from cinderclient import client as cc from cinderclient import exceptions from keystoneauth1 import exceptions as ks_exceptions +from oslo_config import cfg from oslo_log import log as logging from heat.common import exception @@ -62,6 +63,7 @@ class CinderClientPlugin(client_plugin.ClientPlugin): 'interface': self.interface, 'service_type': self.service_type, 'region_name': self._get_region_name(), + 'connect_retries': cfg.CONF.client_retry_limit, 'http_log_debug': self._get_client_option(CLIENT_NAME, 'http_log_debug') } diff --git a/heat/engine/clients/os/glance.py b/heat/engine/clients/os/glance.py index 59970b4ccc..caa306d4f0 100644 --- a/heat/engine/clients/os/glance.py +++ b/heat/engine/clients/os/glance.py @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg from oslo_utils import uuidutils from glanceclient import client as gc @@ -41,6 +42,7 @@ class GlanceClientPlugin(client_plugin.ClientPlugin): return gc.Client(version, session=con.keystone_session, interface=interface, service_type=self.IMAGE, + connect_retries=cfg.CONF.client_retry_limit, region_name=self._get_region_name()) def _find_with_attr(self, entity, **kwargs): diff --git a/heat/engine/clients/os/heat_plugin.py b/heat/engine/clients/os/heat_plugin.py index fb51328932..76cdf990d4 100644 --- a/heat/engine/clients/os/heat_plugin.py +++ b/heat/engine/clients/os/heat_plugin.py @@ -38,6 +38,7 @@ class HeatClientPlugin(client_plugin.ClientPlugin): args['username'] = self.context.username args['password'] = self.context.password + args['connect_retries'] = cfg.CONF.client_retry_limit return hc.Client('1', endpoint_override=endpoint, session=self.context.keystone_session, **args) diff --git a/heat/engine/clients/os/keystone/heat_keystoneclient.py b/heat/engine/clients/os/keystone/heat_keystoneclient.py index 315c57313b..fcb72fcb2e 100644 --- a/heat/engine/clients/os/keystone/heat_keystoneclient.py +++ b/heat/engine/clients/os/keystone/heat_keystoneclient.py @@ -152,12 +152,14 @@ class KsClientWrapper(object): self._domain_admin_client = kc_v3.Client( session=self.session, auth=self.domain_admin_auth, + connect_retries=cfg.CONF.client_retry_limit, region_name=self.region_name) return self._domain_admin_client def _v3_client_init(self): client = kc_v3.Client(session=self.session, + connect_retries=cfg.CONF.client_retry_limit, region_name=self.region_name) if hasattr(self.context.auth_plugin, 'get_access'): diff --git a/heat/engine/clients/os/magnum.py b/heat/engine/clients/os/magnum.py index 216f4ece93..310b81c8d4 100644 --- a/heat/engine/clients/os/magnum.py +++ b/heat/engine/clients/os/magnum.py @@ -13,6 +13,7 @@ from magnumclient import exceptions as mc_exc from magnumclient.v1 import client as magnum_client +from oslo_config import cfg from heat.common import exception from heat.engine.clients import client_plugin @@ -31,6 +32,7 @@ class MagnumClientPlugin(client_plugin.ClientPlugin): 'interface': interface, 'service_type': self.CONTAINER, 'session': self.context.keystone_session, + 'connect_retries': cfg.CONF.client_retry_limit, 'region_name': self._get_region_name() } client = magnum_client.Client(**args) diff --git a/heat/engine/clients/os/manila.py b/heat/engine/clients/os/manila.py index 90c17046bf..e2e32c5a03 100644 --- a/heat/engine/clients/os/manila.py +++ b/heat/engine/clients/os/manila.py @@ -16,6 +16,7 @@ from heat.engine.clients import client_plugin from heat.engine import constraints from manilaclient import client as manila_client from manilaclient import exceptions +from oslo_config import cfg MANILACLIENT_VERSION = "2" CLIENT_NAME = 'manila' @@ -33,6 +34,7 @@ class ManilaClientPlugin(client_plugin.ClientPlugin): 'endpoint_type': endpoint_type, 'service_type': self.SHARE, 'session': self.context.keystone_session, + 'connect_retries': cfg.CONF.client_retry_limit, 'region_name': self._get_region_name() } client = manila_client.Client(MANILACLIENT_VERSION, **args) diff --git a/heat/engine/clients/os/neutron/__init__.py b/heat/engine/clients/os/neutron/__init__.py index 74988aa1cb..64ee0bf1dc 100644 --- a/heat/engine/clients/os/neutron/__init__.py +++ b/heat/engine/clients/os/neutron/__init__.py @@ -14,6 +14,7 @@ from neutronclient.common import exceptions from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.v2_0 import client as nc +from oslo_config import cfg from oslo_utils import uuidutils from heat.common import exception @@ -44,7 +45,8 @@ class NeutronClientPlugin(client_plugin.ClientPlugin): 'session': con.keystone_session, 'service_type': self.NETWORK, 'interface': interface, - 'region_name': self._get_region_name() + 'region_name': self._get_region_name(), + 'connect_retries': cfg.CONF.client_retry_limit } return nc.Client(**args) diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index 80efb84b20..2654d2835e 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -87,6 +87,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin): 'endpoint_type': endpoint_type, 'service_type': self.COMPUTE, 'region_name': self._get_region_name(), + 'connect_retries': cfg.CONF.client_retry_limit, 'http_log_debug': self._get_client_option(CLIENT_NAME, 'http_log_debug') } diff --git a/heat/engine/clients/os/sahara.py b/heat/engine/clients/os/sahara.py index 7f82b2e29f..7146538b6b 100644 --- a/heat/engine/clients/os/sahara.py +++ b/heat/engine/clients/os/sahara.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from oslo_config import cfg from saharaclient.api import base as sahara_base from saharaclient import client as sahara_client import six @@ -38,6 +39,7 @@ class SaharaClientPlugin(client_plugin.ClientPlugin): 'endpoint_type': endpoint_type, 'service_type': self.DATA_PROCESSING, 'session': con.keystone_session, + 'connect_retries': cfg.CONF.client_retry_limit, 'region_name': self._get_region_name() } client = sahara_client.Client('1.1', **args) diff --git a/heat/engine/clients/os/trove.py b/heat/engine/clients/os/trove.py index c645300b70..14fbc28804 100644 --- a/heat/engine/clients/os/trove.py +++ b/heat/engine/clients/os/trove.py @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg from troveclient import client as tc from troveclient import exceptions @@ -36,6 +37,7 @@ class TroveClientPlugin(client_plugin.ClientPlugin): 'endpoint_type': endpoint_type, 'service_type': self.DATABASE, 'session': con.keystone_session, + 'connect_retries': cfg.CONF.client_retry_limit, 'region_name': self._get_region_name() } diff --git a/heat/tests/clients/test_heat_client.py b/heat/tests/clients/test_heat_client.py index 3764aa60ae..610b3abec1 100644 --- a/heat/tests/clients/test_heat_client.py +++ b/heat/tests/clients/test_heat_client.py @@ -95,6 +95,7 @@ class KeystoneClientTest(common.HeatTestCase): n = kc_v3.Client(session=mox.IsA(ks_session.Session), auth=mock_ks_auth, + connect_retries=2, region_name=None) n.AndReturn(self.mock_admin_client) @@ -139,6 +140,7 @@ class KeystoneClientTest(common.HeatTestCase): if client: c = kc_v3.Client(session=mox.IsA(ks_session.Session), + connect_retries=2, region_name=None) c.AndReturn(self.mock_ks_v3_client) @@ -1448,6 +1450,7 @@ class KeystoneClientTestDomainName(KeystoneClientTest): n = kc_v3.Client(session=mox.IsA(ks_session.Session), auth=mock_ks_auth, + connect_retries=2, region_name=None) n.AndReturn(self.mock_admin_client)