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: change mqtt.max_packet_size type from string to bytesize #11438

Merged
merged 3 commits into from Aug 14, 2023

Conversation

zhongwencool
Copy link
Member

@zhongwencool zhongwencool commented Aug 14, 2023

Fixes EMQX-10587

It鈥檚 more friendly to Frontend to design the range validation.
Before:
image

After:
image

image

Summary

馃 Generated by Copilot at b2e687d

This pull request refactors the schema validation of the max_packet_size parameter, removes the unused mqtt_max_packet_size type and function, and updates the version numbers of the emqx_dashboard and emqx_opentelemetry applications. It also fixes the format of the cluster gauge metric in the emqx_otel module.

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
  • Added property-based tests for code which performs user input validation
  • 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
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • 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

@zhongwencool zhongwencool marked this pull request as ready for review August 14, 2023 02:15
@zhongwencool zhongwencool requested review from JimMoen, lafirest and a team as code owners August 14, 2023 02:15
@zhongwencool
Copy link
Member Author

zhongwencool commented Aug 14, 2023

bytesize is also compatibility with the string(mqtt.max_packet_size="1")

lafirest
lafirest previously approved these changes Aug 14, 2023
HJianBo
HJianBo previously approved these changes Aug 14, 2023
@zhongwencool zhongwencool dismissed stale reviews from HJianBo and lafirest via 4ee4f59 August 14, 2023 02:38
@coveralls
Copy link
Collaborator

coveralls commented Aug 14, 2023

Pull Request Test Coverage Report for Build 5853180204

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • 24 unchanged lines in 13 files lost coverage.
  • Overall coverage increased (+0.03%) to 81.354%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/emqx_opentelemetry/src/emqx_otel.erl 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
apps/emqx_authz/src/emqx_authz_schema.erl 1 85.92%
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_client.erl 1 94.74%
apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_consumer_worker.erl 1 93.31%
apps/emqx_dashboard/src/emqx_dashboard_desc_cache.erl 1 94.44%
apps/emqx_gateway/src/emqx_gateway_schema.erl 1 94.44%
apps/emqx_management/src/emqx_mgmt_util.erl 1 13.79%
apps/emqx/src/bpapi/emqx_bpapi.erl 1 95.83%
apps/emqx/src/emqx_broker.erl 1 88.89%
apps/emqx/src/emqx_cm.erl 1 89.96%
apps/emqx_utils/src/emqx_utils.erl 1 82.63%
Totals Coverage Status
Change from base Build 5832650470: 0.03%
Covered Lines: 32226
Relevant Lines: 39612

馃挍 - Coveralls

@@ -2618,6 +2616,16 @@ validate_heap_size(Siz) when is_integer(Siz) ->
validate_heap_size(_SizStr) ->
{error, invalid_heap_size}.

validate_packet_size(Siz) when is_integer(Siz) andalso Siz < 1 ->
{error, #{reason => max_heap_size_too_small, minimum => 1}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{error, #{reason => max_heap_size_too_small, minimum => 1}};
{error, #{reason => max_packet_size_too_small, minimum => 1}};

?

{error, #{reason => max_heap_size_too_small, minimum => 1}};
validate_packet_size(Siz) when is_integer(Siz) andalso Siz > ?MAX_INT_MQTT_PACKET_SIZE ->
Max = integer_to_list(round(?MAX_INT_MQTT_PACKET_SIZE / 1024 / 1024)) ++ "M",
{error, #{reason => max_heap_size_too_large, maximum => Max}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{error, #{reason => max_heap_size_too_large, maximum => Max}};
{error, #{reason => max_packet_size_too_large, maximum => Max}};

?

@zhongwencool zhongwencool merged commit b2d5bae into emqx:master Aug 14, 2023
128 checks passed
@zhongwencool zhongwencool deleted the max-packet-size-validate branch August 14, 2023 12:31
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

5 participants