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

Improve Directory Group lookup error handling #339

Closed
wants to merge 7 commits into from

Conversation

ghsolomon
Copy link
Contributor

No description provided.

@ghsolomon ghsolomon requested review from lbwexler and amcclain March 20, 2024 16:36
logError(errMsg, e)
return directoryGroups.collectEntries {[it, errMsg] }
}
!directoryGroups ? emptyMap() : doLoadUsersForDirectoryGroups(directoryGroups)
Copy link
Member

Choose a reason for hiding this comment

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

perhaps inline the "do" method -- one less method to trace through

try {
Map<String, Object> groupsLookup = defaultRoleService.loadUsersForDirectoryGroups(groups)
usersForGroups = groupsLookup.findAll { it.value instanceof Set }
errorsForGroups = groupsLookup.findAll { !(it.value instanceof Set) }
Copy link
Member

Choose a reason for hiding this comment

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

To confirm - we might still get errorsForGroups populated as expected with partial lookup failures, but now only in the case of 'No AD group found' - is that correct?

Checking that a search returnign no result does not throw- that would be reasonable but didn't want to assume.

(Would suggest changing to "Directory Group not found" FWIW)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct - will double-check this now to make sure. And sounds good re: change to error text

Copy link
Contributor Author

@ghsolomon ghsolomon Apr 2, 2024

Choose a reason for hiding this comment

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

Confirmed! Built a snapshot from this branch and tested in a client app to confirm.

}
_usersForDirectoryGroups = usersForDirectoryGroups
} catch (Throwable e) {
logError("Error resolving users for directory groups", e)
Copy link
Member

Choose a reason for hiding this comment

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

Worth a comment to clarify that leaving the previous _usersForDirectoryGroups in place (and then re-processing it below) is a deliberate choice?

@lbwexler
Copy link
Member

lbwexler commented Apr 2, 2024

Trying to think big picture here and wanted to get this out here. In particular, don't want to trade one set of problems for another.

What motivated this change was the concern that we are making a large number of individual LDAP queries to get groups right now. If any one of them fails (e.g. timeout, or just flaky) we can basically "blip out" user access for all of the users in the group that failed. And we may be just doing our 10 minute refresh, replacing a perfectly good result with a flaky result -- and that seemed wrong. So this should fix that.

New concern -- now a single flaky call keeps us from ever getting needed roles in the app. Or worse yet, someone enters something as a new or modified group tag that somehow causes all role groups to fail to load.

Maybe its overkill, but we could pass a flag to indicate whether we wanted "strict mode" or whether we are happy to have whatever results we can get? The latter could be useful when we start-up, or for whatever reason have no successful load of groups.

@lbwexler
Copy link
Member

lbwexler commented Apr 3, 2024

Created a new branch here to incorporate my thoughts above. Greg reveiwed and testing out now

@lbwexler lbwexler closed this Apr 3, 2024
@lbwexler lbwexler deleted the directoryGroupErrorHandling branch April 3, 2024 19:45
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.

3 participants