Skip to content

Commit

Permalink
fixup! Keep deleting even if something fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreden committed Oct 23, 2024
1 parent e16279b commit 9c8efe3
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private void getRoleMappings(Client client, ActionListener<ExpressionRoleMapping

private void deleteNativeRoleMappings(Client client, Iterator<String> namesIterator, ActionListener<Void> listener) {
String name = namesIterator.next();
boolean hasNext = namesIterator.hasNext();
executeAsyncWithOrigin(
client,
SECURITY_ORIGIN,
Expand All @@ -184,12 +185,20 @@ private void deleteNativeRoleMappings(Client client, Iterator<String> namesItera
} else {
logger.info("Deleted duplicated role mapping [" + name + "] from .security index");
}
if (namesIterator.hasNext()) {
if (hasNext) {
deleteNativeRoleMappings(client, namesIterator, listener);
} else {
listener.onResponse(null);
}
}, listener::onFailure)
}, exception -> {
logger.warn("Failed to delete role mapping [" + name + "]", exception);
if (hasNext) {
// Continue even if some deletions fail to do as much cleanup as possible
deleteNativeRoleMappings(client, namesIterator, listener);
} else {
listener.onFailure(exception);
}
})
);
}

Expand Down

0 comments on commit 9c8efe3

Please sign in to comment.