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

Multi tenancy iq handlers #3118

Merged
merged 13 commits into from
May 19, 2021
Merged

Multi tenancy iq handlers #3118

merged 13 commits into from
May 19, 2021

Conversation

DenysGonchar
Copy link
Collaborator

@DenysGonchar DenysGonchar commented May 14, 2021

this PR introduces iq handling for dynamic domains. here is the list of all changes:

  • introduction of mongoose_iq_handlers
  • enforcing map as type of packet_handler's extra field and extending it with host_type for dynamic domains
  • introducing mongoose_lazy_routing module that controls dynamic domains/subdomains routing and iq handlers registration.
  • splitting gen_iq_handler into 3 different modules:
    • iq handler registration API
    • iq component behaviour
    • iq handlers' workers
  • introducing demo module

TODO: introduce unit testing for mongoose_lazy_routing module

@codecov
Copy link

codecov bot commented May 14, 2021

Codecov Report

Merging #3118 (ca2fcc6) into master (8c597bc) will increase coverage by 0.01%.
The diff coverage is 74.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3118      +/-   ##
==========================================
+ Coverage   79.22%   79.24%   +0.01%     
==========================================
  Files         389      394       +5     
  Lines       31959    32139     +180     
==========================================
+ Hits        25321    25467     +146     
- Misses       6638     6672      +34     
Impacted Files Coverage Δ
src/ejabberd_sup.erl 85.71% <ø> (ø)
src/mod_dynamic_domains_test.erl 0.00% <0.00%> (ø)
src/mod_vcard.erl 76.95% <ø> (ø)
src/mongoose_hooks.erl 92.85% <ø> (+0.54%) ⬆️
src/muc_light/mod_muc_light.erl 84.54% <ø> (ø)
src/mongoose_iq_handler.erl 61.11% <61.11%> (ø)
src/mod_muc_iq.erl 60.00% <62.50%> (-5.00%) ⬇️
src/mongoose_iq_worker.erl 72.72% <72.72%> (ø)
src/gen_iq_handler.erl 73.91% <77.27%> (+16.13%) ⬆️
src/ejabberd_sm.erl 83.61% <80.00%> (+0.90%) ⬆️
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c597bc...ca2fcc6. Read the comment docs.

@DenysGonchar DenysGonchar force-pushed the multi-tenancy-iq_handlers branch 2 times, most recently from 57fc23a to bdc1bc2 Compare May 17, 2021 13:04
Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

added some style comments, but good

big_tests/tests/dynamic_domains_pm_SUITE.erl Outdated Show resolved Hide resolved
big_tests/tests/dynamic_domains_pm_SUITE.erl Outdated Show resolved Hide resolved
src/ejabberd_local.erl Show resolved Hide resolved
src/gen_iq_handler.erl Show resolved Hide resolved
Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

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

Looks good and quite complicated at the same time... There are some gen_servers introduced, which can always become bottlenecks. Please double-check that all the calls really need to be synchronized this way.

Comment on lines +64 to +65
%% KV pairs from the OldExtra map will remain unchanged, only
%% the new keys from Extra map will be added to the NewExtra map
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
%% KV pairs from the OldExtra map will remain unchanged, only
%% the new keys from Extra map will be added to the NewExtra map
%% KV pairs from the OldExtra map will remain unchanged,
%% only the new keys from Extra map will be added to the NewExtra map

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I find it much more readable when all the lines of the block comment have more or less the same length.

Copy link
Member

@chrzaszcz chrzaszcz May 19, 2021

Choose a reason for hiding this comment

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

I am trying to follow the ideas in https://sembr.org/ which really help with reading the comments. It's mostly for markup languages, but it helps me a lot with comments. I don't see a benefit of that stray "only" at the end of the sentence as it can be interpreted differently without seeing the next line (as an adverb instead of a conjunction).

src/mongoose_packet_handler.erl Outdated Show resolved Hide resolved
src/mod_muc_iq.erl Outdated Show resolved Hide resolved
src/domain/mongoose_subdomain_core.erl Show resolved Hide resolved
src/gen_iq_component.erl Show resolved Hide resolved
src/mongoose_router_dynamic_domains.erl Show resolved Hide resolved
src/domain/mongoose_lazy_routing.erl Show resolved Hide resolved
ejabberd_local:register_host(Domain),
ok;
false ->
%% we should never get here, but it's ok to just ignore this.
Copy link
Member

Choose a reason for hiding this comment

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

So if this gets called multiple times (because of a bug), we would silently ignore this fact.

@@ -69,6 +74,59 @@ auth_domain_removal_is_triggered_on_hook(_Config) ->
1 = rpc(mim(), meck, num_calls, [ejabberd_auth_dummy, remove_domain, Params]),
rpc(mim(), meck, unload, [ejabberd_auth_dummy]).

test_routing(Config) ->
Copy link
Member

Choose a reason for hiding this comment

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

Please split into 3 test cases.

big_tests/tests/dynamic_domains_pm_SUITE.erl Outdated Show resolved Hide resolved
@NelsonVides
Copy link
Collaborator

I've seen that ejabberd_local has now its ets table as protected, why can't we do the same for ejabberd_sm' ets table? 🤔

@DenysGonchar
Copy link
Collaborator Author

I've seen that ejabberd_local has now its ets table as protected, why can't we do the same for ejabberd_sm' ets table? 🤔

it is protected. see http://erlang.org/doc/man/ets.html#new-2 :

protected

    The owner process can read and write to the table. Other processes can only read the table. This is the default setting for the access rights.

@NelsonVides
Copy link
Collaborator

I've seen that ejabberd_local has now its ets table as protected, why can't we do the same for ejabberd_sm' ets table? 🤔

it is protected. see http://erlang.org/doc/man/ets.html#new-2 :

protected

    The owner process can read and write to the table. Other processes can only read the table. This is the default setting for the access rights.

Ah, protected is the default, I see, thanks!

Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

k

@arcusfelis arcusfelis merged commit eae2da0 into master May 19, 2021
@arcusfelis arcusfelis deleted the multi-tenancy-iq_handlers branch May 19, 2021 19:16
@Premwoik Premwoik added this to the 5.0.0 milestone Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants