From cda9e802b30369b835f139269d4a4aa442f23fb2 Mon Sep 17 00:00:00 2001 From: Isaac Mungai Date: Mon, 3 Oct 2016 10:25:03 -0400 Subject: [PATCH] Create new context for each recreation of ssl cert This will make tracking cert creation easier when searching through logs by request_id. Change-Id: Ic233f537bbbe3762a2e561677f7e24982e5ab904 --- .../distributed_task/taskflow/flow/recreate_ssl_certificate.py | 3 +++ poppy/manager/default/ssl_certificate.py | 3 +++ tests/unit/distributed_task/taskflow/test_flows.py | 1 + 3 files changed, 7 insertions(+) diff --git a/poppy/distributed_task/taskflow/flow/recreate_ssl_certificate.py b/poppy/distributed_task/taskflow/flow/recreate_ssl_certificate.py index 3fb08e92..55bd6616 100644 --- a/poppy/distributed_task/taskflow/flow/recreate_ssl_certificate.py +++ b/poppy/distributed_task/taskflow/flow/recreate_ssl_certificate.py @@ -18,6 +18,7 @@ from oslo_log import log from taskflow.patterns import linear_flow from taskflow import retry +from poppy.distributed_task.taskflow.task import common from poppy.distributed_task.taskflow.task import create_ssl_certificate_tasks from poppy.distributed_task.taskflow.task import delete_ssl_certificate_tasks @@ -30,6 +31,8 @@ conf(project='poppy', prog='poppy', args=[]) def recreate_ssl_certificate(): flow = linear_flow.Flow('Recreating poppy ssl certificate').add( + linear_flow.Flow('Update Oslo Context').add( + common.ContextUpdateTask()), delete_ssl_certificate_tasks.DeleteStorageSSLCertificateTask(), create_ssl_certificate_tasks.CreateStorageSSLCertificateTask(), linear_flow.Flow("Provision poppy ssl certificate", diff --git a/poppy/manager/default/ssl_certificate.py b/poppy/manager/default/ssl_certificate.py index ed187373..9820ac87 100644 --- a/poppy/manager/default/ssl_certificate.py +++ b/poppy/manager/default/ssl_certificate.py @@ -285,6 +285,9 @@ class DefaultSSLCertificateController(base.SSLCertificateController): 'providers_list_json': json.dumps(providers), 'cert_obj_json': json.dumps(cert_obj.to_dict()), 'enqueue': False, + 'context_dict': context_utils.RequestContext( + tenant=cert_obj.project_id + ).to_dict() } self.distributed_task_controller.submit_task( recreate_ssl_certificate.recreate_ssl_certificate, diff --git a/tests/unit/distributed_task/taskflow/test_flows.py b/tests/unit/distributed_task/taskflow/test_flows.py index 42bb37cd..1df17961 100644 --- a/tests/unit/distributed_task/taskflow/test_flows.py +++ b/tests/unit/distributed_task/taskflow/test_flows.py @@ -1030,6 +1030,7 @@ class TestFlowRuns(base.TestCase): 'domain_name': 'mytestsite.com', 'cert_type': 'san', 'cert_obj_json': json.dumps(cert_obj_json.to_dict()), + 'context_dict': context_utils.RequestContext().to_dict() } (