Skip to content

Commit 0874e58

Browse files
Fix delete rule event consumption for wildcard index based rules (opensearch-project#18628)
--------- Signed-off-by: Kaushal Kumar <[email protected]> Signed-off-by: Ankit Jain <[email protected]> Co-authored-by: Ankit Jain <[email protected]>
1 parent 6dd0ca8 commit 0874e58

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3333
### Fixed
3434
- Add task cancellation checks in aggregators ([#18426](https://github.com/opensearch-project/OpenSearch/pull/18426))
3535
- Fix concurrent timings in profiler ([#18540](https://github.com/opensearch-project/OpenSearch/pull/18540))
36+
- [Autotagging] Fix delete rule event consumption in InMemoryRuleProcessingService ([#18628](https://github.com/opensearch-project/OpenSearch/pull/18628))
3637
- Cannot communicate with HTTP/2 when reactor-netty is enabled ([#18599](https://github.com/opensearch-project/OpenSearch/pull/18599))
3738
- Fix the visit of sub queries for HasParentQuery and HasChildQuery ([#18621](https://github.com/opensearch-project/OpenSearch/pull/18621))
3839

modules/autotagging-commons/src/main/java/org/opensearch/rule/InMemoryRuleProcessingService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void perform(Rule rule, BiConsumer<Map.Entry<Attribute, Set<String>>, Ru
6666
private void removeOperation(Map.Entry<Attribute, Set<String>> attributeEntry, Rule rule) {
6767
AttributeValueStore<String, String> valueStore = attributeValueStoreFactory.getAttributeValueStore(attributeEntry.getKey());
6868
for (String value : attributeEntry.getValue()) {
69-
valueStore.remove(value);
69+
valueStore.remove(value.replace(WILDCARD, ""));
7070
}
7171
}
7272

modules/autotagging-commons/src/test/java/org/opensearch/rule/InMemoryRuleProcessingServiceTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public void testRemove() {
5353
assertFalse(label.isPresent());
5454
}
5555

56+
public void testAddThenRemoveWithWildcard() {
57+
Rule rule = getRule(Set.of("test-*"), "test_id");
58+
sut.add(rule);
59+
sut.remove(rule);
60+
61+
List<AttributeExtractor<String>> extractors = getAttributeExtractors(List.of("test-index"));
62+
Optional<String> label = sut.evaluateLabel(extractors);
63+
assertFalse(label.isPresent());
64+
}
65+
5666
public void testEvaluateLabelForExactMatch() {
5767
sut.add(getRule(Set.of("test1", "change"), "test_id"));
5868
sut.add(getRule(Set.of("test", "double"), "test_id1"));

0 commit comments

Comments
 (0)