Skip to content

Commit

Permalink
Fix Search Applications bug where deleting an alias before deleting a…
Browse files Browse the repository at this point in the history
…n application intermittently caused errors (elastic#106329)

* Update delete object to never fail if alias does not exist

* Update docs/changelog/106329.yaml

* Update changelog

* Fix area in changelog
  • Loading branch information
kderusso authored Mar 14, 2024
1 parent b71a33c commit fc6c2dc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/106329.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 106329
summary: Fix Search Applications bug where deleting an alias before deleting an application intermittently caused errors
area: Application
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,18 @@ teardown:
name: test-search-application-to-delete

- match: { acknowledged: true }

---
"Delete Search Application - Alias does not exist as alias was explicitly removed":
- do:
indices.update_aliases:
body:
actions:
- remove:
index: test-index
alias: test-search-application-to-delete

search_application.delete:
name: test-search-application-to-delete

- match: { acknowledged: true }
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,21 @@ private void removeAlias(String searchAliasName, ActionListener<AcknowledgedResp
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest().addAliasAction(
IndicesAliasesRequest.AliasActions.remove().aliases(searchAliasName).indices("*")
);
client.admin()
.indices()
.aliases(
aliasesRequest,
new DelegatingIndexNotFoundActionListener<>(
searchAliasName,
listener,
(l, acknowledgedResponse) -> l.onResponse(AcknowledgedResponse.TRUE)
)
);
client.admin().indices().aliases(aliasesRequest, new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
listener.onResponse(AcknowledgedResponse.TRUE);
}

@Override
public void onFailure(Exception e) {
if (e instanceof ResourceNotFoundException) {
listener.onResponse(AcknowledgedResponse.TRUE);
} else {
listener.onFailure(e);
}
}
});
}

/**
Expand Down

0 comments on commit fc6c2dc

Please sign in to comment.