### CI Link

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

### Repro line
```
./gradlew ':x-pack:plugin:ml:test' --tests "org.elasticsearch.xpack.ml.utils.NativeMemoryCalculatorTests.testActualNodeSizeCalculationConsistency" -Dtests.seed=A70DC496F83A52CF
```

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

_No response_

### Failure excerpt

```java
org.elasticsearch.xpack.ml.utils.NativeMemoryCalculatorTests > testActualNodeSizeCalculationConsistency FAILED
    java.lang.AssertionError: native memory [113246208] smaller than original native memory [113669306]
    Expected: a value equal to or greater than <113669305L>
         but: <113246208L> was less than <113669305L>
        at __randomizedtesting.SeedInfo.seed([A70DC496F83A52CF:8204CD95D7187768]:0)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
        at org.junit.Assert.assertThat(Assert.java:956)
        at org.elasticsearch.xpack.ml.utils.NativeMemoryCalculatorTests.lambda$testActualNodeSizeCalculationConsistency$0(NativeMemoryCalculatorTests.java:170)
        at org.elasticsearch.xpack.ml.utils.NativeMemoryCalculatorTests.testActualNodeSizeCalculationConsistency(NativeMemoryCalculatorTests.java:207)
```

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculator.java
/**
     * Get the maximum value of model memory limit that a user may set in a job config.
     * If the xpack.ml.max_model_memory_limit setting is set then the value comes from that.
     * Otherwise, if xpack.ml.use_auto_machine_memory_percent is set then the maximum model
     * memory limit is considered to be the largest model memory limit that could fit into
     * the cluster (on the assumption that configured lazy nodes will be added and other
     * jobs stopped to make space).
     * @return The maximum model memory limit calculated from the current cluster settings,
     *         or {@link ByteSizeValue#ZERO} if there is no limit.
     */
    public static ByteSizeValue getMaxModelMemoryLimit(ClusterService clusterService) {
        ClusterSettings clusterSettings = clusterService.getClusterSettings();
        ByteSizeValue maxModelMemoryLimit = clusterSettings.get(MachineLearningField.MAX_MODEL_MEMORY_LIMIT);
        if (maxModelMemoryLimit != null && maxModelMemoryLimit.getBytes() > 0) {
            return maxModelMemoryLimit;
        }
        
        
        Boolean autoMemory = clusterSettings.get(MachineLearning.USE_AUTO_MACHINE_MEMORY_PERCENT);
        if (autoMemory) {
            DiscoveryNodes nodes = clusterService.state().getNodes();
            ByteSizeValue modelMemoryLimitToFit = calculateMaxModelMemoryLimitToFit(clusterSettings, nodes);
            if (modelMemoryLimitToFit != null) {
                return modelMemoryLimitToFit;
            }
        }
        return ByteSizeValue.ZERO;
    }
}