Add region name to trove-guestagent
In a shared keystone multi-region setup, we must set the region_name
when using any of the OpenStack clients. Without the region name,
clients may attempt to use the API endpoints in the wrong region.
Backups currently fail if there are multiple regions created in the
same keystone catalog, due to the fact that the trove guest agent
attempts to connect to the S3 endpoint in another region.
Story: 2010950
Task: 48994
Change-Id: I9bd497c85c6eba67485840d07a80cca8eed27994
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
(cherry picked from commit e998b68866
)
This commit is contained in:
parent
8c47360daa
commit
bb8bbbeb66
@ -52,6 +52,7 @@ cli_opts = [
|
||||
cfg.StrOpt('db-datadir'),
|
||||
cfg.StrOpt('os-token'),
|
||||
cfg.StrOpt('os-auth-url'),
|
||||
cfg.StrOpt('os-region-name'),
|
||||
cfg.StrOpt('os-tenant-id'),
|
||||
cfg.StrOpt('swift-container', default='database_backups'),
|
||||
cfg.DictOpt('swift-extra-metadata'),
|
||||
|
@ -36,9 +36,14 @@ def _get_user_keystone_session(auth_url, token, tenant_id):
|
||||
return session.Session(auth=auth, verify=False)
|
||||
|
||||
|
||||
def _get_service_client(auth_url, token, tenant_id):
|
||||
def _get_service_client(auth_url, token, tenant_id, region_name=None):
|
||||
sess = _get_user_keystone_session(auth_url, token, tenant_id)
|
||||
return swiftclient.Connection(session=sess)
|
||||
os_options = None
|
||||
if region_name:
|
||||
os_options = {
|
||||
'region_name': region_name
|
||||
}
|
||||
return swiftclient.Connection(session=sess, os_options=os_options)
|
||||
|
||||
|
||||
def _set_attr(original):
|
||||
@ -111,7 +116,8 @@ class StreamReader(object):
|
||||
class SwiftStorage(base.Storage):
|
||||
def __init__(self):
|
||||
self.client = _get_service_client(CONF.os_auth_url, CONF.os_token,
|
||||
CONF.os_tenant_id)
|
||||
CONF.os_tenant_id,
|
||||
region_name=CONF.os_region_name)
|
||||
|
||||
def save(self, stream, metadata=None, container='database_backups'):
|
||||
"""Persist data from the stream to swift.
|
||||
|
@ -689,6 +689,7 @@ class BaseMySqlApp(service.BaseDbApp):
|
||||
backup_driver = self.get_backup_strategy()
|
||||
user_token = context.auth_token
|
||||
auth_url = CONF.service_credentials.auth_url
|
||||
region_name = CONF.service_credentials.region_name
|
||||
user_tenant = context.project_id
|
||||
image = self.get_backup_image()
|
||||
name = 'db_restore'
|
||||
@ -698,7 +699,7 @@ class BaseMySqlApp(service.BaseDbApp):
|
||||
f'/usr/bin/python3 main.py --nobackup '
|
||||
f'--storage-driver={storage_driver} --driver={backup_driver} '
|
||||
f'--os-token={user_token} --os-auth-url={auth_url} '
|
||||
f'--os-tenant-id={user_tenant} '
|
||||
f'--os-tenant-id={user_tenant} --os-region-name={region_name} '
|
||||
f'--restore-from={backup_info["location"]} '
|
||||
f'--restore-checksum={backup_info["checksum"]}'
|
||||
)
|
||||
|
@ -267,7 +267,8 @@ class PgSqlApp(service.BaseDbApp):
|
||||
|
||||
os_cred = (f"--os-token={context.auth_token} "
|
||||
f"--os-auth-url={CONF.service_credentials.auth_url} "
|
||||
f"--os-tenant-id={context.project_id}")
|
||||
f"--os-tenant-id={context.project_id} "
|
||||
f"--os-region-name={CONF.service_credentials.region_name}")
|
||||
|
||||
command = (
|
||||
f'/usr/bin/python3 main.py --nobackup '
|
||||
|
@ -438,7 +438,8 @@ class BaseDbApp(object):
|
||||
image = self.get_backup_image()
|
||||
os_cred = (f"--os-token={context.auth_token} "
|
||||
f"--os-auth-url={CONF.service_credentials.auth_url} "
|
||||
f"--os-tenant-id={context.project_id}")
|
||||
f"--os-tenant-id={context.project_id} "
|
||||
f"--os-region-name={CONF.service_credentials.region_name}")
|
||||
|
||||
db_userinfo = ''
|
||||
if need_dbuser:
|
||||
|
Loading…
Reference in New Issue
Block a user