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/main/java/org/elasticsearch/action/admin/cluster/coordination/MasterHistoryAction.java
}
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            MasterHistoryAction.Response response = (MasterHistoryAction.Response) o;
            return masterHistory.equals(response.masterHistory);
        }
        @Override
        public int hashCode() {
            return Objects.hash(masterHistory);
        }
    }
    /**
     * This transport action fetches the MasterHistory from a remote node.
     */
    public static class TransportAction extends HandledTransportAction<Request, Response> {
        private final MasterHistoryService masterHistoryService;
        @Inject
        public TransportAction(TransportService transportService, ActionFilters actionFilters, MasterHistoryService masterHistoryService) {
            super(MasterHistoryAction.NAME, transportService, actionFilters, MasterHistoryAction.Request::new);
            this.masterHistoryService = masterHistoryService;
        }
        @Override
        protected void doExecute(Task task, MasterHistoryAction.Request request, ActionListener<Response> listener) {
            listener.onResponse(new MasterHistoryAction.Response(masterHistoryService.getLocalMasterHistory().getNodes()));
        }
    }
}