fix: Sync Users loop stops when there is a deleted user#11
Merged
Conversation
katallaxie
reviewed
Aug 3, 2020
Contributor
katallaxie
left a comment
There was a problem hiding this comment.
Left a minor comment.
|
|
||
| uu, err := s.aws.FindUserByEmail(u.PrimaryEmail) | ||
| if err != aws.ErrUserNotFound { | ||
| if err != aws.ErrUserNotFound && err != nil { |
Contributor
There was a problem hiding this comment.
Let's make this simpler. if uu == nil { return err }. it should always be nil when there is and error.
Contributor
Author
There was a problem hiding this comment.
I think not.
For the following use-case
deleted_users = [userA@domain.com, userB@domain.com]
where UserA is doesn't exist but userB yes on SSO
FinduserByEmail (userA)
- err = aws.ErrUserNotFound
- uu = nil
action -> continue
go to the next user in the list
FinduserByEmail (userB)
- err = nil
- uu = object
action
-> DeleteUser
go to the next user in the list
if uu == nil and the error is different , then the function should break the whole loop and return err as there is an unexpected errror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
*Issue #10
Description of changes:
When there are deleted users in Gsuite that are previous synced to AWS SSO the logic stops the whole syncUsers loop
The current loop is:
However aws.FindUserByEmail
return aws.ErrUserNotFound when a user is not found and nil when a user is found.
Replaced with:
and added extra logging around deleting users.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.