Skip to content

Commit

Permalink
fix(conflict-handling): on succesfully handled conflict (e.g. already… (
Browse files Browse the repository at this point in the history
#50)

* fix(conflict-handling): on succesfully handled conflict (e.g. already exists) make sure to return the actual member

* fix(comments): fix comments for conflict handling
  • Loading branch information
Avantol13 authored Dec 18, 2018
1 parent 9eb5b61 commit 8a9a46b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cirrus/google_cloud/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,18 +1167,18 @@ def add_member_to_group(self, member_email, group_id):
return member_to_add
else:
# Google's API erroneously returns 400 sometimes
# we check to see if the SA was actually deleted
# we check to see if the SA was actually added
logger.warning(
"When adding {} to group ({}), Google API "
"returned status {}".format(member_email, group_id, err.resp.status)
)
if not self._is_member_in_group(member_email, group_id):
raise

return {}
return member_to_add
except Exception as exc:
# Google's API erroneously returns 400 sometimes
# we check to see if the SA was actually deleted
# Google's API erroneously returns error sometimes
# we check to see if the SA was actually added
logger.warning(
"When adding {} to group ({}), Exception was raised: {}".format(
member_email, group_id, exc
Expand All @@ -1187,7 +1187,7 @@ def add_member_to_group(self, member_email, group_id):
if not self._is_member_in_group(member_email, group_id):
raise

return {}
return member_to_add

def _is_member_in_group(self, member_email, group_id):
member_emails = [
Expand Down

0 comments on commit 8a9a46b

Please sign in to comment.