swift: Do not search storage_url for ks v2
Previously, we introduced a re-auth approach for swift store. In case of single-tenant store we stated that it works with Keystone v3 only when re-authenticating but we also need to make the same restriction when receiving swift endpoint from keystone becase it breaks some installations where auth_url contains trailing slash. So now if auth_version is not v3 then we don't search endpoint url from Keystone in this case and simply return None. It is safe because we don't do any re-authentication for v1 or v2 and use old methods for that version. Change-Id: Id8dab9ed74eef56ffa4937bf29f96888b673ad64 Closes-Bug: #1552132
This commit is contained in:
parent
6c4ae678f5
commit
fb77cb73c5
|
@ -19,6 +19,7 @@ connection with valid credentials and updated token"""
|
|||
import logging
|
||||
|
||||
from keystoneclient import exceptions as ks_exceptions
|
||||
from oslo_utils import encodeutils
|
||||
|
||||
from glance_store import exceptions
|
||||
from glance_store.i18n import _
|
||||
|
@ -137,11 +138,26 @@ class SwiftConnectionManager(object):
|
|||
|
||||
class SingleTenantConnectionManager(SwiftConnectionManager):
|
||||
def _get_storage_url(self):
|
||||
return self.client.session.get_endpoint(
|
||||
service_type=self.store.service_type,
|
||||
interface=self.store.endpoint_type,
|
||||
region_name=self.store.region
|
||||
)
|
||||
"""Get swift endpoint from keystone
|
||||
|
||||
Return endpoint for swift from service catalog. The method works only
|
||||
Keystone v3. If you are using different version (1 or 2)
|
||||
it returns None.
|
||||
:return: swift endpoint
|
||||
"""
|
||||
if self.store.auth_version == '3':
|
||||
try:
|
||||
return self.client.session.get_endpoint(
|
||||
service_type=self.store.service_type,
|
||||
interface=self.store.endpoint_type,
|
||||
region_name=self.store.region
|
||||
)
|
||||
except Exception as e:
|
||||
# do the same that swift driver does
|
||||
# when catching ClientException
|
||||
msg = _("Cannot find swift service endpoint : "
|
||||
"%s") % encodeutils.exception_to_unicode(e)
|
||||
raise exceptions.BackendException(msg)
|
||||
|
||||
def _init_connection(self):
|
||||
if self.store.auth_version == '3':
|
||||
|
|
|
@ -22,7 +22,6 @@ import mock
|
|||
import tempfile
|
||||
import uuid
|
||||
|
||||
from keystoneclient import exceptions as ks_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import units
|
||||
|
@ -974,6 +973,8 @@ class SwiftTests(object):
|
|||
conf = copy.deepcopy(SWIFT_CONF)
|
||||
self.config(**conf)
|
||||
moves.reload_module(swift)
|
||||
# mock client because v3 uses it to receive auth_info
|
||||
self.mock_keystone_client()
|
||||
self.store = Store(self.conf)
|
||||
self.store.configure()
|
||||
|
||||
|
@ -981,7 +982,7 @@ class SwiftTests(object):
|
|||
loc = location.get_location_from_uri(uri, conf=self.conf)
|
||||
self.store.delete(loc)
|
||||
|
||||
self.assertRaises(ks_exceptions.NotFound, self.store.get, loc)
|
||||
self.assertRaises(exceptions.NotFound, self.store.get, loc)
|
||||
|
||||
def test_delete_non_existing(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue