Skip to content

Commit

Permalink
Add default connection pool parameters for generated cnames (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
shriramsharma authored Sep 1, 2022
1 parent 05fc3db commit f933203
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
21 changes: 19 additions & 2 deletions admiral/pkg/clusters/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
DefaultBaseEjectionTime int64 = 300
DefaultConsecutiveGatewayErrors uint32 = 50
DefaultInterval int64 = 60
DefaultHTTP2MaxRequests int32 = 1000
DefaultMaxRequestsPerConnection int32 = 100
)

// ServiceEntryHandler responsible for handling Add/Update/Delete events for
Expand Down Expand Up @@ -85,15 +87,30 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP
dr = &v1alpha32.DestinationRule{}
)
dr.Host = se.Hosts[0]
dr.TrafficPolicy = &v1alpha32.TrafficPolicy{Tls: &v1alpha32.ClientTLSSettings{Mode: v1alpha32.ClientTLSSettings_ISTIO_MUTUAL}}
dr.TrafficPolicy = &v1alpha32.TrafficPolicy{
Tls: &v1alpha32.ClientTLSSettings{
Mode: v1alpha32.ClientTLSSettings_ISTIO_MUTUAL,
},
ConnectionPool: &v1alpha32.ConnectionPoolSettings{
Http: &v1alpha32.ConnectionPoolSettings_HTTPSettings{
Http2MaxRequests: DefaultHTTP2MaxRequests,
MaxRequestsPerConnection: DefaultMaxRequestsPerConnection,
},
},
LoadBalancer: &v1alpha32.LoadBalancerSettings{
LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{
Simple: v1alpha32.LoadBalancerSettings_LEAST_REQUEST,
},
},
}

if len(locality) == 0 {
log.Warnf(LogErrFormat, "Process", "GlobalTrafficPolicy", dr.Host, "", "Skipping gtp processing, locality of the cluster nodes cannot be determined. Is this minikube?")
processGtp = false
}
if gtpTrafficPolicy != nil && processGtp {
var loadBalancerSettings = &v1alpha32.LoadBalancerSettings{
LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{Simple: v1alpha32.LoadBalancerSettings_ROUND_ROBIN},
LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{Simple: v1alpha32.LoadBalancerSettings_LEAST_REQUEST},
}

if len(gtpTrafficPolicy.Target) > 0 {
Expand Down
34 changes: 31 additions & 3 deletions admiral/pkg/clusters/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,23 @@ func TestGetDestinationRule(t *testing.T) {
Interval: &duration.Duration{Seconds: 60},
MaxEjectionPercent: 100,
}
mTLS := &v1alpha3.TrafficPolicy{Tls: &v1alpha3.ClientTLSSettings{Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL}, OutlierDetection: outlierDetection}
mTLS := &v1alpha3.TrafficPolicy{
Tls: &v1alpha3.ClientTLSSettings{
Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL,
},
OutlierDetection: outlierDetection,
ConnectionPool: &v1alpha3.ConnectionPoolSettings{
Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{
Http2MaxRequests: DefaultHTTP2MaxRequests,
MaxRequestsPerConnection: DefaultMaxRequestsPerConnection,
},
},
LoadBalancer: &v1alpha3.LoadBalancerSettings{
LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{
Simple: v1alpha3.LoadBalancerSettings_LEAST_REQUEST,
},
},
}

se := &v1alpha3.ServiceEntry{Hosts: []string{"qa.myservice.global"}, Endpoints: []*v1alpha3.WorkloadEntry{
{Address: "east.com", Locality: "us-east-2"}, {Address: "west.com", Locality: "us-west-2"},
Expand All @@ -195,10 +211,16 @@ func TestGetDestinationRule(t *testing.T) {
TrafficPolicy: &v1alpha3.TrafficPolicy{
Tls: &v1alpha3.ClientTLSSettings{Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL},
LoadBalancer: &v1alpha3.LoadBalancerSettings{
LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_ROUND_ROBIN},
LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_LEAST_REQUEST},
LocalityLbSetting: &v1alpha3.LocalityLoadBalancerSetting{},
},
OutlierDetection: outlierDetection,
ConnectionPool: &v1alpha3.ConnectionPoolSettings{
Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{
Http2MaxRequests: DefaultHTTP2MaxRequests,
MaxRequestsPerConnection: DefaultMaxRequestsPerConnection,
},
},
},
}

Expand All @@ -207,7 +229,7 @@ func TestGetDestinationRule(t *testing.T) {
TrafficPolicy: &v1alpha3.TrafficPolicy{
Tls: &v1alpha3.ClientTLSSettings{Mode: v1alpha3.ClientTLSSettings_ISTIO_MUTUAL},
LoadBalancer: &v1alpha3.LoadBalancerSettings{
LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_ROUND_ROBIN},
LbPolicy: &v1alpha3.LoadBalancerSettings_Simple{Simple: v1alpha3.LoadBalancerSettings_LEAST_REQUEST},
LocalityLbSetting: &v1alpha3.LocalityLoadBalancerSetting{
Distribute: []*v1alpha3.LocalityLoadBalancerSetting_Distribute{
{
Expand All @@ -218,6 +240,12 @@ func TestGetDestinationRule(t *testing.T) {
},
},
OutlierDetection: outlierDetection,
ConnectionPool: &v1alpha3.ConnectionPoolSettings{
Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{
Http2MaxRequests: DefaultHTTP2MaxRequests,
MaxRequestsPerConnection: DefaultMaxRequestsPerConnection,
},
},
},
}

Expand Down

0 comments on commit f933203

Please sign in to comment.