From 7e38f4c3e506d6f8276110324178680d80a0e6ff Mon Sep 17 00:00:00 2001 From: Shriram Sharma Date: Tue, 30 Aug 2022 17:28:36 -0700 Subject: [PATCH 1/4] added default connection pool to DR Signed-off-by: Shriram Sharma --- admiral/pkg/clusters/handler.go | 14 +++++++++++++- admiral/pkg/clusters/handler_test.go | 25 ++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/admiral/pkg/clusters/handler.go b/admiral/pkg/clusters/handler.go index 1d160728..b207054e 100644 --- a/admiral/pkg/clusters/handler.go +++ b/admiral/pkg/clusters/handler.go @@ -32,6 +32,8 @@ const ( DefaultBaseEjectionTime int64 = 300 DefaultConsecutiveGatewayErrors uint32 = 50 DefaultInterval int64 = 60 + DefaultHTTP2MaxRequest int32 = 1000 + DefaultMaxRequestsPerConnection int32 = 100 ) // ServiceEntryHandler responsible for handling Add/Update/Delete events for @@ -85,7 +87,17 @@ 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: DefaultHTTP2MaxRequest, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, + } 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?") diff --git a/admiral/pkg/clusters/handler_test.go b/admiral/pkg/clusters/handler_test.go index 431e957e..c2fda3df 100644 --- a/admiral/pkg/clusters/handler_test.go +++ b/admiral/pkg/clusters/handler_test.go @@ -180,7 +180,18 @@ 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: DefaultHTTP2MaxRequest, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, + } 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"}, @@ -199,6 +210,12 @@ func TestGetDestinationRule(t *testing.T) { LocalityLbSetting: &v1alpha3.LocalityLoadBalancerSetting{}, }, OutlierDetection: outlierDetection, + ConnectionPool: &v1alpha3.ConnectionPoolSettings{ + Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ + Http2MaxRequests: DefaultHTTP2MaxRequest, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, }, } @@ -218,6 +235,12 @@ func TestGetDestinationRule(t *testing.T) { }, }, OutlierDetection: outlierDetection, + ConnectionPool: &v1alpha3.ConnectionPoolSettings{ + Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ + Http2MaxRequests: DefaultHTTP2MaxRequest, + MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, + }, + }, }, } From c0bddbcda479b0ee0f35987580f5e71411e3375b Mon Sep 17 00:00:00 2001 From: Shriram Sharma Date: Wed, 31 Aug 2022 09:10:10 -0700 Subject: [PATCH 2/4] Update admiral/pkg/clusters/handler.go Co-authored-by: aattuluri <44482891+aattuluri@users.noreply.github.com> Signed-off-by: Shriram Sharma --- admiral/pkg/clusters/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admiral/pkg/clusters/handler.go b/admiral/pkg/clusters/handler.go index b207054e..3319a02a 100644 --- a/admiral/pkg/clusters/handler.go +++ b/admiral/pkg/clusters/handler.go @@ -32,7 +32,7 @@ const ( DefaultBaseEjectionTime int64 = 300 DefaultConsecutiveGatewayErrors uint32 = 50 DefaultInterval int64 = 60 - DefaultHTTP2MaxRequest int32 = 1000 + DefaultHTTP2MaxRequests int32 = 1000 DefaultMaxRequestsPerConnection int32 = 100 ) From b53217b6500fd7378b6ba4f37fc9a36e66cd62a2 Mon Sep 17 00:00:00 2001 From: Shriram Sharma Date: Wed, 31 Aug 2022 09:14:25 -0700 Subject: [PATCH 3/4] fixed typo Signed-off-by: Shriram Sharma --- admiral/pkg/clusters/handler.go | 4 ++-- admiral/pkg/clusters/handler_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/admiral/pkg/clusters/handler.go b/admiral/pkg/clusters/handler.go index 3319a02a..13eb5665 100644 --- a/admiral/pkg/clusters/handler.go +++ b/admiral/pkg/clusters/handler.go @@ -32,7 +32,7 @@ const ( DefaultBaseEjectionTime int64 = 300 DefaultConsecutiveGatewayErrors uint32 = 50 DefaultInterval int64 = 60 - DefaultHTTP2MaxRequests int32 = 1000 + DefaultHTTP2MaxRequests int32 = 1000 DefaultMaxRequestsPerConnection int32 = 100 ) @@ -93,7 +93,7 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP }, ConnectionPool: &v1alpha32.ConnectionPoolSettings{ Http: &v1alpha32.ConnectionPoolSettings_HTTPSettings{ - Http2MaxRequests: DefaultHTTP2MaxRequest, + Http2MaxRequests: DefaultHTTP2MaxRequests, MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, }, }, diff --git a/admiral/pkg/clusters/handler_test.go b/admiral/pkg/clusters/handler_test.go index c2fda3df..577731d3 100644 --- a/admiral/pkg/clusters/handler_test.go +++ b/admiral/pkg/clusters/handler_test.go @@ -187,7 +187,7 @@ func TestGetDestinationRule(t *testing.T) { OutlierDetection: outlierDetection, ConnectionPool: &v1alpha3.ConnectionPoolSettings{ Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ - Http2MaxRequests: DefaultHTTP2MaxRequest, + Http2MaxRequests: DefaultHTTP2MaxRequests, MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, }, }, @@ -212,7 +212,7 @@ func TestGetDestinationRule(t *testing.T) { OutlierDetection: outlierDetection, ConnectionPool: &v1alpha3.ConnectionPoolSettings{ Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ - Http2MaxRequests: DefaultHTTP2MaxRequest, + Http2MaxRequests: DefaultHTTP2MaxRequests, MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, }, }, @@ -237,7 +237,7 @@ func TestGetDestinationRule(t *testing.T) { OutlierDetection: outlierDetection, ConnectionPool: &v1alpha3.ConnectionPoolSettings{ Http: &v1alpha3.ConnectionPoolSettings_HTTPSettings{ - Http2MaxRequests: DefaultHTTP2MaxRequest, + Http2MaxRequests: DefaultHTTP2MaxRequests, MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, }, }, From 3fcbe167698df6143b4f158c17797cc4c48ab793 Mon Sep 17 00:00:00 2001 From: Shriram Sharma Date: Thu, 1 Sep 2022 09:49:20 -0700 Subject: [PATCH 4/4] modified the LB policy to LEAST_REQUEST Signed-off-by: Shriram Sharma --- admiral/pkg/clusters/handler.go | 7 ++++++- admiral/pkg/clusters/handler_test.go | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/admiral/pkg/clusters/handler.go b/admiral/pkg/clusters/handler.go index 13eb5665..69c48fdc 100644 --- a/admiral/pkg/clusters/handler.go +++ b/admiral/pkg/clusters/handler.go @@ -97,6 +97,11 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP MaxRequestsPerConnection: DefaultMaxRequestsPerConnection, }, }, + LoadBalancer: &v1alpha32.LoadBalancerSettings{ + LbPolicy: &v1alpha32.LoadBalancerSettings_Simple{ + Simple: v1alpha32.LoadBalancerSettings_LEAST_REQUEST, + }, + }, } if len(locality) == 0 { @@ -105,7 +110,7 @@ func getDestinationRule(se *v1alpha32.ServiceEntry, locality string, gtpTrafficP } 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 { diff --git a/admiral/pkg/clusters/handler_test.go b/admiral/pkg/clusters/handler_test.go index 577731d3..c8fa424a 100644 --- a/admiral/pkg/clusters/handler_test.go +++ b/admiral/pkg/clusters/handler_test.go @@ -191,6 +191,11 @@ func TestGetDestinationRule(t *testing.T) { 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{ @@ -206,7 +211,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{}, }, OutlierDetection: outlierDetection, @@ -224,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{ {