Skip to content

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

Merged
katallaxie merged 1 commit into
awslabs:masterfrom
netrix-emea:bugfix-deleted-user
Aug 3, 2020
Merged

fix: Sync Users loop stops when there is a deleted user#11
katallaxie merged 1 commit into
awslabs:masterfrom
netrix-emea:bugfix-deleted-user

Conversation

@jverhoeks
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread internal/sync.go

uu, err := s.aws.FindUserByEmail(u.PrimaryEmail)
if err != aws.ErrUserNotFound {
if err != aws.ErrUserNotFound && err != nil {
Copy link
Copy Markdown
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
Copy Markdown
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 = [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

@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