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

Support dynamic domains in mod_offline #3164

Merged
merged 14 commits into from
Jul 12, 2021
Merged

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Jun 30, 2021

Main changes:

  • Support host types in mod_offline and its backends.
  • Enable offline-related tests for dynamic domains.
  • Change module templating to make the template and the resulting config readable at the same time. There are some whitespace manipulations, but they don't change the functionality. This can be still improved, I have ideas (e.g. mustache lists), but it would be a separate story. Right now the resulting config file always has a single empty line separating module sections. All module templates should be unified in the near future.

Side changes:

  • Unify the implementation of remove_*_messages to only remove messages for the domain that was provided. The backends were behaving inconsistently before (it worked as expected only for Riak).

Not included in this PR:

  • DB Query optimization with indexes. It does not seem to be required now, but message removal per domain could be sped up by using indexes.
  • Support for dynamic domains in mod_offline_chatmarkers. This is an undocumented module which is disabled by default.
  • Better error handling in backends. Sometimes DB errors can be missed and ok is returned. I didn't want to change too much and these issues don't seem to be critical. It's a bit out of scope as well.

@codecov
Copy link

codecov bot commented Jun 30, 2021

Codecov Report

Merging #3164 (1c27669) into master (f8218b2) will increase coverage by 2.78%.
The diff coverage is 90.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3164      +/-   ##
==========================================
+ Coverage   77.41%   80.20%   +2.78%     
==========================================
  Files         396      396              
  Lines       32306    32316      +10     
==========================================
+ Hits        25010    25918     +908     
+ Misses       7296     6398     -898     
Impacted Files Coverage Δ
src/offline/mod_offline_mnesia.erl 50.70% <55.55%> (-0.77%) ⬇️
src/ejabberd_admin.erl 59.06% <60.00%> (-0.18%) ⬇️
src/offline/mod_offline.erl 77.90% <97.43%> (+0.12%) ⬆️
src/ejabberd_c2s.erl 89.20% <100.00%> (+0.14%) ⬆️
src/mongoose_hooks.erl 94.93% <100.00%> (+0.03%) ⬆️
src/offline/mod_offline_rdbms.erl 93.93% <100.00%> (+0.09%) ⬆️
src/offline/mod_offline_riak.erl 90.66% <100.00%> (ø)
src/mod_roster_riak.erl 81.53% <0.00%> (-15.39%) ⬇️
src/muc_light/mod_muc_light_utils.erl 90.00% <0.00%> (-1.00%) ⬇️
src/muc_light/mod_muc_light.erl 85.13% <0.00%> (-0.75%) ⬇️
... and 18 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 f8218b2...1c27669. Read the comment docs.

@chrzaszcz chrzaszcz force-pushed the offline-with-dynamic-domains branch 4 times, most recently from 1af8fec to 6de2566 Compare July 2, 2021 12:25
Update the backend callbacks.
The tests will not pass until the backend modules are also updated.

Also: clean up comments and type specs.
- Add type specs to callbacks
- Let the remove_*_messages functions remove only the messages
  for the provided LServer, not for all domains.
  This is done in a simple way, it can be optimized later if needed.
- Add type specs to callbacks
- Let the remove_*_messages functions remove only the messages
  for the provided LServer, not for all domains.
  This is done in a simple way, it can be optimized later if needed.
Enable it conditionally in the config template.

Also:
  - Rearrange newlines to make both the templates and the resulting files
    more readable.
    The only inconsitency is the indentation in case of multiple
    options.
    It's a corner case not occuring atm and it will not affect
    the default config visible to the end user - only the dev config
    for mim1.
    There will be a PR in the future which will unify the templating
    for all modules.

  - Do not set options with values same as the default ones.
Also:
  - Add specs
  - Simplify calling resend_offline_messages_hook
@chrzaszcz chrzaszcz force-pushed the offline-with-dynamic-domains branch from 129ed2a to aad2505 Compare July 2, 2021 13:18
@chrzaszcz chrzaszcz marked this pull request as draft July 2, 2021 13:59
@chrzaszcz chrzaszcz marked this pull request as ready for review July 2, 2021 13:59
@chrzaszcz chrzaszcz self-assigned this Jul 2, 2021
Comment on lines +224 to +226
{{#mod_cache_users}}
[modules.mod_cache_users]
{{{mod_cache_users}}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This disables this module in the prod config.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is only a whitespace change, it cannot disable anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was disabled before and remains unchanged. Let's change this in a separate PR.

src/ejabberd_admin.erl Outdated Show resolved Hide resolved
src/ejabberd_admin.erl Outdated Show resolved Hide resolved
Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

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

LGTM

@NelsonVides NelsonVides merged commit de27b3f into master Jul 12, 2021
@NelsonVides NelsonVides deleted the offline-with-dynamic-domains branch July 12, 2021 07:57
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.

ok

@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants