AlinsRan opened a new pull request, #13878:
URL: https://github.com/apache/apisix/pull/13878

   ### Description
   
   `plugins` / `stream_plugins` in `config.yaml` is only the boot-time default 
for the plugin list. `/apisix/plugins` in etcd replaces it while APISIX runs — 
through the Admin API, or written directly by whatever owns the configuration — 
and that happens long after `apisix init` has rendered `nginx.conf`. So any 
directive `apisix/cli/ngx_tpl.lua` made conditional on that list is missing for 
a plugin enabled the etcd way, and nginx cannot grow a shared memory zone (or a 
location, or a `mirror`) without a reload. The plugin loads, runs, and silently 
does nothing.
   
   `apisix_stream_metrics_zone` is the case that surfaced this. The zone was 
rendered only when `stream_plugins` named `prometheus`, so where the plugin 
list lives in etcd the stream prometheus plugin ran but 
`apisix_stream_active_connections` and `apisix_stream_bandwidth` were never 
published, while `apisix_stream_connection_total` and `apisix_stream_status`, 
which do not read the zone, kept working. Fixing only that one gate would leave 
the same trap for `limit-conn`, `limit-count`, `api-breaker`, `openid-connect`, 
`ocsp-stapling`, `ext-plugin-*`, `mcp-bridge`, `skywalking`, 
`error-log-logger`, `proxy-cache`, `proxy-mirror` and `proxy-buffering`, so 
this removes the coupling everywhere.
   
   **What changes**
   
   - Every `lua_shared_dict` that was gated on the plugin list is now rendered 
unconditionally, as are `lua_capture_error_log`, the proxy-cache directives, 
the proxy-mirror locations and `mirror`, and the `@disable_proxy_buffering` 
location.
   - The prometheus export server now follows 
`plugin_attr.prometheus.enable_export_server` alone (via 
`prometheus_server_addr`), which is the knob that was always meant to govern 
it. The same applies to the `http{}` block that hosts it in stream-only mode.
   - Two gates move to a condition that is genuinely about the environment 
rather than the plugin list: the dubbo directives need `mod_dubbo` and 
`ngx_multi_upstream_module`, so they follow APISIX-Runtime; and 
`prometheus-metrics` is declared in the `lua{}` block whenever the stream 
subsystem runs, so both subsystems share one dict.
   - `enabled_plugins` / `enabled_stream_plugins` are no longer passed to the 
template.
   
   **Cost**
   
   Memory that a trimmed plugin list used to save. With the default plugin list 
only `tracing_buffer`, `ocsp-stapling` and `lua_capture_error_log` are new; a 
deployment that lists just a handful of plugins now allocates the full set of 
dicts. A stream-only deployment also gets the `http{}` block hosting the export 
server, which `enable_export_server: false` still removes.
   
   **Tests**
   
   - `t/cli/test_http_config.sh` and `t/cli/test_stream_config.sh`: the two 
"enable shdict on demand" checks asserted exactly the behaviour being removed; 
they now assert the dict is present whatever the config file lists.
   - `t/cli/test_stream_config.sh`: stream-only mode now renders two 
`lua_package_path` (the second belongs to the export server's `http{}`); the 
added check keeps the original intent by asserting the http *proxy* is still 
absent.
   - `t/cli/test_prometheus_stream.sh`: a new block seeds the plugin list into 
etcd with no `stream_plugins` in `config.yaml` and the Admin API off, then 
asserts both that the zone is rendered and that `apisix_stream_bandwidth` is 
exported for proxied traffic. Both assertions fail on `master`.
   
   #### Which issue(s) this PR fixes:
   
   N/A
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to