Commit fixes from staging testing: add required region name parameter.

sil2100/private-runs
Łukasz 'sil2100' Zemczak 3 years ago
parent f79ec3bf54
commit 41b606c2ca

@ -108,6 +108,7 @@ ADT_SWIFT_USER =
ADT_SWIFT_PASS = ADT_SWIFT_PASS =
ADT_SWIFT_AUTH_URL = ADT_SWIFT_AUTH_URL =
ADT_SWIFT_TENANT = ADT_SWIFT_TENANT =
ADT_SWIFT_REGION =
# List of launchpad users/teams that should have read access to any private # List of launchpad users/teams that should have read access to any private
# result logs # result logs
ADT_PRIVATE_SHARED = ADT_PRIVATE_SHARED =

@ -130,6 +130,7 @@ ADT_SWIFT_USER =
ADT_SWIFT_PASS = ADT_SWIFT_PASS =
ADT_SWIFT_AUTH_URL = ADT_SWIFT_AUTH_URL =
ADT_SWIFT_TENANT = ADT_SWIFT_TENANT =
ADT_SWIFT_REGION =
# List of launchpad users/teams that should have read access to any private # List of launchpad users/teams that should have read access to any private
# result logs # result logs
ADT_PRIVATE_SHARED = ADT_PRIVATE_SHARED =

@ -211,7 +211,8 @@ class AutopkgtestPolicy(BasePolicy):
if self.options.adt_swift_user: if self.options.adt_swift_user:
if (not self.options.adt_swift_pass or if (not self.options.adt_swift_pass or
not self.options.adt_swift_auth_url or not self.options.adt_swift_auth_url or
not self.options.adt_swift_tenant): not self.options.adt_swift_tenant or
not self.options.adt_swift_region):
raise RuntimeError('Incomplete swift credentials given') raise RuntimeError('Incomplete swift credentials given')
# once swift credentials are given, the results will be published # once swift credentials are given, the results will be published
@ -228,10 +229,8 @@ class AutopkgtestPolicy(BasePolicy):
import swiftclient import swiftclient
if '/v2.0' in self.options.adt_swift_auth_url: if '/v2.0' not in self.options.adt_swift_auth_url:
auth_version = '2.0' raise RuntimeError('Unsupported swift auth version')
else:
auth_version = '1'
self.logger.info('Creating an authenticated swift connection for user %s', self.options.adt_swift_user) self.logger.info('Creating an authenticated swift connection for user %s', self.options.adt_swift_user)
self.swift_conn = swiftclient.Connection( self.swift_conn = swiftclient.Connection(
@ -239,7 +238,8 @@ class AutopkgtestPolicy(BasePolicy):
user=self.options.adt_swift_user, user=self.options.adt_swift_user,
key=self.options.adt_swift_pass, key=self.options.adt_swift_pass,
tenant_name=self.options.adt_swift_tenant, tenant_name=self.options.adt_swift_tenant,
auth_version=auth_version auth_version='2.0',
os_options={'region_name': self.options.adt_swift_region}
) )
else: else:
if any('@' in ppa for ppa in self.options.adt_ppas): if any('@' in ppa for ppa in self.options.adt_ppas):
@ -910,12 +910,12 @@ class AutopkgtestPolicy(BasePolicy):
from swiftclient.exceptions import ClientException from swiftclient.exceptions import ClientException
try: try:
_, result_paths = self.swift_conn.get_container( _, returned_paths = self.swift_conn.get_container(
self.swift_container, self.swift_container,
query_string=urllib.parse.urlencode(query)) query_string=urllib.parse.urlencode(query))
except ClientException as e: except ClientException as e:
# 401 "Unauthorized" is swift's way of saying "container does not exist" # 401 "Unauthorized" is swift's way of saying "container does not exist"
if e.http_status == '401' or e.http_status == '404': if e.http_status == 401 or e.http_status == 404:
self.logger.info('fetch_swift_results: %s does not exist yet or is inaccessible', self.swift_container) self.logger.info('fetch_swift_results: %s does not exist yet or is inaccessible', self.swift_container)
return return
# Other status codes are usually a transient # Other status codes are usually a transient
@ -924,6 +924,7 @@ class AutopkgtestPolicy(BasePolicy):
# fail hard on this and let the next run retry. # fail hard on this and let the next run retry.
self.logger.error('Failure to fetch swift results from %s: %s', self.swift_container, str(e)) self.logger.error('Failure to fetch swift results from %s: %s', self.swift_container, str(e))
sys.exit(1) sys.exit(1)
result_paths = [p['subdir'] for p in returned_paths]
else: else:
url = os.path.join(swift_url, self.swift_container) url = os.path.join(swift_url, self.swift_container)
url += '?' + urllib.parse.urlencode(query) url += '?' + urllib.parse.urlencode(query)
@ -977,7 +978,7 @@ class AutopkgtestPolicy(BasePolicy):
except ClientException as e: except ClientException as e:
self.logger.error('Failure to fetch %s from container %s: %s', self.logger.error('Failure to fetch %s from container %s: %s',
url, container, str(e)) url, container, str(e))
if e.http_status == '404': if e.http_status == 404:
return return
sys.exit(1) sys.exit(1)
tar_bytes = io.BytesIO(contents) tar_bytes = io.BytesIO(contents)

