Allow Swift endpoint override

Swiftclient uses public endpoint by default. Ironic uses the base URL
from Swift connection to build TempURLs for generated images.
Some drivers (e.g. iLO) use those TempURLs to mount images as vmedia.
With public URLs it will fail if the BMC doesn't have access to the
public network.

This change introduces an option to explicitly set the endpoint URL
used for Swift.

This is a stable-only change as the problem is fixed by refactoring
changes in later releases. This is the only version where Ironic uses
public Swift endpoints and there is no option to override this.

Change-Id: I639a421fa06fff7ab07b8eab557531b8f36c5ed9
Closes-Bug: #1755164
Related-Bug: #1699547
This commit is contained in:
Jacek Tomasiak 2018-03-15 11:59:07 +01:00
parent 93012b2df1
commit ca4fb9b1cf
4 changed files with 27 additions and 0 deletions

View File

@ -55,6 +55,11 @@ class SwiftAPI(object):
# with swift is initialized. Since v3.2.0 swiftclient supports
# instantiating the API client from keystoneauth session.
params = {'session': _get_swift_session()}
if CONF.swift.endpoint_override:
params['os_options'] = {
'object_storage_url': CONF.swift.endpoint_override}
self.connection = swift_client.Connection(**params)
def create_object(self, container, obj, filename,

View File

@ -20,6 +20,9 @@ from ironic.common.i18n import _
from ironic.conf import auth
opts = [
cfg.StrOpt('endpoint_override',
help=_('Always use this endpoint URL for requests to Swift. '
'It also controls base URL used for image TempURLs.')),
cfg.IntOpt('swift_max_retries',
default=2,
help=_('Maximum number of times to retry a Swift request, '

View File

@ -47,6 +47,17 @@ class SwiftTestCase(base.TestCase):
connection_mock.assert_called_once_with(
session=keystone_mock.return_value)
def test___init___endpoint(self, connection_mock, keystone_mock):
"""Check if client is properly initialized with endpoint override"""
CONF.swift.endpoint_override = 'dummy_override_url'
swift.SwiftAPI()
connection_mock.assert_called_once_with(
session=keystone_mock.return_value,
os_options={'object_storage_url': 'dummy_override_url'}
)
def test___init___radosgw(self, connection_mock, swift_session_mock):
"""Check if client is properly initialized with radosgw"""

View File

@ -0,0 +1,8 @@
---
fixes:
- Adds ``[swift]/endpoint_override`` option to explicitly set the endpoint
URL used for Swift. Ironic uses the Swift connection URL as a base for
generation of some TempURLs. Added parameter enables operators to fix
the problem when image is attached (via TempURL) as vmedia (e.g. in iLO
driver) and BMC doesn't have connectivity to public network.
By default this parameter is not set for backward compatibility.