**Build scan:**
https://gradle-enterprise.elastic.co/s/i4wszq2gckgjs/tests/:server:internalClusterTest/org.elasticsearch.health.HealthMetadataServiceIT/testEachMasterPublishesTheirThresholds

**Reproduction line:**
```
./gradlew ':server:internalClusterTest' --tests "org.elasticsearch.health.HealthMetadataServiceIT.testEachMasterPublishesTheirThresholds" -Dtests.seed=8F8ACBE5210B39A4 -Dtests.locale=hu-HU -Dtests.timezone=UTC -Druntime.java=19
```

**Applicable branches:**
main

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.health.HealthMetadataServiceIT&tests.test=testEachMasterPublishesTheirThresholds

**Failure excerpt:**
```
java.lang.IllegalArgumentException: Failed to parse value [0] for setting [cluster.max_shards_per_node] must be >= 1

  at __randomizedtesting.SeedInfo.seed([8F8ACBE5210B39A4:E1485DC2AE1F5DF4]:0)
  at org.elasticsearch.common.settings.Setting.parseInt(Setting.java:1437)
  at org.elasticsearch.common.settings.Setting.parseInt(Setting.java:1426)
  at org.elasticsearch.common.settings.Setting.lambda$intSetting$10(Setting.java:1318)
  at org.elasticsearch.common.settings.Setting.get(Setting.java:518)
  at org.elasticsearch.common.settings.Setting.get(Setting.java:512)
  at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:615)
  at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:521)
  at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:491)
  at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:461)
  at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:151)
  at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:56)
  at org.elasticsearch.node.Node.<init>(Node.java:474)
  at org.elasticsearch.node.MockNode.<init>(MockNode.java:106)
  at org.elasticsearch.node.MockNode.<init>(MockNode.java:89)
  at org.elasticsearch.test.InternalTestCluster.buildNode(InternalTestCluster.java:769)
  at org.elasticsearch.test.InternalTestCluster.startNodes(InternalTestCluster.java:2166)
  at org.elasticsearch.test.InternalTestCluster.startNode(InternalTestCluster.java:2106)
  at org.elasticsearch.health.HealthMetadataServiceIT.startNode(HealthMetadataServiceIT.java:166)
  at org.elasticsearch.health.HealthMetadataServiceIT.testEachMasterPublishesTheirThresholds(HealthMetadataServiceIT.java:57)
  at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
  at java.lang.reflect.Method.invoke(Method.java:578)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
  at java.lang.Thread.run(Thread.java:1589)

```
server/src/internalClusterTest/java/org/elasticsearch/health/HealthMetadataServiceIT.java
import static org.elasticsearch.indices.ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE_FROZEN;
import static org.elasticsearch.test.NodeRoles.onlyRoles;
import static org.hamcrest.Matchers.equalTo;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
public class HealthMetadataServiceIT extends ESIntegTestCase {
    private volatile boolean percentageMode;
    @Before
    public void setup() {
        percentageMode = randomBoolean();
    }
    public void testEachMasterPublishesTheirThresholds() throws Exception {
        try (InternalTestCluster internalCluster = internalCluster()) {
            int numberOfNodes = 3;
            Map<String, String> watermarkByNode = new HashMap<>();
            Map<String, ByteSizeValue> maxHeadroomByNode = new HashMap<>();
            Map<String, HealthMetadata.ShardLimits> shardLimitsPerNode = new HashMap<>();
            for (int i = 0; i < numberOfNodes; i++) {
                ByteSizeValue randomBytes = ByteSizeValue.ofBytes(randomLongBetween(6, 19));
                String customWatermark = percentageMode ? randomIntBetween(86, 94) + "%" : randomBytes.toString();
                ByteSizeValue customMaxHeadroom = percentageMode ? randomBytes : ByteSizeValue.MINUS_ONE;
                var customShardLimits = new HealthMetadata.ShardLimits(randomIntBetween(0, 1000), randomIntBetween(1001, 2000));
                String nodeName = startNode(internalCluster, customWatermark, customMaxHeadroom.toString(), customShardLimits);
                watermarkByNode.put(nodeName, customWatermark);
                maxHeadroomByNode.put(nodeName, customMaxHeadroom);
                shardLimitsPerNode.put(nodeName, customShardLimits);
            }
            ensureStableCluster(numberOfNodes);
            String electedMaster = internalCluster.getMasterName();
            {
                var healthMetadata = HealthMetadata.getFromClusterState(internalCluster.clusterService().state());