Skip to content

Load restapi_routes from config into runtime on startup#5467

Draft
Copilot wants to merge 4 commits intov3.0from
copilot/feature-load-restapi-routes-config
Draft

Load restapi_routes from config into runtime on startup#5467
Copilot wants to merge 4 commits intov3.0from
copilot/feature-load-restapi-routes-config

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

restapi_routes defined in proxysql.cnf were parsed inconsistently and did not support the config shape used in deployment manifests, which left runtime_restapi_routes empty after startup. This change aligns REST API route loading with the expected config format and startup behavior used by other config-backed sections.

  • Config parsing

    • Accepts restapi_routes as a config section, while preserving support for the legacy restapi section.
    • Allows config-defined REST API routes to omit id, matching the common SQL workaround and letting SQLite assign it.
  • Runtime startup behavior

    • Makes config-file route definitions usable at startup by ensuring they are inserted into restapi_routes in the shape expected by the existing runtime load path.
  • Safety hardening in the touched path

    • Escapes route string fields before inserting into SQLite.
    • Adds allocation checks and bounded formatting in the config import path.
  • Coverage

    • Extends config-load validation coverage to include LOAD RESTAPI FROM CONFIG.
    • Adds a startup-focused TAP test that launches a secondary ProxySQL instance from config and verifies runtime_restapi_routes is populated.

Example config now supported directly:

restapi_routes=
(
    {
        active=1
        timeout_ms=5000
        method="GET"
        uri="healthz"
        script="/etc/proxysql/probe.bash"
        comment="health check"
    }
)

With this format, the route is loaded into restapi_routes from config and becomes available in runtime_restapi_routes on startup.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.mysql.com
    • Triggering command: /usr/bin/curl curl -C - -O -s REDACTED (dns block)
    • Triggering command: /usr/bin/wget wget -nc -q REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature request: Load restapi_routes from config file</issue_title>
<issue_description>## Summary

restapi_routes defined in the ProxySQL config file (proxysql.cnf) are parsed but NOT loaded into runtime on startup. This requires users to manually execute INSERT INTO restapi_routes + LOAD RESTAPI TO RUNTIME via the admin interface after ProxySQL starts.

Other config sections like mysql_query_rules, mysql_servers, mysql_users, mysql_aws_aurora_hostgroups, and scheduler are all automatically loaded from the config file to runtime on startup. It would be consistent and convenient if restapi_routes followed the same pattern.

Steps to Reproduce

  1. Add restapi_routes section to proxysql.cnf:
restapi_routes=
(
    {
        active=1
        timeout_ms=5000
        method="GET"
        uri="healthz"
        script="/etc/proxysql/probe.bash"
        comment="health check"
    }
)
  1. Start ProxySQL with --reload:
proxysql --config /etc/proxysql/proxysql.cnf -f --reload
  1. Check runtime:
SELECT * FROM runtime_restapi_routes;
-- Returns empty result set
  1. The REST API endpoint returns:
{"error":"The script for method [GET] and route [/sync/healthz] was not found. Rows count returned [0]"}

Expected Behavior

restapi_routes defined in the config file should be automatically loaded into runtime on startup, just like mysql_query_rules, scheduler, and other config sections.

Current Workaround

Execute SQL via admin interface after ProxySQL starts:

INSERT INTO restapi_routes (active, timeout_ms, method, uri, script, comment)
VALUES (1, 5000, 'GET', 'healthz', '/etc/proxysql/probe.bash', 'health check');
LOAD RESTAPI TO RUNTIME;

Environment

  • ProxySQL version: 3.0.6
  • OS: Kubernetes (proxysql/proxysql:3.0.6 Docker image)
  • Config: Using --reload flag

Use Case

In Kubernetes deployments, health checks rely on REST API routes. Having to use an init script to register routes adds complexity to the deployment. Declarative config would simplify Helm charts and reduce startup failure modes.</issue_description>

<agent_instructions>We need to implement this feature. Also include extensive testing</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 3 commits March 20, 2026 21:46
Co-authored-by: renecannao <3645227+renecannao@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sysown/proxysql/sessions/40d309f0-bd3d-4616-9cd6-fa7d8f1cb355
Co-authored-by: renecannao <3645227+renecannao@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sysown/proxysql/sessions/40d309f0-bd3d-4616-9cd6-fa7d8f1cb355
Co-authored-by: renecannao <3645227+renecannao@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sysown/proxysql/sessions/40d309f0-bd3d-4616-9cd6-fa7d8f1cb355
Copilot AI changed the title [WIP] Add functionality to load restapi_routes from config file Load restapi_routes from config into runtime on startup Mar 20, 2026
Copilot AI requested a review from renecannao March 20, 2026 21:53
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Load restapi_routes from config file

2 participants