haproxy/reg-tests/server/get_srv_stats.lua
Amaury Denoyelle 14c3c5c121 MEDIUM: server: allow to remove servers at runtime except non purgeable
Relax the condition on "delete server" CLI handler to be able to remove
all servers, even non dynamic, except if they are flagged as non
purgeable.

This change is necessary to extend the use cases for dynamic servers
with reload. It's expected that each dynamic server created via the CLI
is manually commited in the haproxy configuration by the user. Dynamic
servers will be present on reload only if they are present in the
configuration file. This means that non-dynamic servers must be allowed
to be removable at runtime.

The dynamic servers removal reg-test has been updated and renamed to
reflect its purpose. A new test is present to check that non-purgeable
servers cannot be removed.
2021-08-25 15:53:54 +02:00

12 lines
274 B
Lua

local function lua_get_srv_stats(txn, name)
for _, backend in pairs(core.backends) do
for _, server in pairs(backend.servers) do
if server.name == name then
return server:get_stats()
end
end
end
end
core.register_fetches('get_srv_stats', lua_get_srv_stats)