### Elasticsearch Version

8.6.0, 8.7.0, 8.8.0, 8.9.0

### Installed Plugins

ESS default

### Java Version

ESS default

### OS Version

ESS default

### Problem Description

Our clusters hit continuously the following error on ESS

It is related to the number of shards per cluster `max_shards_in_cluster` that is calculated based on `max_shards_per_node` but is not correctly calculated, our value for `max_shards_per_node` is 10000. We have 10 data nodes, so we have configured more than 7000 shards per cluster for sure. No matter the value you put on `max_shards_per_node`, we cannot have more than 7000 shards in our clusters.

![image](https://github.com/elastic/elasticsearch/assets/5400788/b32b3025-6c49-4ea8-a793-3a3d8ff0d300)

```
      "shards_capacity" : {
        "status" : "Red",
        "symptom" : "Cluster is close to reaching the configured maximum number of shards for data nodes.",
        "details" : {
          "data" : {
            "max_shards_in_cluster" : 7000,
            "current_used_shards" : 9023
```

```
{
  "status": "green",
  "number_of_nodes": 10,
  "unassigned_shards": 0,
  "number_of_pending_tasks": 2,
  "number_of_in_flight_fetch": 0,
  "timed_out": false,
  "active_primary_shards": 5185,
  "task_max_waiting_in_queue_millis": 600,
  "cluster_name": "0000000000000000000000000",
  "relocating_shards": 0,
  "active_shards_percent_as_number": 100,
  "active_shards": 9753,
  "initializing_shards": 0,
  "number_of_data_nodes": 7,
  "delayed_unassigned_shards": 0
}
```

Probably related to https://github.com/elastic/elasticsearch/issues/91119

### Steps to Reproduce

* Deploy a cluster with Elastic Stack 8.7.0
* Create more than 7000 shards
* Change the value of `max_shards_per_node` to 5000
* Wait until the error appears again

### Logs (if relevant)

_No response_
server/src/main/java/org/elasticsearch/node/Node.java
jvmInfo,
                (e, apmConfig) -> logger.error("failed to delete temporary APM config file [{}], reason: [{}]", apmConfig, e.getMessage())
            );
            this.pluginsService = pluginServiceCtor.apply(tmpSettings);
            final Settings settings = mergePluginSettings(pluginsService.pluginMap(), tmpSettings);
            /*
             * Create the environment based on the finalized view of the settings. This is to ensure that components get the same setting
             * values, no matter they ask for them from.
             */
            this.environment = new Environment(settings, initialEnvironment.configFile());
            Environment.assertEquivalent(initialEnvironment, this.environment);
            final List<ExecutorBuilder<?>> executorBuilders = pluginsService.flatMap(p -> p.getExecutorBuilders(settings)).toList();
            final ThreadPool threadPool = new ThreadPool(settings, executorBuilders.toArray(new ExecutorBuilder<?>[0]));
            resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
            final ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, threadPool);
            resourcesToClose.add(resourceWatcherService);
            
            HeaderWarning.setThreadContext(threadPool.getThreadContext());
            resourcesToClose.add(() -> HeaderWarning.removeThreadContext(threadPool.getThreadContext()));
            final Set<String> taskHeaders = Stream.concat(
                pluginsService.filterPlugins(ActionPlugin.class).stream().flatMap(p -> p.getTaskHeaders().stream()),
                Task.HEADERS_TO_COPY.stream()
            ).collect(Collectors.toSet());
            final Tracer tracer = getTracer(pluginsService, settings);
            final TaskManager taskManager = new TaskManager(settings, threadPool, taskHeaders, tracer);
            
            final List<Setting<?>> additionalSettings = new ArrayList<>(pluginsService.flatMap(Plugin::getSettings).toList());
            for (final ExecutorBuilder<?> builder : threadPool.builders()) {
                additionalSettings.addAll(builder.getRegisteredSettings());
            }