]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: hlua: add option to preserve bool type from smp to lua
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 19 Dec 2024 11:32:10 +0000 (12:32 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 19 Dec 2024 12:50:27 +0000 (13:50 +0100)
commitec744382739d24681b7ccd08dd57ee9606870bc5
treef0848ceb0cc6facb4d82e92a7533b44620605673
parent67e3270c59f4cb997f2078d395d365e0189326ba
MINOR: hlua: add option to preserve bool type from smp to lua

As discussed in GH #2814, there is an ambiguity in hlua implementation
that causes haproxy smp boolean type to be pushed as an integer on the
Lua stack. On the other hand, when doing Lua to haproxy smp conversion,
the boolean type is properly perserved. Of course this situation is not
desirable and can lead to unexpected results. However we cannot simply
fix the behavior because in Lua boolean and integer types are not
are completely distinct types and cannot be used interchangeably. So in
order to prevent breaking existing scripts logic, in this patch we add a
dedicated lua tunable named "tune.lua.smp-preserve-bool" which can take
the following values:

  - "on" : when converting haproxy smp to lua, boolean type is preserved
  - "off": when converting haproxy smp to lua, boolean is converted to
           integer (legacy behavior)

For now, the tunable defaults to "off" to preserve historical behavior.
However, when the option isn't set explicitly and lua is used, a warning
will be emitted in order to raise user's awareness about this ambiguity.
It is expected that the tunable could default to "on" in future versions,
thus it is recommended to avoid setting it to "off" except when using
existing Lua scripts that still rely on the old behavior regarding boolean
smp to Lua conversion, and that they cannot be fixed easily.

This should solve issue GH #2814. It may be relevant to backport this in
haproxy 3.1.
doc/configuration.txt
src/hlua.c