Skip to content

Commit 03f45da

Browse files
hub-capmartijnvg
authored andcommitted
Fix policy removal bug in delete policy (#45573)
The delete policy had a subtle bug in that it would still delete the policy if pipelines were accessing it, after giving the client back an error. This commit fixes that and ensures it does not happen by adding verification in the test.
1 parent fd57d3c commit 03f45da

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

x-pack/plugin/enrich/qa/common/src/main/java/org/elasticsearch/test/enrich/CommonEnrichRestTestCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public void testDeleteExistingPipeline() throws Exception {
128128
// delete the pipelines so the policies can be deleted
129129
client().performRequest(new Request("DELETE", "/_ingest/pipeline/my_pipeline"));
130130
client().performRequest(new Request("DELETE", "/_ingest/pipeline/another_pipeline"));
131+
132+
// verify the delete did not happen
133+
Request getRequest = new Request("GET", "/_enrich/policy/my_policy");
134+
assertOK(client().performRequest(getRequest));
131135
}
132136

133137
private static Map<String, Object> toMap(Response response) throws IOException {

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/TransportDeleteEnrichPolicyAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ protected void masterOperation(DeleteEnrichPolicyAction.Request request, Cluster
8282
listener.onFailure(
8383
new ElasticsearchStatusException("Could not delete policy [{}] because a pipeline is referencing it {}",
8484
RestStatus.CONFLICT, request.getName(), pipelinesWithProcessors));
85+
return;
8586
}
8687

8788
EnrichStore.deletePolicy(request.getName(), clusterService, e -> {

0 commit comments

Comments
 (0)