Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sync Users loop stops when there is a deleted user #11

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

jverhoeks
Copy link
Contributor

*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:

uu, err := s.aws.FindUserByEmail(u.PrimaryEmail)
if err != aws.ErrUserNotFound  {

However aws.FindUserByEmail
return aws.ErrUserNotFound when a user is not found and nil when a user is found.

Replaced with:

if err != aws.ErrUserNotFound && err != nil {

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.

@jverhoeks jverhoeks changed the title Bugfix: Sync Users loop stops when there is a deleted user fix: Sync Users loop stops when there is a deleted user Aug 3, 2020
Copy link
Contributor

@katallaxie katallaxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment.

uu, err := s.aws.FindUserByEmail(u.PrimaryEmail)
if err != aws.ErrUserNotFound {
if err != aws.ErrUserNotFound && err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this simpler. if uu == nil { return err }. it should always be nil when there is and error.

Copy link
Contributor Author

@jverhoeks jverhoeks Aug 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not.
For the following use-case
deleted_users = [[email protected], [email protected]]
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

@katallaxie katallaxie merged commit 91f3ceb into awslabs:master Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants