Open git001 opened 7 months ago
Hi, can you paste the output of: /data/haproxy/etc/dataplaneapi.yaml
?
that's it
$ cat /data/haproxy/etc/dataplaneapi.yaml
config_version: 2
name: craftcms-hap-debug
mode: single
status: ""
dataplaneapi:
advertised:
api_address: ""
api_port: 0
haproxy:
reload:
reload_strategy: custom
Maybe there is another issue and the message above hides the original problem. As OpenShift restricts the Pod run environment could the socket call fail.
Which, I think, is called from here.
Hi @git001, thanks for your input, but the bug is in the dataplaneapi code, it picks up the master socket location from a env variable set by the HAProxy: https://github.com/haproxytech/dataplaneapi/blob/master/configure_data_plane.go#L121 and it doesn't properly sanitize the socket location (doesn't remove sockpair@
suffix added by the latest versions of HAProxy). We can fix this, or you could give it a shot if that is interesting for you.
@mjuraga thanks for the tip. I will try to fix it with a PR
I have now fixed the sockpair@
bug with this code.
...
// Override options with env variables
if os.Getenv("HAPROXY_MWORKER") == "1" {
mWorker = true
masterRuntime := os.Getenv("HAPROXY_MASTER_CLI")
if misc.IsUnixSocketAddr(masterRuntime) {
fmt.Printf("before Replace masterRuntime :%v:\n", masterRuntime)
if strings.HasPrefix(masterRuntime, "unix@") {
haproxyOptions.MasterRuntime = strings.Replace(masterRuntime, "unix@", "", 1)
if strings.Contains(haproxyOptions.MasterRuntime, "sockpair@") {
semikolon := strings.Index(haproxyOptions.MasterRuntime, ";")
haproxyOptions.MasterRuntime = haproxyOptions.MasterRuntime[:semikolon]
}
}
fmt.Printf("after Replace masterRuntime :%v:\n", haproxyOptions.MasterRuntime)
}
}
...
From the output below is shown that the socketpair
is gone.
before Replace masterRuntime :unix@/data/haproxy/run/master-socket;sockpair@7:
after Replace masterRuntime :/data/haproxy/run/master-socket:
The problem with the SIGTERM
is still there.
haproxy -f /data/haproxy/etc/haproxy.cfg -db -W -S /data/haproxy/run/master-socket
[NOTICE] (9) : New program 'api' (11) forked
[NOTICE] (9) : New worker (12) forked
[NOTICE] (9) : Loading success.
[WARNING] (12) : fcgi-servers/craftcms1 changed its IP from (none) to 10.129.2.11 by kube-dns/dns1.
fcgi-servers/craftcms1 changed its IP from (none) to 10.129.2.11 by kube-dns/dns1.
[WARNING] (12) : Server fcgi-servers/craftcms1 ('craftcms-php.craftcms.svc.cluster.local') is UP/READY (resolves again).
Server fcgi-servers/craftcms1 ('craftcms-php.craftcms.svc.cluster.local') is UP/READY (resolves again).
[WARNING] (12) : Server fcgi-servers/craftcms1 administratively READY thanks to valid DNS answer.
Server fcgi-servers/craftcms1 administratively READY thanks to valid DNS answer.
configuration file /data/haproxy/etc/dataplaneapi.yaml does not exists, creating one
time="2024-04-03T11:26:23Z" level=info msg="HAProxy Data Plane API .dev.dirty"
time="2024-04-03T11:26:23Z" level=info msg="Reload strategy: custom"
time="2024-04-03T11:26:23Z" level=info msg="Build from: "
time="2024-04-03T11:26:23Z" level=info msg="Build date: 2024-04-03T11:23:50Z"
before Replace masterRuntime :unix@/data/haproxy/run/master-socket;sockpair@7:
after Replace masterRuntime :/data/haproxy/run/master-socket:
Command Successfully Executed
srwxr-xr-x. 1 1000950000 root 0 Apr 3 11:26 /data/haproxy/run/master-socket
ms :{/data/haproxy/run/master-socket 1}: masterSocket :/data/haproxy/run/master-socket: mapsDir :{/data/haproxy/maps}:
[NOTICE] (9) : haproxy version is 2.9.6-9eafce5
[NOTICE] (9) : path to executable is /usr/local/sbin/haproxy
[ALERT] (9) : Current program 'api' (11) exited with code 1 (Exit)
[ALERT] (9) : exit-on-failure: killing every processes with SIGTERM
[ALERT] (9) : Current worker (12) exited with code 143 (Terminated)
[WARNING] (9) : All workers exited. Exiting... (1)
As mentioned in https://github.com/haproxytech/dataplaneapi/issues/329#issuecomment-2034014921 could it be that the socket call in client-native be another issue?
For test could you try running dpapi standalone, without running from the program section.
Any chance to merge the PR https://github.com/haproxytech/dataplaneapi/pull/330 ?
Introduction
I try to run haproxy in front of craftcms and want to use the Data Plane API for management.
Data Plane API infos
This is the dataplane api version.
Due to the fact that the trace output of the dataplaneapi binary was not very helpful have I added this lines to the code which creates the output below.
original code https://github.com/haproxytech/dataplaneapi/blob/14ab8aa5d85a3f697d5a0a44ce10c11335cc92de/client-native/cn.go#L95-L103
my "patch"
That's the output when I run the HAProxy with the dataplane api
My observations
This line confuses me
because the
ls
before the commandruntime_api.New(...)
shows that the socket is there.and I can execute the help command on the master socket
My assumption is that dataplaneapi tries to connect to
/data/haproxy/run/master-socket;sockpair@7
which of course does not exist.haproxy infos
haproxy run
This is how the haproxy is started.
haproxy config
Output of haproxy -vv
Dockerfile
That's the Dockerfile of the image.