Watch for updates in configuration configmaps
This commit is contained in:
parent
71ca55440b
commit
ae52257c3a
6 changed files with 66 additions and 24 deletions
|
|
@ -129,7 +129,7 @@ type Configuration struct {
|
|||
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors
|
||||
// http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
|
||||
// By default this is disabled
|
||||
CustomHTTPErrors []int
|
||||
CustomHTTPErrors []int `structs:"custom-http-errors,-"`
|
||||
|
||||
// Time during which a keep-alive client connection will stay open on the server side.
|
||||
// The zero value disables keep-alive client connections
|
||||
|
|
@ -295,7 +295,7 @@ func newDefaultNginxCfg() Configuration {
|
|||
WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
|
||||
VtsStatusZoneSize: "10m",
|
||||
UseHTTP2: true,
|
||||
CustomHTTPErrors: []int{},
|
||||
CustomHTTPErrors: make([]int, 0),
|
||||
}
|
||||
|
||||
if glog.V(5) {
|
||||
|
|
|
|||
|
|
@ -197,14 +197,14 @@ func buildRateLimitZones(input interface{}) []string {
|
|||
for _, server := range servers {
|
||||
for _, loc := range server.Locations {
|
||||
|
||||
if loc.RateLimit.Connections.Limit != -1 {
|
||||
zone := fmt.Sprintf("limit_conn_zone $binary_remote_addr zone=%v:%v;",
|
||||
if loc.RateLimit.Connections.Limit > 0 {
|
||||
zone := fmt.Sprintf("limit_conn_zone $binary_remote_addr zone=%v:%vm;",
|
||||
loc.RateLimit.Connections.Name, loc.RateLimit.Connections.SharedSize)
|
||||
zones = append(zones, zone)
|
||||
}
|
||||
|
||||
if loc.RateLimit.RPS.Limit != -1 {
|
||||
zone := fmt.Sprintf("limit_conn_zone $binary_remote_addr zone=%v:%v rate=%vr/s;",
|
||||
if loc.RateLimit.RPS.Limit > 0 {
|
||||
zone := fmt.Sprintf("limit_conn_zone $binary_remote_addr zone=%v:%vm rate=%vr/s;",
|
||||
loc.RateLimit.Connections.Name, loc.RateLimit.Connections.SharedSize, loc.RateLimit.Connections.Limit)
|
||||
zones = append(zones, zone)
|
||||
}
|
||||
|
|
@ -224,13 +224,13 @@ func buildRateLimit(input interface{}) []string {
|
|||
return limits
|
||||
}
|
||||
|
||||
if loc.RateLimit.Connections.Limit != -1 {
|
||||
if loc.RateLimit.Connections.Limit > 0 {
|
||||
limit := fmt.Sprintf("limit_conn %v %v;",
|
||||
loc.RateLimit.Connections.Name, loc.RateLimit.Connections.Limit)
|
||||
limits = append(limits, limit)
|
||||
}
|
||||
|
||||
if loc.RateLimit.RPS.Limit != -1 {
|
||||
if loc.RateLimit.RPS.Limit > 0 {
|
||||
limit := fmt.Sprintf("limit_req zone=%v burst=%v nodelay;",
|
||||
loc.RateLimit.Connections.Name, loc.RateLimit.Connections.Burst)
|
||||
limits = append(limits, limit)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func (ngx *Manager) ReadConfig(config *api.ConfigMap) Configuration {
|
|||
Metadata: metadata,
|
||||
})
|
||||
|
||||
var cErrors []int
|
||||
cErrors := make([]int, 0)
|
||||
if val, ok := config.Data[customHTTPErrors]; ok {
|
||||
delete(config.Data, customHTTPErrors)
|
||||
for _, i := range strings.Split(val, ",") {
|
||||
|
|
@ -138,7 +138,7 @@ func (ngx *Manager) ReadConfig(config *api.ConfigMap) Configuration {
|
|||
}
|
||||
|
||||
func (ngx *Manager) filterErrors(errCodes []int) []int {
|
||||
var fa []int
|
||||
fa := make([]int, 0)
|
||||
for _, errCode := range errCodes {
|
||||
if errCode > 299 && errCode < 600 {
|
||||
fa = append(fa, errCode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue