Merge "Fix invalid admin endpoint cert during subcloud upgrade"

This commit is contained in:
Zuul 2021-05-11 13:16:04 +00:00 committed by Gerrit Code Review
commit f5a419194b
3 changed files with 29 additions and 5 deletions

View File

@ -166,6 +166,11 @@ class CertificateMonManager(periodic_task.PeriodicTasks):
# Failed tasks that need to be reattempted will be taken care here
max_attempts = CONF.certmon.max_retry
tasks = self.reattempt_tasks[:]
num_tasks = len(tasks)
if num_tasks > 0:
LOG.info('%s failed tasks to reattempt in queue.' % num_tasks)
for task in tasks:
if task.run():
self.reattempt_tasks.remove(task)

View File

@ -58,12 +58,17 @@ class CertificateMonitorService(service.Service):
self._rpc_server = rpc_messaging.get_rpc_server(self.target, self)
self._rpc_server.start()
elif dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SUBCLOUD:
self.manager.start_audit()
def stop(self):
dc_role = utils.get_dc_role()
if dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER:
self._stop_rpc_server()
self.manager.stop_audit()
elif dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SUBCLOUD:
self.manager.stop_audit()
self.manager.stop_monitor()
super(CertificateMonitorService, self).stop()
rpc_messaging.cleanup()

View File

@ -618,23 +618,37 @@ def upload_request_with_data(token, url, **kwargs):
files = {'file': ("for_upload",
kwargs['body'],)}
data = kwargs.get('data')
req = requests.post(url, headers=headers, files=files,
data=data)
timeout = kwargs.get('timeout')
try:
req = requests.post(url, headers=headers, files=files,
data=data, timeout=timeout)
req.raise_for_status()
except requests.exceptions.HTTPError as e:
if 401 == e.response.status_code:
if token:
token.set_expired()
raise
except requests.exceptions.InvalidURL:
LOG.error("Cannot access %s" % url)
raise
LOG.info('response from upload API = %s' % req.json())
return req.json()
def rest_api_upload(token, filepath, url, data=None):
def rest_api_upload(token, filepath, url, data=None, timeout=30):
"""
Make a rest-api upload call
"""
LOG.info('rest_api_upload called. filepath=%s, url=%s, data=%s' % (filepath, url, data))
LOG.info('rest_api_upload called. filepath=%s, url=%s, data=%s, timeout=%s'
% (filepath, url, data, timeout))
try:
file_to_upload = open(filepath, 'rb')
except Exception as e:
LOG.exception(e)
return upload_request_with_data(token, url, body=file_to_upload, data=data)
return upload_request_with_data(token, url, body=file_to_upload, data=data,
timeout=timeout)
def update_pemfile(tls_crt, tls_key):