mirror of
https://github.com/alibaba/higress.git
synced 2026-06-02 00:57:28 +08:00
feat: add new param for global option (#813)
Signed-off-by: sjcsjc123 <1401189096@qq.com>
This commit is contained in:
@@ -39,6 +39,7 @@ const (
|
|||||||
|
|
||||||
defaultIdleTimeout = 180
|
defaultIdleTimeout = 180
|
||||||
defaultUpStreamIdleTimeout = 10
|
defaultUpStreamIdleTimeout = 10
|
||||||
|
defaultUpStreamConnectionBufferLimits = 10485760
|
||||||
defaultMaxRequestHeadersKb = 60
|
defaultMaxRequestHeadersKb = 60
|
||||||
defaultConnectionBufferLimits = 32768
|
defaultConnectionBufferLimits = 32768
|
||||||
defaultMaxConcurrentStreams = 100
|
defaultMaxConcurrentStreams = 100
|
||||||
@@ -72,6 +73,8 @@ type Downstream struct {
|
|||||||
type Upstream struct {
|
type Upstream struct {
|
||||||
// IdleTimeout limits the time that a connection may be idle on the upstream.
|
// IdleTimeout limits the time that a connection may be idle on the upstream.
|
||||||
IdleTimeout uint32 `json:"idleTimeout"`
|
IdleTimeout uint32 `json:"idleTimeout"`
|
||||||
|
// ConnectionBufferLimits configures the buffer size limits for connections.
|
||||||
|
ConnectionBufferLimits uint32 `json:"connectionBufferLimits,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Http2 configures HTTP/2 specific options.
|
// Http2 configures HTTP/2 specific options.
|
||||||
@@ -158,6 +161,7 @@ func deepCopyGlobal(global *Global) (*Global, error) {
|
|||||||
}
|
}
|
||||||
if global.Upstream != nil {
|
if global.Upstream != nil {
|
||||||
newGlobal.Upstream.IdleTimeout = global.Upstream.IdleTimeout
|
newGlobal.Upstream.IdleTimeout = global.Upstream.IdleTimeout
|
||||||
|
newGlobal.Upstream.ConnectionBufferLimits = global.Upstream.ConnectionBufferLimits
|
||||||
}
|
}
|
||||||
newGlobal.AddXRealIpHeader = global.AddXRealIpHeader
|
newGlobal.AddXRealIpHeader = global.AddXRealIpHeader
|
||||||
newGlobal.DisableXEnvoyHeaders = global.DisableXEnvoyHeaders
|
newGlobal.DisableXEnvoyHeaders = global.DisableXEnvoyHeaders
|
||||||
@@ -188,6 +192,7 @@ func NewDefaultDownstream() *Downstream {
|
|||||||
func NewDefaultUpStream() *Upstream {
|
func NewDefaultUpStream() *Upstream {
|
||||||
return &Upstream{
|
return &Upstream{
|
||||||
IdleTimeout: defaultUpStreamIdleTimeout,
|
IdleTimeout: defaultUpStreamIdleTimeout,
|
||||||
|
ConnectionBufferLimits: defaultUpStreamConnectionBufferLimits,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,10 +344,11 @@ func (g *GlobalOptionController) ConstructEnvoyFilters() ([]*config.Config, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
upstreamStruct := g.constructUpstream(global.Upstream)
|
upstreamStruct := g.constructUpstream(global.Upstream)
|
||||||
|
bufferLimitStruct = g.constructUpstreamBufferLimit(global.Upstream)
|
||||||
if len(upstreamStruct) == 0 {
|
if len(upstreamStruct) == 0 {
|
||||||
return generateEnvoyFilter(namespace, configPatch), nil
|
return generateEnvoyFilter(namespace, configPatch), nil
|
||||||
}
|
}
|
||||||
upstreamConfig := g.generateUpstreamEnvoyFilter(upstreamStruct, namespace)
|
upstreamConfig := g.generateUpstreamEnvoyFilter(upstreamStruct, bufferLimitStruct, namespace)
|
||||||
configPatch = append(configPatch, upstreamConfig...)
|
configPatch = append(configPatch, upstreamConfig...)
|
||||||
|
|
||||||
return generateEnvoyFilter(namespace, configPatch), nil
|
return generateEnvoyFilter(namespace, configPatch), nil
|
||||||
@@ -404,7 +410,7 @@ func (g *GlobalOptionController) generateDownstreamEnvoyFilter(downstreamValueSt
|
|||||||
return downstreamConfig
|
return downstreamConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GlobalOptionController) generateUpstreamEnvoyFilter(upstreamValueStruct string, namespace string) []*networking.EnvoyFilter_EnvoyConfigObjectPatch {
|
func (g *GlobalOptionController) generateUpstreamEnvoyFilter(upstreamValueStruct string, bufferLimit string, namespace string) []*networking.EnvoyFilter_EnvoyConfigObjectPatch {
|
||||||
upstreamConfig := []*networking.EnvoyFilter_EnvoyConfigObjectPatch{
|
upstreamConfig := []*networking.EnvoyFilter_EnvoyConfigObjectPatch{
|
||||||
{
|
{
|
||||||
ApplyTo: networking.EnvoyFilter_CLUSTER,
|
ApplyTo: networking.EnvoyFilter_CLUSTER,
|
||||||
@@ -416,6 +422,16 @@ func (g *GlobalOptionController) generateUpstreamEnvoyFilter(upstreamValueStruct
|
|||||||
Value: util.BuildPatchStruct(upstreamValueStruct),
|
Value: util.BuildPatchStruct(upstreamValueStruct),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ApplyTo: networking.EnvoyFilter_CLUSTER,
|
||||||
|
Match: &networking.EnvoyFilter_EnvoyConfigObjectMatch{
|
||||||
|
Context: networking.EnvoyFilter_GATEWAY,
|
||||||
|
},
|
||||||
|
Patch: &networking.EnvoyFilter_Patch{
|
||||||
|
Operation: networking.EnvoyFilter_Patch_MERGE,
|
||||||
|
Value: util.BuildPatchStruct(bufferLimit),
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return upstreamConfig
|
return upstreamConfig
|
||||||
}
|
}
|
||||||
@@ -531,6 +547,16 @@ func (g *GlobalOptionController) constructUpstream(upstream *Upstream) string {
|
|||||||
return upstreamConfig
|
return upstreamConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// constructUpstreamBufferLimit constructs the upstream buffer limit config.
|
||||||
|
func (g *GlobalOptionController) constructUpstreamBufferLimit(upstream *Upstream) string {
|
||||||
|
upstreamBufferLimitStruct := fmt.Sprintf(`
|
||||||
|
{
|
||||||
|
"per_connection_buffer_limit_bytes": %d
|
||||||
|
}
|
||||||
|
`, upstream.ConnectionBufferLimits)
|
||||||
|
return upstreamBufferLimitStruct
|
||||||
|
}
|
||||||
|
|
||||||
// constructAddXRealIpHeader constructs the add x-real-ip header config.
|
// constructAddXRealIpHeader constructs the add x-real-ip header config.
|
||||||
func (g *GlobalOptionController) constructAddXRealIpHeader() string {
|
func (g *GlobalOptionController) constructAddXRealIpHeader() string {
|
||||||
addXRealIpHeaderStruct := fmt.Sprintf(`
|
addXRealIpHeaderStruct := fmt.Sprintf(`
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
},
|
},
|
||||||
Upstream: &configmap.Upstream{
|
Upstream: &configmap.Upstream{
|
||||||
IdleTimeout: 10,
|
IdleTimeout: 10,
|
||||||
|
ConnectionBufferLimits: 10485760,
|
||||||
},
|
},
|
||||||
DisableXEnvoyHeaders: true,
|
DisableXEnvoyHeaders: true,
|
||||||
AddXRealIpHeader: true,
|
AddXRealIpHeader: true,
|
||||||
@@ -128,6 +129,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "10s",
|
"idle_timeout": "10s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -147,6 +149,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
},
|
},
|
||||||
Upstream: &configmap.Upstream{
|
Upstream: &configmap.Upstream{
|
||||||
IdleTimeout: 10,
|
IdleTimeout: 10,
|
||||||
|
ConnectionBufferLimits: 10485760,
|
||||||
},
|
},
|
||||||
DisableXEnvoyHeaders: true,
|
DisableXEnvoyHeaders: true,
|
||||||
},
|
},
|
||||||
@@ -214,6 +217,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "10s",
|
"idle_timeout": "10s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -233,6 +237,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
},
|
},
|
||||||
Upstream: &configmap.Upstream{
|
Upstream: &configmap.Upstream{
|
||||||
IdleTimeout: 10,
|
IdleTimeout: 10,
|
||||||
|
ConnectionBufferLimits: 10485760,
|
||||||
},
|
},
|
||||||
AddXRealIpHeader: true,
|
AddXRealIpHeader: true,
|
||||||
},
|
},
|
||||||
@@ -305,6 +310,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "10s",
|
"idle_timeout": "10s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -324,6 +330,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
},
|
},
|
||||||
Upstream: &configmap.Upstream{
|
Upstream: &configmap.Upstream{
|
||||||
IdleTimeout: 10,
|
IdleTimeout: 10,
|
||||||
|
ConnectionBufferLimits: 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
envoyAssertion: []envoy.Assertion{
|
envoyAssertion: []envoy.Assertion{
|
||||||
@@ -388,6 +395,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "10s",
|
"idle_timeout": "10s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -559,6 +567,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "10s",
|
"idle_timeout": "10s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -805,6 +814,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "10s",
|
"idle_timeout": "10s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 10485760,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -824,6 +834,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
},
|
},
|
||||||
Upstream: &configmap.Upstream{
|
Upstream: &configmap.Upstream{
|
||||||
IdleTimeout: 0,
|
IdleTimeout: 0,
|
||||||
|
ConnectionBufferLimits: 32768,
|
||||||
},
|
},
|
||||||
DisableXEnvoyHeaders: true,
|
DisableXEnvoyHeaders: true,
|
||||||
AddXRealIpHeader: true,
|
AddXRealIpHeader: true,
|
||||||
@@ -899,6 +910,7 @@ var ConfigMapGlobalEnvoy = suite.ConformanceTest{
|
|||||||
"common_http_protocol_options": map[string]interface{}{
|
"common_http_protocol_options": map[string]interface{}{
|
||||||
"idle_timeout": "0s",
|
"idle_timeout": "0s",
|
||||||
},
|
},
|
||||||
|
"per_connection_buffer_limit_bytes": 32768,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user