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

[MM-62410] Automatically cleanup stale calls in RTCD enabled deployments #940

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

streamer45
Copy link
Collaborator

Summary

PR adds logic to automatically clean up stale calls/sessions on plugin activation under RTCD-backed deployments. This is achieved by asking the RTCD side if the calls are still ongoing.

Related PR

mattermost/rtcd#166

Ticket Link

https://mattermost.atlassian.net/browse/MM-62410

@streamer45 streamer45 added the 2: Dev Review Requires review by a core committer label Jan 8, 2025
@streamer45 streamer45 added this to the v1.5.0 (MM v10.5) milestone Jan 8, 2025
@streamer45 streamer45 requested a review from cpoile January 8, 2025 16:16
@streamer45 streamer45 self-assigned this Jan 8, 2025
Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

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

Really nice, thanks!

Comment on lines +720 to +722
if err != nil {
m.ctx.LogDebug("failed to get version info", "err", err.Error(), "callID", call.ID, "rtcdHost", call.Props.RTCDHost)
return false
Copy link
Member

Choose a reason for hiding this comment

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

This defaults to call is still running if there's a problem getting the version info -- will that cause trouble? Should we return the err and have logic for it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A stuck call is strictly better than killing a live call, so unless we get a guarantee from the RTCD side that the call has ended, we err on the side of caution.


if code != http.StatusOK && code != http.StatusNotFound {
m.ctx.LogDebug("unexpected status code from RTCD", "code", code, "callID", call.ID, "rtcdHost", call.Props.RTCDHost)
// The request above could fail for various reasons, in which case we can't assume the call has ended.
Copy link
Member

Choose a reason for hiding this comment

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

ah, this confirms the default behavior. Maybe add this comment to the above as well? (would just save some cognitive overhead)

})
require.NoError(t, err)

mockAPI.On("LogDebug", "cleaning up calls state",
Copy link
Member

Choose a reason for hiding this comment

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

this must have been a pain to get exactly right, but I kind of like that the tests have the logs laid out like this -- you can see exactly what's supposed to happen. It's easy to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it takes some time, but it ensures the tests are solid, even in the presence of heavy mocking.

@cpoile cpoile added 3: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Jan 10, 2025
@streamer45 streamer45 merged commit 70efba8 into main Jan 13, 2025
21 checks passed
@streamer45 streamer45 deleted the MM-62410 branch January 13, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants