envoyproxy/envoy

[Feature Request] Health aware weighted clusters: do not route to unhealthy clusters

Open

#43 150 ouverte le 25 janv. 2026

Voir sur GitHub
 (3 commentaires) (0 réactions) (0 assignés)C++ (5 373 forks)batch import
area/upstreamenhancementhelp wanted

Métriques du dépôt

Stars
 (27 997 stars)
Métriques de merge PR
 (Merge moyen 7j 21h) (260 PRs mergées en 30 j)

Description

Title: Health aware weighted cluster routing

Description: Weighted clusters are frequently used to route to remote ingress endpoints which tend to be single VIPs. If one of the clusters is "unhealthy" traffic is still sent to the cluster even though it has NO healthy endpoints.

For the above use case this is not the expected or desired behaviour. So potentially this is a bug.

API change. Add a health_aware_lb bool to weighted cluster: Do not route to a cluster with no healthy endpoints.

Implementation Plan https://github.com/envoyproxy/envoy/blob/2d3d05dff994eae57b628a765d9cc4958bd1b77e/source/common/router/weighted_cluster_specifier.h#L25

Thread thru health_aware_lb_ and update WeightedClustersConfigEntry::clusterWeight to also take Upstream::ClusterManager& cluster_manager and then something like this.

 uint64_t clusterWeight(Runtime::Loader& loader, Upstream::ClusterManager& cm) const {
  auto weight = loader.snapshot().getInteger(runtime_key_, cluster_weight_);

  if (health_aware_lb_ && weight > 0) {
    auto* cluster = cm.getThreadLocalCluster(cluster_name_);
    if (cluster != nullptr) {
      for (const auto& ps : cluster->prioritySet().hostSetsPerPriority()) {
        if (!ps->healthyHosts().empty()) {
          return weight;
        }
      }
      return 0;
    }
  }
  return weight;
}

Guide contributeur