From fc3973a83b9d658fba5ef9f645f5816a594d4586 Mon Sep 17 00:00:00 2001 From: Kwaizer Date: Mon, 14 Aug 2023 17:57:26 +0300 Subject: [PATCH] Clients: Intoduced new constraint #6091 --- lib/rucio/web/rest/flaskapi/v1/dids.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/rucio/web/rest/flaskapi/v1/dids.py b/lib/rucio/web/rest/flaskapi/v1/dids.py index a16a5c6199..3ed8ecf4fd 100644 --- a/lib/rucio/web/rest/flaskapi/v1/dids.py +++ b/lib/rucio/web/rest/flaskapi/v1/dids.py @@ -24,7 +24,7 @@ resurrect, get_users_following_did, remove_did_from_followed, add_did_to_followed, delete_metadata, \ set_metadata_bulk, set_dids_metadata_bulk from rucio.api.rule import list_replication_rules, list_associated_replication_rules_for_file -from rucio.common.exception import ScopeNotFound, DataIdentifierNotFound, DataIdentifierAlreadyExists, \ +from rucio.common.exception import ScopeNotFound, DatabaseException, DataIdentifierNotFound, DataIdentifierAlreadyExists, \ DuplicateContent, AccessDenied, KeyNotFound, Duplicate, InvalidValueForKey, UnsupportedStatus, \ UnsupportedOperation, RSENotFound, RuleNotFound, InvalidMetadata, InvalidPath, FileAlreadyExists, InvalidObject, FileConsistencyMismatch from rucio.common.utils import render_json, APIEncoder @@ -655,6 +655,15 @@ def post(self, scope_name): return generate_http_error_flask(409, error) except AccessDenied as error: return generate_http_error_flask(401, error) + except DatabaseException as error: + if 'DELETED_DIDS_PK violated' in str(error): + return generate_http_error_flask( + status_code=406, + exc=error.__class__.__name__, + exc_msg=str('A deleted DID {} with scope {} is reused'.format(name, scope)) + ) + else: + return generate_http_error_flask(406, error) return 'Created', 201