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

EMQX-10590 data import fix missing config relealse 51 #11322

Conversation

SergeTupchiy
Copy link
Contributor

@SergeTupchiy SergeTupchiy commented Jul 21, 2023

Fixes EMQX-10590

This is the same as #11296, but ported to release-51.

Summary

🤖 Generated by Copilot at 6a6413b

This pull request adds support for importing backup data for the emqx_modules application, especially the topic_metrics and slow_subs configurations. It also fixes a typo in the emqx_rule_engine module and updates the version number and test cases for the emqx_modules application. The changes are documented in the changes/ce/fix-11296.en.md file.

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • If there should be document changes, a PR to emqx-docs.git is sent, or a jira ticket is created to follow up
  • Schema changes are backward compatible

Checklist for CI (.github/workflows) changes

  • If changed package build workflow, pass this action (manual trigger)
  • Change log has been added to changes/ dir for user-facing artifacts update

The type resulted in missing `rule_engine` config after importing data from a backup file.

Fixes: EMQX-10590
@SergeTupchiy SergeTupchiy force-pushed the EMQX-10590-data-import-fix-missing-config-rel51 branch from 6a6413b to b37920d Compare July 21, 2023 07:42
lafirest
lafirest previously approved these changes Jul 21, 2023
Comment on lines 164 to 175
post_config_update(_, _UpdateReq, NewConfig, OldConfig, _AppEnvs) ->
#{
removed := Removed,
added := Added
} = emqx_utils:diff_lists(NewConfig, OldConfig, fun(#{topic := T}) -> T end),
Deregistered = [emqx_topic_metrics:deregister(T) || #{topic := T} <- Removed],
Registered = [emqx_topic_metrics:register(T) || #{topic := T} <- Added],
Errs = [Res || Res <- Registered ++ Deregistered, Res =/= ok],
case Errs of
[] -> ok;
_ -> {error, Errs}
end.
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch, I can't believe I don't implment config_handler's callback for topic_metrics before.
Nit:
deregister will return ok or topic_not_found, we should mark topic_not_found as deregister success.
register will return ok or already_existed, maybe already_existed is also register success.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @zhongwencool, fixed.

@SergeTupchiy SergeTupchiy merged commit 04bd7c7 into emqx:release-51 Jul 21, 2023
112 of 115 checks passed
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

3 participants