-
Notifications
You must be signed in to change notification settings - Fork 332
FS-1467: Make conversation metadata APIs fault tolerant to federation errors #3229
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3a4940c
FS-1467: Updates to allow partial success and tests
lepsa 79f8ebb
Merge remote-tracking branch 'origin/develop' into FS-1467
lepsa fde2821
Merge remote-tracking branch 'origin/develop' into FS-1467
lepsa 70df213
FS-1467 Setting which conversation actions should be fault tolerant
lepsa aafcba0
FS-1467: Fixing tests for unavailable federator
lepsa 1796f66
FS-1467: Formatting and linting
lepsa 4e09baf
FS-1467: Adding changelog
lepsa 7b6ac1d
FS-1467: Swapping out a bool for a more descriptive type
lepsa 1d13864
FS-1467: Updates from PR comments
lepsa 0739e55
Empty commit, rerun CI
lepsa b2233d9
Another Hi, CI
ea5fbd5
HI CI
elland 0985a71
Hi CI now that ok-to-test is in place
5300181
Remove a debugging statement
56a08c5
Merge commit '3836eb0' into FS-1467
7ed327a
Hi CI
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Updating conversation meta-data APIs to be fault tolerant of unavailable federation servers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ module Galley.API.Action | |
| notifyConversationAction, | ||
| notifyRemoteConversationAction, | ||
| ConversationUpdate, | ||
| FederationFailEarly (..), | ||
| ) | ||
| where | ||
|
|
||
|
|
@@ -632,10 +633,16 @@ updateLocalConversationUnchecked lconv qusr con action = do | |
| (extraTargets, action') <- performAction tag qusr lconv action | ||
|
|
||
| notifyConversationAction | ||
| -- Removing members should be fault tolerant. | ||
| ( case tag of | ||
| SConversationRemoveMembersTag -> False | ||
| _ -> True | ||
| -- Removing members should be fault tolerant. | ||
| SConversationRemoveMembersTag -> FaultTolerant | ||
| -- Conversation metadata updates should be fault tolerant. | ||
| SConversationRenameTag -> FaultTolerant | ||
| SConversationMessageTimerUpdateTag -> FaultTolerant | ||
| SConversationReceiptModeUpdateTag -> FaultTolerant | ||
| SConversationAccessDataTag -> FaultTolerant | ||
| SConversationMemberUpdateTag -> FaultTolerant | ||
| _ -> FailEarly | ||
| ) | ||
| (sing @tag) | ||
| qusr | ||
|
|
@@ -689,6 +696,11 @@ addMembersToLocalConversation lcnv users role = do | |
| let action = ConversationJoin neUsers role | ||
| pure (bmFromMembers lmems rmems, action) | ||
|
|
||
| data FederationFailEarly | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌🏼 |
||
| = FailEarly | ||
| | FaultTolerant | ||
| deriving (Eq, Show) | ||
|
|
||
| notifyConversationAction :: | ||
| forall tag r. | ||
| ( Member FederatorAccess r, | ||
|
|
@@ -697,7 +709,7 @@ notifyConversationAction :: | |
| Member (Input UTCTime) r, | ||
| Member (Logger (Log.Msg -> Log.Msg)) r | ||
| ) => | ||
| Bool -> | ||
| FederationFailEarly -> | ||
| Sing tag -> | ||
| Qualified UserId -> | ||
| Bool -> | ||
|
|
@@ -769,7 +781,9 @@ notifyConversationAction failEarly tag quid notifyOrigDomain con lconv targets a | |
| "An error occurred while communicating with federated server: " | ||
| pure update | ||
|
|
||
| update <- if failEarly then errorIntolerant else errorTolerant | ||
| update <- case failEarly of | ||
| FailEarly -> errorIntolerant | ||
| FaultTolerant -> errorTolerant | ||
|
|
||
| -- notify local participants and bots | ||
| pushConversationEvent con e (qualifyAs lcnv (bmLocals targets)) (bmBots targets) | ||
|
|
@@ -856,7 +870,7 @@ kickMember qusr lconv targets victim = void . runError @NoChanges $ do | |
| lconv | ||
| () | ||
| notifyConversationAction | ||
| False | ||
| FaultTolerant | ||
| (sing @'ConversationRemoveMembersTag) | ||
| qusr | ||
| True | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Should've brought this up before, but I'm feeling a case of boolean blindness here. Could we use a more descriptive type? 🤞
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.
Fair enough, I've swapped it for a new type with better names.