Skip to content

Commit

Permalink
backport of commit 438aae1
Browse files Browse the repository at this point in the history
  • Loading branch information
analogue committed Nov 9, 2022
1 parent 4aecb06 commit ba40944
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
29 changes: 22 additions & 7 deletions control-plane/api/v1alpha1/ingressgateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func (in *IngressGateway) ToConsul(datacenter string) capi.ConfigEntry {
TLS: *in.Spec.TLS.toConsul(),
Listeners: listeners,
Meta: meta(datacenter),
Defaults: in.Spec.Defaults.toConsul(),
}
}

Expand Down Expand Up @@ -344,13 +345,16 @@ func (in IngressListener) toConsul() capi.IngressListener {

func (in IngressService) toConsul() capi.IngressService {
return capi.IngressService{
Name: in.Name,
Hosts: in.Hosts,
Namespace: in.Namespace,
Partition: in.Partition,
TLS: in.TLS.toConsul(),
RequestHeaders: in.RequestHeaders.toConsul(),
ResponseHeaders: in.ResponseHeaders.toConsul(),
Name: in.Name,
Hosts: in.Hosts,
Namespace: in.Namespace,
Partition: in.Partition,
TLS: in.TLS.toConsul(),
RequestHeaders: in.RequestHeaders.toConsul(),
ResponseHeaders: in.ResponseHeaders.toConsul(),
MaxConnections: in.MaxConnections,
MaxPendingRequests: in.MaxPendingRequests,
MaxConcurrentRequests: in.MaxConcurrentRequests,
}
}

Expand Down Expand Up @@ -456,3 +460,14 @@ func (in *IngressServiceConfig) validate(path *field.Path) field.ErrorList {
}
return errs
}

func (in *IngressServiceConfig) toConsul() *capi.IngressServiceConfig {
if in == nil {
return nil
}
return &capi.IngressServiceConfig{
MaxConnections: in.MaxConnections,
MaxPendingRequests: in.MaxPendingRequests,
MaxConcurrentRequests: in.MaxConcurrentRequests,
}
}
41 changes: 33 additions & 8 deletions control-plane/api/v1alpha1/ingressgateway_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ func TestIngressGateway_MatchesConsul(t *testing.T) {
}

func TestIngressGateway_ToConsul(t *testing.T) {

defaultMaxConnections := uint32(100)
defaultMaxPendingRequests := uint32(101)
defaultMaxConcurrentRequests := uint32(102)

maxConnections := uint32(200)
maxPendingRequests := uint32(201)
maxConcurrentRequests := uint32(202)

cases := map[string]struct {
Ours IngressGateway
Exp *capi.IngressGatewayConfigEntry
Expand Down Expand Up @@ -289,6 +298,11 @@ func TestIngressGateway_ToConsul(t *testing.T) {
TLSMaxVersion: "TLSv1_1",
CipherSuites: []string{"ECDHE-ECDSA-AES128-GCM-SHA256", "AES128-SHA"},
},
Defaults: &IngressServiceConfig{
MaxConnections: &defaultMaxConnections,
MaxPendingRequests: &defaultMaxPendingRequests,
MaxConcurrentRequests: &defaultMaxConcurrentRequests,
},
Listeners: []IngressListener{
{
Port: 8888,
Expand All @@ -305,10 +319,13 @@ func TestIngressGateway_ToConsul(t *testing.T) {
},
Services: []IngressService{
{
Name: "name1",
Hosts: []string{"host1_1", "host1_2"},
Namespace: "ns1",
Partition: "default",
Name: "name1",
Hosts: []string{"host1_1", "host1_2"},
Namespace: "ns1",
Partition: "default",
MaxConnections: &maxConnections,
MaxPendingRequests: &maxPendingRequests,
MaxConcurrentRequests: &maxConcurrentRequests,
TLS: &GatewayServiceTLSConfig{
SDS: &GatewayTLSSDSConfig{
ClusterName: "cluster1",
Expand Down Expand Up @@ -378,6 +395,11 @@ func TestIngressGateway_ToConsul(t *testing.T) {
TLSMaxVersion: "TLSv1_1",
CipherSuites: []string{"ECDHE-ECDSA-AES128-GCM-SHA256", "AES128-SHA"},
},
Defaults: &capi.IngressServiceConfig{
MaxConnections: &defaultMaxConnections,
MaxPendingRequests: &defaultMaxPendingRequests,
MaxConcurrentRequests: &defaultMaxConcurrentRequests,
},
Listeners: []capi.IngressListener{
{
Port: 8888,
Expand All @@ -394,10 +416,13 @@ func TestIngressGateway_ToConsul(t *testing.T) {
},
Services: []capi.IngressService{
{
Name: "name1",
Hosts: []string{"host1_1", "host1_2"},
Namespace: "ns1",
Partition: "default",
Name: "name1",
Hosts: []string{"host1_1", "host1_2"},
Namespace: "ns1",
Partition: "default",
MaxConnections: &maxConnections,
MaxPendingRequests: &maxPendingRequests,
MaxConcurrentRequests: &maxConcurrentRequests,
TLS: &capi.GatewayServiceTLSConfig{
SDS: &capi.GatewayTLSSDSConfig{
ClusterName: "cluster1",
Expand Down

0 comments on commit ba40944

Please sign in to comment.