**Build scan:**
https://gradle-enterprise.elastic.co/s/xvwrlxusnxdgu/tests/:qa:rolling-upgrade:v8.6.1%23oneThirdUpgradedTest/org.elasticsearch.upgrades.SnapshotBasedRecoveryIT/testSnapshotBasedRecovery

**Reproduction line:**
```
./gradlew ':qa:rolling-upgrade:v8.6.1#oneThirdUpgradedTest' -Dtests.class="org.elasticsearch.upgrades.SnapshotBasedRecoveryIT" -Dtests.method="testSnapshotBasedRecovery" -Dtests.seed=32151106DB58AD22 -Dtests.bwc=true -Dtests.locale=en-MT -Dtests.timezone=Asia/Colombo -Druntime.java=17
```

**Applicable branches:**
main

**Reproduces locally?:**
Didn't try

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.upgrades.SnapshotBasedRecoveryIT&tests.test=testSnapshotBasedRecovery

**Failure excerpt:**
```
java.lang.AssertionError: timed out waiting for green state for index [snapshot_based_recovery] cluster state [{
  "cluster_name" : "v8.6.1",
  "cluster_uuid" : "ETWjuovuQXC6pr6CN8pJXA",
  "version" : 391,
  "state_uuid" : "y7ss0aZLQvab9JIDk7jppg",
  "master_node" : "tsyOGVI1T5iBSTLS0zL29A",
  ...
```
server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationCommandsTests.java
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).routingTable(routingTable).build();
        final String node1 = "node1";
        final String node2 = "node2";
        clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode(node1)).add(newNode(node2))).build();
        clusterState = allocation.reroute(clusterState, "reroute", ActionListener.noop());
        
        final List<ShardRouting> shardRoutings = shardsWithState(clusterState.getRoutingNodes(), UNASSIGNED);
        assertThat(shardRoutings, hasSize(2));
        logger.info("--> allocating empty primary with acceptDataLoss flag set to true");
        clusterState = allocation.reroute(
            clusterState,
            new AllocationCommands(new AllocateStalePrimaryAllocationCommand(index, 0, node1, true)),
            false,
            false,
            false,
            ActionListener.noop()
        ).clusterState();
        RoutingNode routingNode1 = clusterState.getRoutingNodes().node(node1);
        assertThat(routingNode1.size(), equalTo(1));
        assertThat(routingNode1.numberOfShardsWithState(INITIALIZING), equalTo(1));
        Set<String> inSyncAllocationIds = clusterState.metadata().index(index).inSyncAllocationIds(0);
        assertThat(inSyncAllocationIds, equalTo(Collections.singleton(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID)));
        clusterState = startInitializingShardsAndReroute(allocation, clusterState);
        routingNode1 = clusterState.getRoutingNodes().node(node1);
        assertThat(routingNode1.size(), equalTo(1));
        assertThat(routingNode1.numberOfShardsWithState(STARTED), equalTo(1));
        inSyncAllocationIds = clusterState.metadata().index(index).inSyncAllocationIds(0);
        assertThat(inSyncAllocationIds, hasSize(1));
        assertThat(inSyncAllocationIds, not(Collections.singleton(RecoverySource.ExistingStoreRecoverySource.FORCED_ALLOCATION_ID)));
    }