Skip to content

Commit

Permalink
fixup! Add assertion on migration status
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreden committed Oct 24, 2024
1 parent 90eb45f commit b86c0a8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import static org.elasticsearch.xpack.core.ClientHelper.SECURITY_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
import static org.elasticsearch.xpack.security.support.SecurityIndexManager.RoleMappingsCleanupMigrationStatus.READY;
import static org.elasticsearch.xpack.security.support.SecurityIndexManager.RoleMappingsCleanupMigrationStatus.SKIP;
import static org.elasticsearch.xpack.security.support.SecuritySystemIndices.SecurityMainIndexMappingVersion.ADD_MANAGE_ROLES_PRIVILEGE;
import static org.elasticsearch.xpack.security.support.SecuritySystemIndices.SecurityMainIndexMappingVersion.ADD_REMOTE_CLUSTER_AND_DESCRIPTION_FIELDS;

Expand Down Expand Up @@ -153,10 +154,11 @@ public int minMappingVersion() {
public static class CleanupRoleMappingDuplicatesMigration implements SecurityMigration {
@Override
public void migrate(SecurityIndexManager indexManager, Client client, ActionListener<Void> listener) {
if (indexManager.getRoleMappingsCleanupMigrationStatus() == SecurityIndexManager.RoleMappingsCleanupMigrationStatus.SKIP) {
if (indexManager.getRoleMappingsCleanupMigrationStatus() == SKIP) {
listener.onResponse(null);
return;
}
assert indexManager.getRoleMappingsCleanupMigrationStatus() == READY;

getRoleMappings(client, ActionListener.wrap(roleMappings -> {
List<String> roleMappingsToDelete = getDuplicateRoleMappingNames(roleMappings.mappings());
Expand Down

0 comments on commit b86c0a8

Please sign in to comment.