### CI Link

https://gradle-enterprise.elastic.co/s/bettqvfg5kyos

### Repro line

./gradlew ':server:internalClusterTest' --tests "org.elasticsearch.indices.recovery.IndexRecoveryIT.testTransientErrorsDuringRecoveryAreRetried" -Dtests.seed=4BDFC31A406EBDF9 -Dtests.locale=ga -Dtests.timezone=America/Atikokan -Druntime.java=19	

### Does it reproduce?

Didn't try

### Applicable branches

main

### Failure history

https://gradle-enterprise.elastic.co/scans/tests?search.timeZoneId=Europe/Rome&tests.container=org.elasticsearch.indices.recovery.IndexRecoveryIT&tests.test=testTransientErrorsDuringRecoveryAreRetried

### Failure excerpt

```
java.lang.AssertionError: timed out waiting for green state
```

Call to `ensureGreen()` times out before being able to reach a stable cluster state.
server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", 1)).get();
        var allocator = internalCluster().getInstance(ShardsAllocator.class);
        if (allocator instanceof BalancedShardsAllocator) {
            
            ensureGreen("test");
        } else if (allocator instanceof DesiredBalanceShardsAllocator) {
            
            ensureYellow("test");
        } else {
            fail("Unknown allocator used");
        }
        client().admin().indices().prepareRefresh("test").get();
        assertHitCount(client().prepareSearch().get(), numDocs);
    }
    
    public void testOngoingRecoveryAndMasterFailOver() throws Exception {
        String indexName = "test";
        internalCluster().startNodes(2);
        String nodeWithPrimary = internalCluster().startDataOnlyNode();
        assertAcked(
            client().admin()
                .indices()
                .prepareCreate(indexName)
                .setSettings(
                    Settings.builder()
                        .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
                        .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
                        .put("index.routing.allocation.include._name", nodeWithPrimary)
                )
        );