Similar to https://github.com/elastic/elasticsearch/issues/82807 Kibana upgrades can never succeed if a cluster already exceeded the maximum open shards.

It would reduce the downtime and help our users safely upgrade if we emitted a critical warning from the deprecations info API for this condition. At the moment it will only help users upgrading from 7.x to 8.x but we hope to enable the upgrade assistant during minor upgrades too https://github.com/elastic/kibana/issues/117220
server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java
return new ShardLimitValidator(limitOnlySettings, clusterService);
    }
    /**
     * Creates a {@link ShardLimitValidator} for testing with the given setting and a mocked cluster service.
     *
     * @param maxShardsPerNode the value to use for the max shards per node setting
     * @return a test instance
     */
    public static ShardLimitValidator createTestShardLimitService(int maxShardsPerNode) {
        
        ClusterService clusterService = mock(ClusterService.class);
        Settings limitOnlySettings = Settings.builder().put(SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), maxShardsPerNode).build();
        when(clusterService.getClusterSettings()).thenReturn(
            new ClusterSettings(limitOnlySettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)
        );
        return new ShardLimitValidator(limitOnlySettings, clusterService);
    }
    /**
     * Creates a {@link ShardLimitValidator} for testing with the given setting and a given cluster service.
     *
     * @param maxShardsPerNode the value to use for the max shards per node setting
     * @param clusterService   the cluster service to use
     * @return a test instance
     */
    public static ShardLimitValidator createTestShardLimitService(int maxShardsPerNode, ClusterService clusterService) {
        Settings limitOnlySettings = Settings.builder().put(SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), maxShardsPerNode).build();
        return new ShardLimitValidator(limitOnlySettings, clusterService);
    }
}