Skip to content

Commit

Permalink
chore(google-manage-keys): Handle key deletion with FAILED_PRECONDITION
Browse files Browse the repository at this point in the history
  • Loading branch information
themarcelor committed Jan 22, 2021
1 parent a60cf4e commit b07e614
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fence/scripting/fence_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def remove_expired_google_service_account_keys(db):
account=sa.email, key_name=expired_user_key.key_id
)
response_error_code = response.get("error", {}).get("code")
response_error_status = response.get("error", {}).get("status")

if not response_error_code:
current_session.delete(expired_user_key)
Expand All @@ -564,7 +565,10 @@ def remove_expired_google_service_account_keys(db):
expired_user_key.key_id, sa.email, sa.user_id
)
)
elif response_error_code == 404:
elif (
response_error_code == 404
or response_error_status == "FAILED_PRECONDITION"
):
logger.info(
"INFO: Service account key {} for service account {} "
"(owned by user with id {}) does not exist in Google. "
Expand Down

0 comments on commit b07e614

Please sign in to comment.