Add verification of lua load balancer to health check (#2308)
This commit is contained in:
parent
888b74b336
commit
1c65320618
3 changed files with 34 additions and 1 deletions
File diff suppressed because one or more lines are too long
|
@ -42,6 +42,17 @@ func (n *NGINXController) Check(_ *http.Request) error {
|
|||
return fmt.Errorf("ingress controller is not healthy")
|
||||
}
|
||||
|
||||
if n.cfg.DynamicConfigurationEnabled {
|
||||
res, err := http.Get(fmt.Sprintf("http://0.0.0.0:%v/is-dynamic-lb-initialized", n.cfg.ListenPorts.Status))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != 200 {
|
||||
return fmt.Errorf("dynamic load balancer not started")
|
||||
}
|
||||
}
|
||||
|
||||
// check the nginx master process is running
|
||||
fs, err := proc.NewFS("/proc")
|
||||
if err != nil {
|
||||
|
|
|
@ -487,10 +487,32 @@ http {
|
|||
set $proxy_upstream_name "-";
|
||||
|
||||
location {{ $healthzURI }} {
|
||||
{{ if $cfg.EnableOpentracing }}
|
||||
opentracing off;
|
||||
{{ end }}
|
||||
access_log off;
|
||||
return 200;
|
||||
}
|
||||
|
||||
location /is-dynamic-lb-initialized {
|
||||
{{ if $cfg.EnableOpentracing }}
|
||||
opentracing off;
|
||||
{{ end }}
|
||||
access_log off;
|
||||
|
||||
content_by_lua_block {
|
||||
local configuration = require("configuration")
|
||||
local backend_data = configuration.get_backends_data()
|
||||
if not backend_data then
|
||||
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("OK")
|
||||
ngx.exit(ngx.HTTP_OK)
|
||||
}
|
||||
}
|
||||
|
||||
location /nginx_status {
|
||||
set $proxy_upstream_name "internal";
|
||||
{{ if $cfg.EnableOpentracing }}
|
||||
|
|
Loading…
Reference in a new issue