Skip to content

Commit 7d4ea3f

Browse files
authored
Checking that a configuration exists before attempting to delete it when its index has been deleted (elastic#136984)
1 parent fc7ae8e commit 7d4ea3f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/src/main/java/org/elasticsearch/ingest/SamplingService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,14 @@ private void maybeDeleteSamplingConfigurations(ClusterChangedEvent event, Projec
510510
IndexMetadata current = currentProject.index(index.getIndex());
511511
if (current == null) {
512512
String indexName = index.getIndex().getName();
513-
logger.debug("Deleting sample configuration for {} because the index has been deleted", indexName);
514-
deleteSampleConfiguration(projectId, indexName);
513+
SamplingConfiguration samplingConfiguration = getSamplingConfiguration(
514+
event.state().projectState(projectId).metadata(),
515+
indexName
516+
);
517+
if (samplingConfiguration != null) {
518+
logger.debug("Deleting sample configuration for {} because the index has been deleted", indexName);
519+
deleteSampleConfiguration(projectId, indexName);
520+
}
515521
}
516522
}
517523
}

0 commit comments

Comments
 (0)