Skip to content

Commit fbf5656

Browse files
committed
fix: delete only executions if existed
1 parent 8f706be commit fbf5656

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cumulus_lambda_functions/cumulus_wrapper/query_collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ def list_executions(self, new_collection: dict, private_api_prefix: str):
254254
return {'client_error': query_result}
255255
query_result = json.loads(query_result['body'])
256256
LOGGER.debug(f'json query_result: {query_result}')
257-
if 'id' not in query_result:
257+
if 'results' not in query_result:
258258
return {'server_error': f'invalid response: {query_result}'}
259259
except Exception as e:
260260
LOGGER.exception('error while invoking')
261261
return {'server_error': f'error while invoking:{str(e)}'}
262-
return {'status': query_result}
262+
return {'results': query_result['results']}
263263

264264
def create_sqs_rules(self, new_collection: dict, private_api_prefix: str, sqs_url: str, provider_name: str = '', workflow_name: str = 'CatalogGranule', visibility_timeout: int = 1800):
265265
"""

cumulus_lambda_functions/uds_api/dapa/collections_dapa_creation.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,23 @@ def delete(self):
146146
creation_result = 'NA'
147147

148148
if self.__include_cumulus:
149-
result = self.__cumulus_collection_query.delete_executions(cumulus_collection_doc, self.__cumulus_lambda_prefix)
150-
print(f'execution list result: {result}')
151-
self.__delete_collection_execution(cumulus_collection_doc, deletion_result)
149+
result = self.__cumulus_collection_query.list_executions(cumulus_collection_doc, self.__cumulus_lambda_prefix)
150+
LOGGER.debug(f'execution list result: {result}')
151+
if len(result['results']) > 0:
152+
self.__delete_collection_execution(cumulus_collection_doc, deletion_result)
153+
return {
154+
'statusCode': 409,
155+
'body': {
156+
'message': f'There are cumulus executions for this collection. Deleting them. Pls try again in a few minutes.',
157+
}
158+
}
159+
# self.__delete_collection_execution(cumulus_collection_doc, deletion_result)
152160
self.__delete_collection_rule(cumulus_collection_doc, deletion_result)
153161
delete_result = self.__cumulus_collection_query.delete_collection(self.__cumulus_lambda_prefix, cumulus_collection_doc['name'], cumulus_collection_doc['version'])
154162
delete_err, delete_result = self.analyze_cumulus_result(delete_result)
155163
if delete_err is not None:
156164
LOGGER.error(f'deleting collection ends in error. Trying again. {delete_err}')
157-
self.__delete_collection_execution(cumulus_collection_doc, deletion_result)
165+
# self.__delete_collection_execution(cumulus_collection_doc, deletion_result)
158166
self.__delete_collection_rule(cumulus_collection_doc, deletion_result)
159167
delete_result = self.__cumulus_collection_query.delete_collection(self.__cumulus_lambda_prefix, cumulus_collection_doc['name'], cumulus_collection_doc['version'])
160168
delete_err, delete_result = self.analyze_cumulus_result(delete_result)

0 commit comments

Comments
 (0)