Fix access list reminder notifications for access lists overdue by more than 8 days #52820
+10
−3
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.
Purpose
This PR resolves #52808
This PR fixes a flaky test, as well as a bug that would have prevented access lists due by more than 8 days from triggering a notification.
Context
While implementing the feature, I added a memory optimization that would only process access lists that fall between our notification thresholds (due in less than 14 days<->overdue by more than 7 days) to avoid keeping in memory and processing irrelevant access lists. However the way the latter limit was implemented (by excluding those overdue by more than 8 days) was incorrect since technically an access list could be created with a review due date more than 8 days ago, for which we would want a "overdue by more than 7 days" notification.
This bug is very unlikely to ever affect anyone in a real cluster, since for a real access list to be overdue by more than 8 days, it must have been overdue by 7 days first, and then 8 days, and thus have triggered the notification previously. The only way to trigger this bug is by initially creating the access list with a hardcoded due date value already more than 8 days in the past, which happens to be what we do in the unit test.
I suspect the flakiness came from timing issues when running the tests in CI, since the test access list was created with a due date of exactly 8 days ago, and the exclusion threshold is also 8 days and would therefore exclude it if time passed between the time the access list was created and the threshold check.