def _check_cluster_raft_term(self, cluster_id: Optional[str], value: Union[None, str, int]) -> None:
        """Check that observed Raft Term in Etcd cluster is increasing.

        :param cluster_id: last observed Etcd Cluster ID
        :param raft_term: last observed Raft Term

        :raises:
            :exc::`StaleEtcdNode` if last observed *raft_term* is smaller than previously known *raft_term*.
        """
        if not (cluster_id and value):
            return

        # We need to reset the memorized value when we notice that Cluster ID changed.
        if self._cluster_id and self._cluster_id != cluster_id:
            logger.warning('Etcd Cluster ID changed from %s to %s', self._cluster_id, cluster_id)
            self._raft_term = 0
        self._cluster_id = cluster_id

        try:
            raft_term = int(value)
        except Exception:
            return

        if raft_term < self._raft_term:
            logger.warning('Connected to Etcd node with term %d. Old known term %d. Switching to another node.',
                           raft_term, self._raft_term)
            raise StaleEtcdNode
        self._raft_term = raft_term
Check that observed Raft Term in Etcd cluster is increasing.

        :param cluster_id: last observed Etcd Cluster ID
        :param raft_term: last observed Raft Term

        :raises:
            :exc::`StaleEtcdNode` if last observed *raft_term* is smaller than previously known *raft_term*.
        
patroni/dcs/etcd.py