envoyproxy/envoy

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

Open

#43.150 aberto em 25 de jan. de 2026

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)C++ (5.373 forks)batch import
area/upstreamenhancementhelp wanted

Métricas do repositório

Stars
 (27.997 stars)
Métricas de merge de PR
 (Mesclagem média 7d 21h) (260 fundiu PRs em 30d)

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;
}

Guia do colaborador