StarRocks / starrocks

StarRocks, a Linux Foundation project, is a next-generation sub-second MPP OLAP database for full analytics scenarios, including multi-dimensional analytics, real-time analytics, and ad-hoc queries.
https://starrocks.io
Apache License 2.0
8.74k stars 1.75k forks source link

[BugFix] Fix match of source ip for resource group (backport #47732) #47803

Closed mergify[bot] closed 3 months ago

mergify[bot] commented 3 months ago

Why I'm doing:

What I'm doing:

Fixes #47437.

  1. Match SubnetUtils::isInRange doesn't consider the broadcast and network address as a usable endpoint by default. As a result, 127.0.0.1 cannot matched 127.0.0.1/32.

  2. Weight The weight of sourceIP of a resource group classifier is 1 + cidrPrefixLength/64. However, we calculate cidrPrefixLength by Long.numberOfLeadingZeros(subnetUtils.getInfo().getAddressCountLong()) - 32, which should be Long.numberOfLeadingZeros(subnetUtils.getInfo().getAddressCountLong()) - 31.

What type of PR is this:

Does this PR entail a change in behavior?

If yes, please specify the type of change:

Checklist:

Bugfix cherry-pick branch check:

What I'm doing:

Fixes #47437.

  1. Match SubnetUtils::isInRange doesn't consider the broadcast and network address as a usable endpoint by default. As a result, 127.0.0.1 cannot matched 127.0.0.1/32.

  2. Weight The weight of sourceIP of a resource group classifier is 1 + cidrPrefixLength/64. However, we calculate cidrPrefixLength by Long.numberOfLeadingZeros(subnetUtils.getInfo().getAddressCountLong()) - 32, which should be Long.numberOfLeadingZeros(subnetUtils.getInfo().getAddressCountLong()) - 31.

What type of PR is this:

Does this PR entail a change in behavior?

If yes, please specify the type of change:

Checklist:

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud