source/common/upstream/health_discovery_service.cc
// TODO(lilika): Add support for the same endpoint in different clusters/ports
Add support for the same endpoint in different clusters/ports
Add support for the same endpoint in different clusters / ports
envoy::service::discovery::v2::HealthCheckRequestOrEndpointHealthResponse
HdsDelegate::sendResponse() {
  envoy::service::discovery::v2::HealthCheckRequestOrEndpointHealthResponse response;
  for (const auto& cluster : hds_clusters_) {
    for (const auto& hosts : cluster->prioritySet().hostSetsPerPriority()) {
      for (const auto& host : hosts->hosts()) {
        auto* endpoint = response.mutable_endpoint_health_response()->add_endpoints_health();
        Network::Utility::addressToProtobufAddress(
            *host->address(), *endpoint->mutable_endpoint()->mutable_address());
        if (host->healthy()) {
          endpoint->set_health_status(envoy::api::v2::core::HealthStatus::HEALTHY);
        } else {
          if (host->getActiveHealthFailureType() == Host::ActiveHealthFailureType::TIMEOUT) {
            endpoint->set_health_status(envoy::api::v2::core::HealthStatus::TIMEOUT);
          } else if (host->getActiveHealthFailureType() ==
                     Host::ActiveHealthFailureType::UNHEALTHY) {
            endpoint->set_health_status(envoy::api::v2::core::HealthStatus::UNHEALTHY);
          } else if (host->getActiveHealthFailureType() == Host::ActiveHealthFailureType::UNKNOWN) {
            endpoint->set_health_status(envoy::api::v2::core::HealthStatus::UNHEALTHY);
          } else {
            NOT_REACHED_GCOVR_EXCL_LINE;
          }
        }
      }
    }
  }
  ENVOY_LOG(debug, "Sending EndpointHealthResponse to server {}", response.DebugString());
  stream_->sendMessage(response, false);
  stats_.responses_.inc();
  setHdsStreamResponseTimer();
  return response;
}
envoy :: service :: discovery :: v2 :: HealthCheckRequestOrEndpointHealthResponse HdsDelegate :: sendResponse ( ) { envoy :: service :: discovery :: v2 :: HealthCheckRequestOrEndpointHealthResponse response ; for ( const auto & cluster : hds_clusters_ ) { for ( const auto & hosts : cluster -> prioritySet ( ) . hostSetsPerPriority ( ) ) { for ( const auto & host : hosts -> hosts ( ) ) { auto * endpoint = response . mutable_endpoint_health_response ( ) -> add_endpoints_health ( ) ; Network :: Utility :: addressToProtobufAddress ( * host -> address ( ) , * endpoint -> mutable_endpoint ( ) -> mutable_address ( ) ) ; if ( host -> healthy ( ) ) { endpoint -> set_health_status ( envoy :: api :: v2 :: core :: HealthStatus :: HEALTHY ) ; } else { if ( host -> getActiveHealthFailureType ( ) == Host :: ActiveHealthFailureType :: TIMEOUT ) { endpoint -> set_health_status ( envoy :: api :: v2 :: core :: HealthStatus :: TIMEOUT ) ; } else if ( host -> getActiveHealthFailureType ( ) == Host :: ActiveHealthFailureType :: UNHEALTHY ) { endpoint -> set_health_status ( envoy :: api :: v2 :: core :: HealthStatus :: UNHEALTHY ) ; } else if ( host -> getActiveHealthFailureType ( ) == Host :: ActiveHealthFailureType :: UNKNOWN ) { endpoint -> set_health_status ( envoy :: api :: v2 :: core :: HealthStatus :: UNHEALTHY ) ; } else { NOT_REACHED_GCOVR_EXCL_LINE ; } } } } } ENVOY_LOG ( debug , " " , response . DebugString ( ) ) ; stream_ -> sendMessage ( response , false ) ; stats_ . responses_ . inc ( ) ; setHdsStreamResponseTimer ( ) ; return response ; }
TODO(lilika): Add support for the same endpoint in different clusters/ports
TODO ( lilika ) : Add support for the same endpoint in different clusters / ports
// TODO(lilika): Add support for more granular options of envoy::api::v2::core::HealthStatus