func processEdsClusterResponse()

in dp_check/dp_check.go [816:834]


func processEdsClusterResponse(cdsReply *v3discoverypb.DiscoveryResponse, clusterName string) (string, error) {
	edsCluster, err := getCluster(cdsReply, clusterName)
	if err != nil {
		return "", fmt.Errorf("failed to get EDS cluster from CDS response: %v", err)
	}
	if edsCluster.GetType() != v3clusterpb.Cluster_EDS {
		return "", fmt.Errorf("the cluster type is expected to be EDS, but it is: %v, set --xds_expect_fallback_configured=true if CFE fallback is expected to be configured for this service", edsCluster.GetType())
	}
	// The cluster lbPolicy field must be Round Robin or Ring Hash
	if edsCluster.GetLbPolicy() != v3clusterpb.Cluster_ROUND_ROBIN && edsCluster.GetLbPolicy() != v3clusterpb.Cluster_RING_HASH {
		return "", fmt.Errorf("expected cluster lb_policy field to be Round Robin or Ring Hash, but is is: |%+v|", edsCluster.GetLbPolicy())
	}
	if serviceName := edsCluster.GetEdsClusterConfig().GetServiceName(); serviceName != "" {
		infoLog.Printf("eds_cluster_config.service_name |%v| is not empty, use it as the service_name for EDS request", serviceName)
		return serviceName, nil
	}
	infoLog.Printf("eds_cluster_config.service_name is empty, use cluster_name |%v| as the service_name for EDS request", clusterName)
	return clusterName, nil
}