Repository navigation
Conversation
|
Whole-suite comparison, added for completeness ( The single added test is the new one; the failing ids are identical on both sides and unrelated to this |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Fixes an inconsistency where findActive compared scope.instanceId() against the raw (potentially padded) rule.getInstanceId(), while the metric selector on the line directly above and every other rule matcher (NativeAlertRuleScopeMatcher, NativeAlertMetricCatalogService, NativeAlertRuleTestService) all trim whitespace. This caused padded instance IDs to fire alerts and write FIRING/ACKED rows that findActive could not match back.
The fix applies StringUtils.trimWhitespace() consistently in both MybatisPlusAlertStateRepository.findActive and NativeAlertProcessor.reconcileMissingActiveStates. Test covers the padded-ID scenario. LGTM.
Automated review by github-manager-bot
|
The asymmetry is real: the evaluation path trims the instance id ( Please regroup your open Studio fixes into one PR per functional domain (for example |
What is the purpose of the change
Fixes #4297.
The active-alert-state lookup compares the collection scope's instance id against
rule.getInstanceId()untrimmed, while the metric selector on the line directly above is trimmed andevery rule that decides whether an alert fires trims too
(
NativeAlertRuleScopeMatcher,NativeAlertMetricCatalogService,NativeAlertRuleTestService). Astored padded instance id therefore fires and writes
FIRING/ACKEDrows thatfindActivecannotsee, so the alert disappears from the active/runtime view and
NativeAlertProcessor.reconcileMissingActiveStatescan never resolve it.Brief changelog
server/src/main/java/org/apache/rocketmq/studio/ops/alert/MybatisPlusAlertStateRepository.javafindActivecomparesStringUtils.trimWhitespace(rule.getInstanceId()), matching the metricfilter beside it.
server/src/main/java/org/apache/rocketmq/studio/ops/alert/NativeAlertProcessor.javabefore
findActiveis consulted.server/src/test/java/org/apache/rocketmq/studio/ops/alert/MybatisPlusAlertStateRepositoryTest.javafindsActiveStatesForRulesWithPaddedStoredInstanceIdsTest, mirroring the existingpadded-metric test.
Verification
Red, before the fix (
mvn -o -f server/pom.xml test -Dtest=MybatisPlusAlertStateRepositoryTest):Green, after the fix
(
mvn -o -f server/pom.xml test -Dtest=MybatisPlusAlertStateRepositoryTest,NativeAlertProcessorTest):AI disclosure
Drafted with AI assistance (analysis, patch and test authoring); the red and green Maven output above
was executed and observed locally on Windows, JDK 21.