dataplaneapi icon indicating copy to clipboard operation
dataplaneapi copied to clipboard

HAProxy 2.3.3+ Issues Loading Lua Config Elements

Open MillsyBot opened this issue 4 years ago • 4 comments

Hello HAP Friends,

I was in the process of updating our HAProxy from 2.3.2 to 2.3.3+ and we are unable to enable DataplaneAPI in the new version.

Here is the error that is returned

[NOTICE] 012/203734 (110) : New program 'api' (111) forked
[NOTICE] 012/203734 (110) : New program 'mirror' (112) forked
[NOTICE] 012/203734 (110) : New worker #1 (114) forked
time="2021-01-13T20:37:34Z" level=info msg="HAProxy Data Plane API v2.1.0 af9b8e4"
time="2021-01-13T20:37:34Z" level=info msg="Build from: [email protected]:haproxytech/dataplaneapi.git"
time="2021-01-13T20:37:34Z" level=info msg="Build date: 2020-07-16T12:44:20Z"
time="2021-01-13T20:37:34Z" level=fatal msg="Error initializing configuration client: error setting up configuration client: 41: Cannot read lua.unrecognized_hostname"

DataplaneAPI

root@7a80ab3b15d5:/haproxy# /haproxy/bin/dataplaneapi -vv
HAProxy Data Plane API v2.1.0 af9b8e4

Build from: [email protected]:haproxytech/dataplaneapi.git
Build date: 2020-07-16T12:44:20Z

HAProxy Version

root@7a80ab3b15d5:/haproxy# /haproxy/bin/haproxy -vv
HA-Proxy version 2.3.4-10189c9 2021/01/13 - https://haproxy.org/
Status: stable branch - will stop receiving fixes around Q1 2022.
Known bugs: http://www.haproxy.org/bugs/bugs-2.3.4.html
Running on: Linux 4.19.121-linuxkit #1 SMP Tue Dec 1 17:50:32 UTC 2020 x86_64
Build options :
  TARGET  = linux-glibc
  CPU     = generic
  CC      = cc
  CFLAGS  = -O2 -g -Wall -Wextra -Wdeclaration-after-statement -fwrapv -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wno-missing-field-initializers -Wtype-limits -Wshift-negative-value -Wshift-overflow=2 -Wduplicated-cond -Wnull-dereference
  OPTIONS = USE_OPENSSL=1 USE_LUA=1 USE_TFO=1
  DEBUG   =

Feature list : +EPOLL -KQUEUE +NETFILTER -PCRE -PCRE_JIT -PCRE2 -PCRE2_JIT +POLL -PRIVATE_CACHE +THREAD -PTHREAD_PSHARED +BACKTRACE -STATIC_PCRE -STATIC_PCRE2 +TPROXY +LINUX_TPROXY +LINUX_SPLICE +LIBCRYPT +CRYPT_H +GETADDRINFO +OPENSSL +LUA +FUTEX +ACCEPT4 -CLOSEFROM -ZLIB -SLZ +CPU_AFFINITY +TFO +NS +DL +RT -DEVICEATLAS -51DEGREES -WURFL -SYSTEMD -OBSOLETE_LINKER +PRCTL +THREAD_DUMP -EVPORTS

Default settings :
  bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Built with multi-threading support (MAX_THREADS=64, default=16).
Built with OpenSSL version : OpenSSL 1.1.1i  8 Dec 2020
Running on OpenSSL version : OpenSSL 1.1.1  11 Sep 2018
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : TLSv1.0 TLSv1.1 TLSv1.2 TLSv1.3
Built with Lua version : Lua 5.3.6
Built with network namespace support.
Built with the Prometheus exporter as a service
Built without compression support (neither USE_ZLIB nor USE_SLZ are set).
Compression algorithms supported : identity("identity")
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Built without PCRE or PCRE2 support (using libc's regex instead)
Encrypted password support via crypt(3): yes
Built with gcc compiler version 7.5.0

Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.

Available multiplexer protocols :
(protocols marked as <default> cannot be specified using 'proto' keyword)
              h2 : mode=HTTP       side=FE|BE     mux=H2
            fcgi : mode=HTTP       side=BE        mux=FCGI
       <default> : mode=HTTP       side=FE|BE     mux=H1
       <default> : mode=TCP        side=FE|BE     mux=PASS

Available services : prometheus-exporter
Available filters :
	[SPOE] spoe
	[CACHE] cache
	[FCGI] fcgi-app
	[COMP] compression
	[TRACE] trace

Config

global 
  master-worker
  maxconn 500000
  hard-stop-after 30s
  pidfile /haproxy/run/pid
  stats socket /haproxy/run/haproxy.sock mode 600 expose-fd listeners level admin
  tune.ssl.default-dh-param 2048
  log /haproxy/run/access_log format raw local0
  lua-load /haproxy/lua/healthcheck.lua
  lua-load /haproxy/lua/static_response.lua
  server-state-file /haproxy/run/server-state

Lua Code

unrecognized_hostname = function(applet)
    local response = "Not Found."
    applet:set_status(404)
    applet:add_header("content-length", string.len(response))
    applet:add_header("content-type", "text/plain")
    applet:add_header("cache-control", "no-cache, no-store")
    applet:add_header("x-rblx-origin", "lb")
    applet:add_header("connection", "close")
    applet:start_response()
    applet:send(response)
end

core.register_service("unrecognized_hostname", "http", unrecognized_hostname)

MillsyBot avatar Jan 13 '21 20:01 MillsyBot

Looks like it is tied to permissions issues. However, based on the unclear logging, I am not certain.

MillsyBot avatar Jan 22 '21 18:01 MillsyBot

Hey, same here with HAProxy >= 2.2.7:

time="2021-02-08T16:02:31Z" level=fatal msg="Error initializing configuration client: error setting up configuration client: 41: Cannot read lua.maintenance_disable"

I use Docker image and my conf work fine with haproxy:2.2.6-alpine

william-p avatar Feb 08 '21 16:02 william-p

just want to mention #199 here because they might be related

c-nv-s avatar Jun 20 '21 23:06 c-nv-s

To me it seems as an HAProxy issue, meaning that haproxy cannot start with the given configuration file. Can you test just starting of haproxy process with this haproxy.cfg to see if it works?

mjuraga avatar Jul 27 '21 14:07 mjuraga