-
Notifications
You must be signed in to change notification settings - Fork 10
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
sync_repos: allow private repo permissions to be set on error #478
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. @@ Coverage Diff @@
## main #478 +/- ##
=======================================
Coverage 97.26% 97.26%
=======================================
Files 412 412
Lines 34122 34114 -8
=======================================
- Hits 33189 33182 -7
+ Misses 933 932 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. @@ Coverage Diff @@
## main #478 +/- ##
=======================================
Coverage 97.26% 97.26%
=======================================
Files 412 412
Lines 34122 34114 -8
=======================================
- Hits 33189 33182 -7
+ Misses 933 932 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found @@ Coverage Diff @@
## main #478 +/- ##
=======================================
Coverage 97.26% 97.26%
=======================================
Files 412 412
Lines 34122 34114 -8
=======================================
- Hits 33189 33182 -7
+ Misses 933 932 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #478 +/- ##
=======================================
Coverage 97.29% 97.29%
=======================================
Files 443 443
Lines 34851 34843 -8
=======================================
- Hits 33908 33901 -7
+ Misses 943 942 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
number_old_permissions=len(old_permissions), | ||
number_new_permissions=len(set(private_project_ids)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goated log ngl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
codecov/engineering-team#1757
in most tasks, all db writes occur in a transaction and if an uncaught error occurs we roll the transaction back. for sync_repos, if a user syncs 999/1000 repos and then encounters an error, we actually don't want to roll everything back.
sync_repos
already commits after each repo insert so the repo data won't be thrown away. however, what we don't do is update the list of private repos that the syncing user can see. so if they sync 999 new private repos and then get a 502, the 999 repos will be in our database but we won't let the user view any of them. this PR changes thatthe old behavior, when catching a worker task timeout or
TorngitClientError
, would clear the private repo permission list entirely to avoid the possibility of leaving the user with permission they shouldn't have. that was stricter than necessary though; theprivate_project_ids
list may be incomplete if an error occurs before we've processed every repo but the things it does have are definitely visible to the user. so it's fine to setowner.permission = private_project_ids
.the old behavior did not catch
TorngitServerFailureError
and if such an error occurred (as it would if github returns a 504) no changes would be made to the private repo permission list. no new repos will be added, and if access to a private repo was supposed to have been revoked, the user will still be able to see it in codecov.the new behavior handles timeouts,
TorngitClientError
s, andTorngitServerFailureError
s the same way: log the error, mention that the private repo permission list may be incomplete, and then setowner.permission
and complete the task normally. the way this appears to the user:TorngitClientError
(e.g. rate limit, token flukes) will no longer have the list of private repos they can see totally wiped. the list may be incomplete, but it will no longer be emptyTorngitServerFailureError
(e.g. github 504) will not be left with an empty list of private repos. they will be able to see any repos that successfully syncedTorngitServerFailureError
(e.g. github 504) will have their permission list updated to a new, possibly incomplete list. some repos may be added, some repos may "disappear". repos that should not be in the list will no longer be in the list