haproxytech / dataplaneapi

HAProxy Data Plane API
https://www.haproxy.com/documentation/dataplaneapi/
Apache License 2.0
326 stars 76 forks source link

API: map: Cannot add new entries in existing file. #236

Open ghost opened 2 years ago

ghost commented 2 years ago

Hello,

I have a strange issue with the map handler. When I try to add a new entrie in existing file on my server, I have the following result :

Request & Body :

# curl -X POST http://haproxy-prod-tools-01/v2/services/haproxy/runtime/maps_entries?map=test&force_sync=true
{
    "key": "my_key",
    "value": "my_value"
}

Result :

{"code":404,"message":"/etc/haproxy/maps/test.map not found"}

image

I tried with empty file or not, adding custom path in dataplaneapi configuration, updating access on file and the result was the same 404.

This is my misstake or this a real issue ?

HAProxy version 2.5.0 HAProxy Data Plane API v2.3.0

mjuraga commented 2 years ago

Hi, does the dataplaneapi have the correct permissions on that file?

hujiko commented 2 years ago

Hey,

we experience the same issue.

What we discovered: When we create the map files by hand and then try and fill them through dataplaneapi, we see this error. When we create the map files through the dataplane-api, they work alright.

root@myMachine:/etc/haproxy/maps# ls -lha
drwxr-x--- 2 root root 4.0K Jul 22 16:06 .
drwxr-xr-x 6 root root 4.0K Jul 25 12:49 ..
-rw-r--r-- 1 root root 1.6K Jul 12 18:09 routing-main-preview.map
-rw-r--r-- 1 root root    0 May 23 11:05 routing.map

routing.map was created by hand, routing-main-preview.map through the dataplaneapi. Both have the same owner, group and permissions. (Unless the dataplaneapi sets some special xattrs when creating a map file, but I am lacking this in documentation)