Skip to content

Changes are not synced to disk when modifying entries in regex map files.#398

@jmdelafe

Description

@jmdelafe

Using ?force_sync=yes when updating an entry in a map file loaded as a regex (map_reg), won't update the file on disk and it returns a 404. In-memory version (runtime) will be updated.

  1. State before running the update:
$ cat maps/paths.map ^/api apiservers ^/cart cartservers% $ echo "show map maps/paths.map" | socat stdio /tmp/admin.sock 0x104414cb0 ^/api apiservers 0x104414d10 ^/cart cartservers 
  1. Running update via Data Plane API. Notice the HTTP/1.1 404 Not Found
$ curl -v --request PUT \ --url 'http://127.0.0.1:5555/v3/services/haproxy/runtime/maps/paths.map/entries/%5E%2Fapi?force_sync=true' \ --header 'authorization: Basic YWRtaW46YWRtaW4=' \ --header 'content-type: application/json' \ --data '{"value": "newapiservers" }' * Trying 127.0.0.1:5555... * Connected to 127.0.0.1 (127.0.0.1) port 5555 > PUT /v3/services/haproxy/runtime/maps/paths.map/entries/%5E%2Fapi?force_sync=true HTTP/1.1 > Host: 127.0.0.1:5555 > User-Agent: curl/8.7.1 > Accept: */* > authorization: Basic YWRtaW46YWRtaW4= > content-type: application/json > Content-Length: 30 > * upload completely sent off: 30 bytes < HTTP/1.1 404 Not Found < Configuration-Version: 1 < Content-Type: application/json < Vary: Origin < Date: Fri, 19 Dec 2025 16:01:06 GMT < Content-Length: 0 < * Connection #0 to host 127.0.0.1 left intact 
  1. State after the update. notice how runtime shows the new (expected value)
$ echo "show map maps/paths.map" | socat stdio /tmp/admin.sock 0x104414cb0 ^/api newapiservers 0x104414d10 ^/cart cartservers $ cat maps/paths.map ^/api apiservers ^/cart cartservers% 
haproxy.cfg

global  stats socket /tmp/admin.sock mode777 level admin defaults defaults mode http frontend www from defaults  bind:8888# Choose which backend depending on the URL path use_backend%[path,map_reg(maps/paths.map,webservers)] default_backend webservers backend webservers from defaults  http-request return status 200 content-type "text/plain" lf-string "200 OK" hdr "X-Backend" "webservers" backend apiservers from defaults  http-request return status 200 content-type "text/plain" lf-string "200 OK" hdr "X-Backend" "apiservers" backend cartservers from defaults  http-request return status 200 content-type "text/plain" lf-string "200 OK" hdr "X-Backend" "cartservers"

dataplaneapi.yml

dataplaneapi: socket_path: ./data-plane.sock host: 127.0.0.1 port: 5555 pid_file: ./dataplaneapi.pid scheme: - http - unix transaction: transaction_dir: ./storage/transactions backups_number: 10 backups_dir: ./storage/backups resources: maps_dir: ./maps ssl_certs_dir: ./storage/ssl general_storage_dir: ./storage/general dataplane_storage_dir: ./storage/dataplane spoe_dir: ./storage/spoe spoe_transaction_dir: ./storage/transactions/spoe user: - name: admin insecure: true password: admin haproxy: config_file: ./haproxy.cfg haproxy_bin: /opt/homebrew/bin/haproxy reload: reload_strategy: systemd log_targets: - log_to: stdout log_level: debug log_format: text log_types: - app - access 

I didn't experience this when updating "regular" (or "literal) map files loaded with map directive.

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