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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: more straightforward log for force_shutdown reason #10354

Merged
merged 2 commits into from Apr 14, 2023

Conversation

zhongwencool
Copy link
Member

@zhongwencool zhongwencool commented Apr 10, 2023

Fixes EMQX-9497

2023-04-10T08:58:32.713601+08:00 [error] failed_to_check_schema: emqx_conf_schema
2023-04-10T08:58:32.717076+08:00 [error] #{kind => validation_error,path => "force_shutdown.max_heap_size",reason => #{exception => 
{error,[102,111,114,99,101,95,115,104,117,116,100,111,119,110,95,112,111,108,105,99,121,58,32,104,101,97,112,45,115,105,122,101,32,"32M",32,105,115,32,116,111,111,32,108,97,114,103,101]},
stacktrace => [{emqx_schema,validate_heap_size,1,[{file,"emqx_schema.erl"},{line,2658}]},{hocon_tconf,do_validate,4,[{file,"hocon_tconf.erl"},{line,1134}]},{hocon_tconf,map_field,4,[{file,"hocon_tconf.erl"},
{line,653}]},{hocon_tconf,map_one_field_non_hidden,4,[{file,"hocon_tconf.erl"},{line,492}]},{hocon_tconf,map_fields_cont,4,[{file,"hocon_tconf.erl"},{line,431}]},{hocon_tconf,map_one_field_non_hidden,4,[{file,"hocon_tconf.erl"},{line,492}]},{hocon_tconf,map_fields_cont,4,[{file,"hocon_tconf.erl"},{line,431}]},{hocon_tconf,map,4,[{file,"hocon_tconf.erl"},{line,301}]}]},value => "32M"}

after:

too large value

force_shutdown.max_heap_size="1000000000000GB"

2023-04-10T11:09:41.776605+08:00 [error] failed_to_check_schema: emqx_conf_schema
2023-04-10T11:09:41.781234+08:00 [error] #{kind => validation_error,path => "force_shutdown.max_heap_size",
reason => #{maximum => 576460752303423487,reason => max_heap_size_too_large},
value => 134217728000000000000}

Bad value 10M, Missing a B, should be 10MB

force_shutdown.max_heap_size="10M"

2023-04-10T11:10:37.129884+08:00 [error] failed_to_check_schema: emqx_conf_schema
2023-04-10T11:10:37.133536+08:00 [error] #{kind => validation_error,path => "force_shutdown.max_heap_size",
reason => invalid_heap_size,value => "10M"}

Summary

馃 Generated by Copilot at e1e3f77

Refactor the force shutdown policy feature to improve error handling and logging. Change the shutdown reason format to a map with more information, move the validate_heap_size function to emqx_misc and update the test case for check_oom.

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

Copy link
Member

@HJianBo HJianBo left a comment

Choose a reason for hiding this comment

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

LGTM

@zhongwencool zhongwencool merged commit 1e07f37 into emqx:master Apr 14, 2023
107 checks passed
@zhongwencool zhongwencool deleted the straightforward-log-info branch April 14, 2023 02:15
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 4689274156

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 100 unchanged lines in 18 files lost coverage.
  • Overall coverage increased (+0.04%) to 81.12%

Files with Coverage Reduction New Missed Lines %
apps/emqx_auto_subscribe/src/emqx_auto_subscribe_schema.erl 1 87.5%
apps/emqx_bridge/src/emqx_bridge.erl 1 91.2%
apps/emqx_management/src/emqx_mgmt_util.erl 1 13.79%
apps/emqx/src/emqx_connection.erl 1 87.96%
apps/emqx/src/emqx_channel.erl 2 87.33%
apps/emqx/src/emqx_cm.erl 2 90.99%
apps/emqx/src/emqx_crl_cache.erl 2 92.31%
apps/emqx/src/emqx_stats.erl 2 91.67%
apps/emqx_dashboard/src/emqx_dashboard_swagger.erl 3 96.25%
apps/emqx_exproto/src/emqx_exproto_gcli.erl 3 48.78%
Totals Coverage Status
Change from base Build 4642703850: 0.04%
Covered Lines: 25315
Relevant Lines: 31207

馃挍 - Coveralls

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