Skip to content

Commit

Permalink
Update delete object to never fail if alias does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso committed Mar 13, 2024
1 parent de33a57 commit 5bdf344
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
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 5bdf344

Please sign in to comment.