run e2e
This commit is contained in:
parent
8f2b701361
commit
6ce0e63f7e
4 changed files with 1239 additions and 1542 deletions
|
@ -41,10 +41,10 @@ func (em exeMatcher) MatchAndName(nacl common.NameAndCmdline) (bool, string) {
|
|||
return em.name == cmd, ""
|
||||
}
|
||||
|
||||
func (n *NGINXController) setupMonitor(args []string) {
|
||||
func (n *NGINXController) setupMonitor(args []string, vtsCollector *bool) {
|
||||
|
||||
// TODO fix true
|
||||
pc, err := newProcessCollector(true, exeMatcher{"nginx", args}, false)
|
||||
pc, err := newProcessCollector(true, exeMatcher{"nginx", args}, vtsCollector)
|
||||
if err != nil {
|
||||
glog.Warningf("unexpected error registering nginx collector: %v", err)
|
||||
}
|
||||
|
@ -58,7 +58,14 @@ func (n *NGINXController) setupMonitor(args []string) {
|
|||
}
|
||||
|
||||
func (n *NGINXController) reloadMonitor(enableVts *bool) {
|
||||
n.namedProcessCollector.vtsCollector = enableVts
|
||||
|
||||
if enableVts == nil {
|
||||
falseVar := false
|
||||
n.namedProcessCollector.vtsCollector = &falseVar
|
||||
return
|
||||
}
|
||||
falseVar := true
|
||||
n.namedProcessCollector.vtsCollector = &falseVar
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -238,7 +245,7 @@ type (
|
|||
func newProcessCollector(
|
||||
children bool,
|
||||
n common.MatchNamer,
|
||||
vtsCollector bool) (*namedProcessCollector, error) {
|
||||
vtsCollector *bool) (*namedProcessCollector, error) {
|
||||
|
||||
//fs, err := proc.NewFS("/proc")
|
||||
//if err != nil {
|
||||
|
@ -248,7 +255,7 @@ func newProcessCollector(
|
|||
scrapeChan: make(chan scrapeRequest),
|
||||
Grouper: proc.NewGrouper(children, n),
|
||||
//fs: fs,
|
||||
vtsCollector: &vtsCollector,
|
||||
vtsCollector: vtsCollector,
|
||||
}
|
||||
|
||||
//_, err = p.Update(p.fs.AllProcs())
|
||||
|
@ -272,7 +279,7 @@ func (p *namedProcessCollector) Describe(ch chan<- *prometheus.Desc) {
|
|||
ch <- memVirtualbytesDesc
|
||||
ch <- startTimeDesc
|
||||
|
||||
if p.vtsCollector == true {
|
||||
if *p.vtsCollector {
|
||||
|
||||
ch <- vtsBytesDesc
|
||||
ch <- vtsCacheDesc
|
||||
|
@ -312,7 +319,7 @@ func (p *namedProcessCollector) start() {
|
|||
ch := req.results
|
||||
p.scrapeNginxStatus(ch)
|
||||
|
||||
if &p.vtsCollector {
|
||||
if *p.vtsCollector {
|
||||
p.scrapeVts(ch)
|
||||
}
|
||||
|
||||
|
@ -471,3 +478,4 @@ func reflectMetrics(value interface{}, desc *prometheus.Desc, ch chan<- promethe
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -159,8 +159,8 @@ func (n *NGINXController) start(cmd *exec.Cmd, done chan error) {
|
|||
done <- err
|
||||
return
|
||||
}
|
||||
|
||||
n.setupMonitor(cmd.Args)
|
||||
falseVar := false
|
||||
n.setupMonitor(cmd.Args, &falseVar)
|
||||
|
||||
go func() {
|
||||
done <- cmd.Wait()
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -213,7 +213,11 @@ http {
|
|||
listen {{ if not $cfg.DisableIpv6 }}[::]:{{ end }}80{{ if $cfg.UseProxyProtocol }} proxy_protocol{{ end }}{{ if eq $server.Hostname "_"}} default_server {{ if not $cfg.DisableIpv6 }}ipv6only=off{{end}} reuseport backlog={{ $backlogSize }}{{end}};
|
||||
{{/* Listen on 442 because port 443 is used in the stream section */}}
|
||||
{{/* This listen on port 442 cannot contains proxy_protocol directive because port 443 is in charge of decoding the protocol */}}
|
||||
<<<<<<< HEAD
|
||||
{{ if not (empty $server.SSLCertificate) }}listen {{ if gt (len $passthroughBackends) 0 }}442{{ else }}{{ if not $cfg.DisableIpv6 }}[::]:{{ end }}443 {{ if $cfg.UseProxyProtocol }} proxy_protocol {{ end }}{{ end }} {{ if eq $server.Hostname "_"}} default_server {{ if not $cfg.DisableIpv6 }}ipv6only=off{{end}} reuseport backlog={{ $backlogSize }}{{end}} ssl {{ if $cfg.UseHTTP2 }}http2{{ end }};
|
||||
=======
|
||||
{{ if not (empty $server.SSLCertificate) }}listen {{ if gt (len $passthroughBackends) 0 }}4420{{ else }}[::]:4430 {{ if $cfg.UseProxyProtocol }} proxy_protocol {{ end }}{{ end }} {{ if eq $index 0 }} ipv6only=off{{end}} {{ if eq $server.Hostname "_"}} default_server reuseport backlog={{ $backlogSize }}{{end}} ssl ; #{{ if $cfg.UseHTTP2 }}http2{{ end }};
|
||||
>>>>>>> run e2e
|
||||
{{/* comment PEM sha is required to detect changes in the generated configuration and force a reload */}}
|
||||
# PEM sha: {{ $server.SSLPemChecksum }}
|
||||
ssl_certificate {{ $server.SSLCertificate }};
|
||||
|
@ -221,7 +225,7 @@ http {
|
|||
{{ end }}
|
||||
|
||||
{{ if (and (not (empty $server.SSLCertificate)) $cfg.HSTS) }}
|
||||
more_set_headers "Strict-Transport-Security: max-age={{ $cfg.HSTSMaxAge }}{{ if $cfg.HSTSIncludeSubdomains }}; includeSubDomains{{ end }}; preload";
|
||||
#more_set_headers "Strict-Transport-Security: max-age={{ $cfg.HSTSMaxAge }}{{ if $cfg.HSTSIncludeSubdomains }}; includeSubDomains{{ end }}; preload";
|
||||
{{ end }}
|
||||
|
||||
{{ if $cfg.EnableVtsStatus }}vhost_traffic_status_filter_by_set_key $geoip_country_code country::$server_name;{{ end }}
|
||||
|
@ -384,7 +388,6 @@ http {
|
|||
}
|
||||
{{ end }}
|
||||
|
||||
{{ template "CUSTOM_ERRORS" $cfg }}
|
||||
}
|
||||
|
||||
{{ end }}
|
||||
|
@ -427,9 +430,9 @@ http {
|
|||
set $proxy_upstream_name "upstream-default-backend";
|
||||
proxy_pass http://upstream-default-backend;
|
||||
}
|
||||
{{ template "CUSTOM_ERRORS" $cfg }}
|
||||
}
|
||||
|
||||
|
||||
# default server for services without endpoints
|
||||
server {
|
||||
listen 8181;
|
||||
|
@ -437,6 +440,7 @@ http {
|
|||
|
||||
location / {
|
||||
{{ if .CustomErrors }}
|
||||
<<<<<<< HEAD
|
||||
content_by_lua_block {
|
||||
openURL(ngx.req.get_headers(0), 503)
|
||||
}
|
||||
|
@ -517,44 +521,14 @@ stream {
|
|||
{{ range $errCode := .CustomHTTPErrors }}
|
||||
location @custom_{{ $errCode }} {
|
||||
internal;
|
||||
=======
|
||||
>>>>>>> run e2e
|
||||
content_by_lua_block {
|
||||
openURL(ngx.req.get_headers(0), {{ $errCode }})
|
||||
}
|
||||
openURL(ngx.req.get_headers(0), 503)
|
||||
}
|
||||
{{ else }}
|
||||
return 503;
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* CORS support from https://michielkalkman.com/snippets/nginx-cors-open-configuration.html */}}
|
||||
{{ define "CORS" }}
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
#
|
||||
# Om nom nom cookies
|
||||
#
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
#
|
||||
# Custom headers and headers various browsers *should* be OK with but aren't
|
||||
#
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||
#
|
||||
# Tell client that this pre-flight info is valid for 20 days
|
||||
#
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Content-Type' 'text/plain charset=UTF-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'POST') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||
}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue