-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
fix: Presence broadcast isn't enabled after license validation #30282
fix: Presence broadcast isn't enabled after license validation #30282
Conversation
🦋 Changeset detectedLatest commit: 8d68ec5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report
@@ Coverage Diff @@
## develop #30282 +/- ##
===========================================
- Coverage 50.15% 49.97% -0.18%
===========================================
Files 781 773 -8
Lines 14520 14453 -67
Branches 2627 2613 -14
===========================================
- Hits 7282 7223 -59
+ Misses 6840 6821 -19
- Partials 398 409 +11
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -39,9 +39,13 @@ export class Presence extends ServiceClass implements IPresence { | |||
} | |||
}); | |||
|
|||
this.onEvent('license.module', ({ module, valid }) => { | |||
this.onEvent('license.module', async ({ module, valid }) => { |
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.
I believe this partially fixes the problem. Testing it locally, it looks like this event is not being received (even having a valid license). I'm unsure if this is the intended behavior or a problem with the onModule
function.
Also, if I'm not wrong, started()
method solves the problem. https://github.com/RocketChat/Rocket.Chat/blob/develop/ee/packages/presence/src/Presence.ts#L61
The only problem that could happen is, while started()
is executing AND before it fully finishes, we receive an event on the watch.instanceStatus
turning the setting to true again. What I'm trying to say is, the execution must be at this point when the started()
finishes.
I think @sampaiodiego opinion is really important here.
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.
I don't think this is the best solution either..
if the problem is really the method validateAvailability
being called before the start up procedure, we should actually make sure that doesn't happen by adding some kind of control like started = true
.. or maybe making like hasLicense = boolean | null
, so if it is still null
we ignore all events.
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.
I've just pushed a new commit following the second approach.
But I'm not really convinced this will fix the issue 🤔 for the case where the license takes too long to fetch, hasLicense()
will just return false
while it's not validated, right? then all these changes won't have any effect
As a way to make sure this is fixed and always synced, I was thinking of adding an else statement here to toggle the setting's value and make sure it's set to false
whenever the total amount of connections is below the max allowed. wdyt? (edit: pushed a new commit so it's less abstract)
cc @sampaiodiego @MarcosSpessatto
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.
Thought of another approach: here
It's basically calling toggleBroadcast
directly on new connections if the license is active and presence broadcast is disabled
ee/packages/presence/src/Presence.ts
Outdated
return; | ||
} | ||
|
||
if (this.getTotalConnections() > MAX_CONNECTIONS) { | ||
this.broadcastEnabled = false; | ||
|
||
await Settings.updateValueById('Presence_broadcast_disabled', true); | ||
} else { | ||
const presenceBroadcastDisabled = await Settings.findOneById('Troubleshoot_Disable_Presence_Broadcast'); |
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.
this looks expensive, doesn't it? potentially two trips for every new connection?
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.
Yeah, it did 😬
I've just had a better idea, I'm now checking the broadcastEnabled
property to make sure that presence broadcast is always enabled when there's a valid license (so we just do it once, not at every new connection).
ee/packages/presence/src/Presence.ts
Outdated
|
||
if (!this.broadcastEnabled && valid) { | ||
// broadcast should always be enabled if license is active (unless the troubleshoot setting is on) | ||
const presenceBroadcastDisabled = await Settings.findOneById('Troubleshoot_Disable_Presence_Broadcast'); |
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.
checking this setting is not wrong, but it is not a concern of this package..
we need to create an alternate mechanism to properly respect this setting, as it is already being "ignored" in other places.
Co-authored-by: Diego Sampaio <chinello@gmail.com>
Co-authored-by: Diego Sampaio <chinello@gmail.com>
…ove/iframeLogin * 'develop' of github.com:RocketChat/Rocket.Chat: (29 commits) fix: Disables `GenericMenu` without any sections or items (#30319) i18n: Language update from LingoHub 🤖 on 2023-09-18Z (#30426) chore: remove connectToCloud option (#30430) chore: remove Troubleshoot options (#30429) chore: bump fuselage packages (#30424) chore: Webhooks page refactor (#30274) chore: color palette changes (#30385) fix: increase cron job check delay to 1 min (#30402) fix: Presence broadcast isn't enabled after license validation (#30282) test: create non private team and readonly team (#30371) Bump version to 6.5.0-develop refactor: Implement functional code for the 'useFilteredApps' hook (#30279) Release 6.4.0-rc.1 Release 6.3.6 regression: Login page callout messages (#30399) test: tests for muting and unmuting (#30286) regression: Fix rooms table not showing teams (#30361) regression: Move queue-timeout setting to CE and remove dependency on waiting queue (#30386) fix: engagement dashboard not working (#30277) Bump 6.3.6 ...
@matheusbsilva137 @sampaiodiego Please backport this change to the 6.3 and 6.4 branches as well, because - frankly - this is a pain and happens occasionally without any (intended) change on a running installation, like restarting a service. (ping @ankar84 ) |
Ok, seems like it is included in the 6.3.7 changelog as well. 👍 |
Co-authored-by: Diego Sampaio <chinello@gmail.com>
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Context: we received multiple reports from customers saying that presence broadcast has been disabled when starting the server. This could be caused by some sort of race condition between the
license.module
andwatch.instanceStatus
events (for the presence feature). IfvalidateAvailability
runs before the license is validated, then presence broadcast will be disabled for this workspace (that is, thePresence_broadcast_disabled
setting will be enabled) and won't be enabled anytime later.The issue could be solved by disabling the
Presence_broadcast_disabled
setting directly in the DB. This fix should avoid such cases.SUP-308