@ -399,6 +399,7 @@ ADT_SWIFT_USER =
ADT_SWIFT_PASS = ADT_SWIFT_PASS =
ADT_SWIFT_AUTH_URL = ADT_SWIFT_AUTH_URL =
ADT_SWIFT_TENANT = ADT_SWIFT_TENANT =
ADT_SWIFT_REGION =
ADT_PRIVATE_SHARED = ADT_PRIVATE_SHARED =
ADT_PRIVATE_URL = ADT_PRIVATE_URL =
ADT_CI_URL = https://autopkgtest.ubuntu.com/ ADT_CI_URL = https://autopkgtest.ubuntu.com/

@ -2560,6 +2560,8 @@ class AT(TestAutopkgtestBase):
print('ADT_SWIFT_PASS = pass') print('ADT_SWIFT_PASS = pass')
elif line.startswith('ADT_SWIFT_TENANT'): elif line.startswith('ADT_SWIFT_TENANT'):
print('ADT_SWIFT_TENANT = tenant') print('ADT_SWIFT_TENANT = tenant')
elif line.startswith('ADT_SWIFT_REGION'):
print('ADT_SWIFT_REGION = region')
elif line.startswith('ADT_SWIFT_AUTH_URL'): elif line.startswith('ADT_SWIFT_AUTH_URL'):
print('ADT_SWIFT_AUTH_URL = http://127.0.0.1:5000/v2.0/') print('ADT_SWIFT_AUTH_URL = http://127.0.0.1:5000/v2.0/')
elif line.startswith('ADT_PRIVATE_SHARED'): elif line.startswith('ADT_PRIVATE_SHARED'):
@ -2632,6 +2634,8 @@ class AT(TestAutopkgtestBase):
print('ADT_SWIFT_PASS = pass') print('ADT_SWIFT_PASS = pass')
elif line.startswith('ADT_SWIFT_TENANT'): elif line.startswith('ADT_SWIFT_TENANT'):
print('ADT_SWIFT_TENANT = tenant') print('ADT_SWIFT_TENANT = tenant')
elif line.startswith('ADT_SWIFT_REGION'):
print('ADT_SWIFT_REGION = region')
elif line.startswith('ADT_SWIFT_AUTH_URL'): elif line.startswith('ADT_SWIFT_AUTH_URL'):
print('ADT_SWIFT_AUTH_URL = http://127.0.0.1:5000/v2.0/') print('ADT_SWIFT_AUTH_URL = http://127.0.0.1:5000/v2.0/')
elif line.startswith('ADT_PRIVATE_URL'): elif line.startswith('ADT_PRIVATE_URL'):

Loading…
Cancel
Save