Mark san mapping items to mark progress
Since we have two types of jobs for san mapping queue mark completion of the first job in order to filter items for the second job type. The order of execution for job types matters. Change-Id: Ifc9e5a24c9359befc5580007940d3aa7b9437426
This commit is contained in:
parent
9cf9088569
commit
6fa8a5959a
@ -47,7 +47,10 @@ class BackgroundJobController(base.BackgroundJobController):
|
||||
run_list = []
|
||||
ignore_list = []
|
||||
if job_type == "akamai_check_and_update_cert_status":
|
||||
# this task will consume the san mapping queue
|
||||
# this task consumes the san mapping queue
|
||||
# items marked as having an updated property are processed
|
||||
# for the this job type, all other items are returned to the
|
||||
# queue until they are ready for processing
|
||||
if 'akamai' in self._driver.providers:
|
||||
akamai_driver = self._driver.providers['akamai'].obj
|
||||
queue_data += akamai_driver.san_mapping_queue.traverse_queue(
|
||||
@ -72,12 +75,24 @@ class BackgroundJobController(base.BackgroundJobController):
|
||||
"cert_obj_json": json.dumps(cert_dict),
|
||||
"project_id": cert_dict.get("project_id")
|
||||
}
|
||||
self.distributed_task_controller.submit_task(
|
||||
check_cert_status_and_update_flow.
|
||||
check_cert_status_and_update_flow,
|
||||
**t_kwargs
|
||||
)
|
||||
run_list.append(cert_dict)
|
||||
if cert_dict.get('property_activated', False) is True:
|
||||
self.distributed_task_controller.submit_task(
|
||||
check_cert_status_and_update_flow.
|
||||
check_cert_status_and_update_flow,
|
||||
**t_kwargs
|
||||
)
|
||||
run_list.append(cert_dict)
|
||||
else:
|
||||
akamai_driver.san_mapping_queue.\
|
||||
enqueue_san_mapping(json.dumps(cert_dict))
|
||||
ignore_list.append(cert_dict)
|
||||
LOG.info(
|
||||
"Queue item for {0} was sent back to the "
|
||||
"queue because it wasn't marked as "
|
||||
"activated.".format(
|
||||
cert_dict.get("domain_name")
|
||||
)
|
||||
)
|
||||
except Exception as exc:
|
||||
try:
|
||||
akamai_driver.san_mapping_queue.\
|
||||
@ -93,7 +108,9 @@ class BackgroundJobController(base.BackgroundJobController):
|
||||
|
||||
return run_list, ignore_list
|
||||
elif job_type == "akamai_update_papi_property_for_mod_san":
|
||||
# this task will leave the san mapping queue intact
|
||||
# this task leaves the san mapping queue intact,
|
||||
# once items are successfully processed they are marked
|
||||
# ready for the next job type execution
|
||||
if 'akamai' in self._driver.providers:
|
||||
akamai_driver = self._driver.providers['akamai'].obj
|
||||
queue_data += akamai_driver.san_mapping_queue.traverse_queue()
|
||||
|
@ -33,7 +33,8 @@ def update_property_flow():
|
||||
flow = linear_flow.Flow('Update Akamai Property').add(
|
||||
update_property_tasks.PropertyGetLatestVersionTask(),
|
||||
update_property_tasks.PropertyUpdateTask(),
|
||||
update_property_tasks.PropertyActivateTask()
|
||||
update_property_tasks.PropertyActivateTask(),
|
||||
update_property_tasks.MarkQueueItemsWithActivatedProperty()
|
||||
)
|
||||
return flow
|
||||
|
||||
|
@ -309,3 +309,29 @@ class PropertyActivateTask(task.Task):
|
||||
|
||||
def revert(self, property_spec, new_version_number, **kwargs):
|
||||
LOG.info('retrying task: %s ...' % self.name)
|
||||
|
||||
|
||||
class MarkQueueItemsWithActivatedProperty(task.Task):
|
||||
|
||||
def __init__(self):
|
||||
super(MarkQueueItemsWithActivatedProperty, self).__init__()
|
||||
service_controller, self.providers = \
|
||||
memoized_controllers.task_controllers('poppy', 'providers')
|
||||
self.akamai_driver = self.providers['akamai'].obj
|
||||
|
||||
def execute(self, update_info_list):
|
||||
update_info_list = json.loads(update_info_list)
|
||||
|
||||
queue_data = self.akamai_driver.san_mapping_queue.traverse_queue()
|
||||
new_queue_data = []
|
||||
for cert in queue_data:
|
||||
cert_dict = json.loads(cert)
|
||||
|
||||
for action, update_cname_host_mapping_info in update_info_list:
|
||||
for host_info in update_cname_host_mapping_info:
|
||||
if host_info['cnameFrom'] == cert_dict['domain_name']:
|
||||
cert_dict['property_activated'] = True
|
||||
|
||||
new_queue_data.append(json.dumps(cert_dict))
|
||||
|
||||
self.akamai_driver.san_mapping_queue.put_queue_data(new_queue_data)
|
||||
|
@ -235,7 +235,8 @@ class DefaultSSLCertificateControllerTests(base.TestCase):
|
||||
"akamai_spsId": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'property_activated': True
|
||||
})
|
||||
]
|
||||
|
||||
@ -337,7 +338,8 @@ class DefaultSSLCertificateControllerTests(base.TestCase):
|
||||
"akamai_spsId": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'property_activated': True
|
||||
})
|
||||
]
|
||||
|
||||
|
@ -77,6 +77,8 @@ class MockManager(mock.Mock):
|
||||
akamai_mock_provider_obj.akamai_papi_api_base_url = (
|
||||
'https://mybaseurl.net/papi/v0/{middle_part}/'
|
||||
'?contractId=ctr_None&groupId=grp_None')
|
||||
akamai_mock_provider_obj.san_mapping_queue.\
|
||||
traverse_queue.return_value = []
|
||||
akamai_mock_provider.obj = akamai_mock_provider_obj
|
||||
providers = {
|
||||
'akamai': akamai_mock_provider,
|
||||
|
Loading…
x
Reference in New Issue
Block a user