Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin) support HTTP/2 when requesting /status #8690

Merged
merged 12 commits into from
May 5, 2022
Merged

fix(admin) support HTTP/2 when requesting /status #8690

merged 12 commits into from
May 5, 2022

Conversation

outsinre
Copy link
Contributor

:8444/status does not support HTTP/2 due to
"ngx.location.capture". Now use LuaJIT ffi to retrieve Nginx status
data.

The "/nginx_status" location block is left in nginx-kong.conf as other
components may depend on it.

@CLAassistant
Copy link

CLAassistant commented Apr 15, 2022

CLA assistant check
All committers have signed the CLA.

kong/api/routes/health.lua Outdated Show resolved Hide resolved
kong/api/routes/health.lua Outdated Show resolved Hide resolved
kong/api/routes/health.lua Outdated Show resolved Hide resolved
dndx
dndx previously approved these changes Apr 22, 2022
kong/pdk/nginx.lua Outdated Show resolved Hide resolved
@dndx
Copy link
Member

dndx commented Apr 22, 2022

Approved with minor improvement.

@dndx dndx dismissed their stale review April 22, 2022 07:55

No tests

@dndx
Copy link
Member

dndx commented Apr 22, 2022

outsinre and others added 10 commits April 28, 2022 01:31
:8444/status does not support HTTP/2 due to
"ngx.location.capture". Now use LuaJIR ffi to retrieve Nginx status
data.

The "/nginx_status" location block is left in nginx-kong.conf as other
components may depend on it.
The "prometheus" plugin now depends 'ngx.location.capture' to retrieve
/metrics through Admin API. However, 'ngx.location.capture' does not
support http2.

1. Use LuaJIR "ffi" to support http2.
2. Remove the "/nginx_status" location blocks from 'nginx-kong.conf'
   template.

A reminder; the Status API, natively, disallows http2!
We use ffi method to get metrics/status of Kong.
To avoid code duplication. Provide a PDK function reporting Kong
connections and requests metrics at Admin API :8444/status,
:8444/metrics and Status API :8100/metrics.

Update 'prometheus' plugin to invoke the PDK function.
Explain the return values of kong.nginx.get_statistics() function in
details.

Use local variables as many as possible to avoid function calls.
Append test-nginx unit for "kong.nginx.get_statistics()" and busted
unit for plugin "prometheus". The two units test "/metrics" and
"/status" http2 support.
Built-in variables like 'ngx.var.connections_active' may be "nil"
during the busted tasks. Now exposing connections_active,
connections_reading, connections_writing, connections_waiting by 'ffi'
directly.

Add busted task to test prometheus metrics against status API.

Remove '/nginx_status' from prometheus fixtures.

Add 'pdk.nginx.get_statistics' to test-nginx 'phase_checks.t'
@outsinre
Copy link
Contributor Author

outsinre commented May 3, 2022

Seems all checks passed.

Copy link
Member

@kikito kikito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this with minor comments about spacing.

spec/03-plugins/26-prometheus/05-metrics_spec.lua Outdated Show resolved Hide resolved
end)

end)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing: newline at the end of file.

Copy link
Member

@dndx dndx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Pending Enrique's reviews to be addressed.

@dndx dndx merged commit c5fd723 into Kong:master May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants