Skip to content

Configuration parser is getting instances of lua-load-per-thread incorrectly #128

@jmdelafe

Description

@jmdelafe

As per HAproxy documentation, the directive can be used multiple times.

This global directive loads and executes a Lua file into each started thread.
Any global variable has a thread-local visibility so that each thread could
see a different value. As such it is strongly recommended not to use global
variables in programs loaded this way. An independent copy is loaded and
initialized for each thread, everything is done sequentially and in the
thread's numeric order from 1 to nbthread. If some operations need to be
performed only once, the program should check the "core.thread" variable to
figure what thread is being initialized. Programs loaded this way will run
concurrently on all threads and will be highly scalable. This is the
recommended way to load simple functions that register sample-fetches,
converters, actions or services once it is certain the program doesn't depend
on global variables. For the sake of simplicity, the directive is available
even if only one thread is used and even if threads are disabled (in which
case it will be equivalent to lua-load). This directive can be used multiple
times.

But the client seems to get only one of them when parsing the configuration.

Details when querying the structured config using the Data Plane API

# haproxy.conf
global
(...)
  tune.lua.bool-sample-conversion normal
  lua-load-per-thread /etc/haproxy/lua/ja4.lua
  lua-load-per-thread /etc/haproxy/lua/ja4h.lua
(...)

The config file is valid:

$ haproxy -f /etc/haproxy/haproxy.cfg -c && echo $?
0
$ curl -s --user admin:admin https://localhost:5555/v3/services/haproxy/configuration/global | jq '.lua_options'
{
  "load_per_thread": "/etc/haproxy/lua/ja4h.lua"
}

lua-load-per-thread shows defined as string per spec. https://github.com/haproxytech/client-native/blob/master/specification/models/configuration/global.yaml#L1214-L1215

And it seems to be constructed parsing the last entry in the configuration file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions