envoyproxy/envoy

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

Open

#43,150 创建于 2026年1月25日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)C++ (27,997 star) (5,373 fork)batch import
area/upstreamenhancementhelp wanted

描述

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

贡献者指南