envoyproxy/envoy

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

Open

Aperta il 25 gen 2026

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)C++ (27.997 star) (5373 fork)batch import
area/upstreamenhancementhelp wanted

Descrizione

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

Guida contributor