Today the stable-master health indicator reports `yellow` health if it sees the elected master change 4 times in 30 minutes. However, this could be caused by planned activity such as a rolling restart, and in that case we should not consider a sequence of master failovers as a sign of ill health.

I think we can solve this by refining this check to disregard master nodes that have restarted since they were master, or are no longer in the cluster at all. Restarting the master will always trigger a failover, and the stable-master indicator need not worry about whether the node restart was planned or not; separately, unplanned node restarts are definitely a sign of ill health, but that applies whether the node was the elected master or not. Similarly, if a node is no longer in the cluster then either it is no longer running (again, whether that's planned or not is irrelevant to the stable-master indicator) or else it is running and failing to join the cluster (and hence reporting its own ill health).
server/src/test/java/org/elasticsearch/cluster/coordination/CoordinationDiagnosticsServiceTests.java
* master becomes null and then is immediately non-null when a new master is elected. This means that polling will not be started
         *  since there is a 10-second delay, and we expect no results.
         */
        try (Cluster cluster = new Cluster(3, true, Settings.EMPTY)) {
            createAndAddNonMasterNode(cluster);
            createAndAddNonMasterNode(cluster);
            cluster.runRandomly();
            cluster.stabilise();
            List<DiscoveryNode> masterNodes = cluster.clusterNodes.stream()
                .map(Cluster.ClusterNode::getLocalNode)
                .filter(DiscoveryNode::isMasterNode)
                .toList();
            cluster.clusterNodes.stream().filter(node -> node.getLocalNode().isMasterNode() == false).forEach(node -> {
                List<CoordinationDiagnosticsService.RemoteMasterHealthResult> healthResults = new ArrayList<>();
                AtomicReference<Scheduler.Cancellable> cancellableReference = new AtomicReference<>();
                node.coordinationDiagnosticsService.beginPollingRemoteMasterStabilityDiagnostic(healthResults::add, cancellableReference);
                cancellableReference.get().cancel();
                cluster.runRandomly(false, true, EXTREME_DELAY_VARIABILITY);
                cluster.stabilise();
                /*
                 * The cluster has now run normally for some period of time, but cancel() was called before polling began, so we expect
                 * no results:
                 */
                assertThat(healthResults.size(), equalTo(0));
            });
        }
    }
    public void testRemoteMasterHealthResult() {
        expectThrows(IllegalArgumentException.class, () -> new CoordinationDiagnosticsService.RemoteMasterHealthResult(null, null, null));
        expectThrows(