Skip to content

Commit

Permalink
fix original destination bug (istio#13242)
Browse files Browse the repository at this point in the history
* fix original destination bug

* add ut
  • Loading branch information
hzxuzhonghu authored and rshriram committed Apr 11, 2019
1 parent 4b5666a commit cc09c8d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pilot/pkg/networking/core/v1alpha3/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,12 @@ func applyLoadBalancer(cluster *apiv2.Cluster, lb *networking.LoadBalancerSettin
return
}

// Original destination service discovery must be used with the original destination load balancer.
if cluster.GetClusterDiscoveryType().Equal(&apiv2.Cluster_Type{Type: apiv2.Cluster_ORIGINAL_DST}) {
cluster.LbPolicy = apiv2.Cluster_ORIGINAL_DST_LB
return
}

// TODO: MAGLEV
switch lb.GetSimple() {
case networking.LoadBalancerSettings_LEAST_CONN:
Expand Down
23 changes: 23 additions & 0 deletions pilot/pkg/networking/core/v1alpha3/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,3 +734,26 @@ func TestBuildLocalityLbEndpoints(t *testing.T) {
}
}
}

func TestClusterDiscoveryTypeAndLbPolicy(t *testing.T) {
g := NewGomegaWithT(t)

clusters, err := buildTestClusters("*.example.org", model.Passthrough, model.SidecarProxy, nil, testMesh,
&networking.DestinationRule{
Host: "*.example.org",
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
},
},
})

g.Expect(err).NotTo(HaveOccurred())
g.Expect(clusters[0].LbPolicy).To(Equal(apiv2.Cluster_ORIGINAL_DST_LB))
g.Expect(clusters[0].GetClusterDiscoveryType()).To(Equal(&apiv2.Cluster_Type{Type: apiv2.Cluster_ORIGINAL_DST}))
}

0 comments on commit cc09c8d

Please sign in to comment.