[MXS-4729] Rest API does not accept commands to modify Created: 2023-08-24  Updated: 2023-09-04  Resolved: 2023-08-25

Status: Closed
Project: MariaDB MaxScale
Component/s: REST-API
Affects Version/s: 6.4.6
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Edward Stoever Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None

Attachments: PNG File KB_Maxscale_modifying_data.png    

 Description   

Rest API does not work according to documentation to change a server to maintenance state.
Test #1

root@mxscl:~$ maxctrl list servers
┌─────────┬───────────────┬──────┬─────────────┬───────────────────────────────────┬─────────────┐
│ Server  │ Address       │ Port │ Connections │ State                             │ GTID        │
├─────────┼───────────────┼──────┼─────────────┼───────────────────────────────────┼─────────────┤
│ serverA │ 192.168.8.157 │ 3306 │ 0           │ Master, Running                   │ 0-1-3192705 │
├─────────┼───────────────┼──────┼─────────────┼───────────────────────────────────┼─────────────┤
│ serverB │ 192.168.8.158 │ 3306 │ 0           │ Running, Slave of External Server │ 0-1-3192705 │
└─────────┴───────────────┴──────┴─────────────┴───────────────────────────────────┴─────────────┘
root@mxscl:~$ curl -X PUT -d '{"data": {"id": "serverB", "type": "servers", "attributes": { "state": "Maintenance" } } }' http://127.0.0.1:8989/v1/servers/serverB
root@mxscl:~$ maxctrl list servers
┌─────────┬───────────────┬──────┬─────────────┬───────────────────────────────────┬─────────────┐
│ Server  │ Address       │ Port │ Connections │ State                             │ GTID        │
├─────────┼───────────────┼──────┼─────────────┼───────────────────────────────────┼─────────────┤
│ serverA │ 192.168.8.157 │ 3306 │ 0           │ Master, Running                   │ 0-1-3192717 │
├─────────┼───────────────┼──────┼─────────────┼───────────────────────────────────┼─────────────┤
│ serverB │ 192.168.8.158 │ 3306 │ 0           │ Running, Slave of External Server │ 0-1-3192717 │
└─────────┴───────────────┴──────┴─────────────┴───────────────────────────────────┴─────────────┘
root@mxscl:~$

Test #2

root@mxscl:~$ curl 127.0.0.1:8989/v1/servers/serverB > serverB.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8749  100  8749    0     0  4271k      0 --:--:-- --:--:-- --:--:-- 8543k
root@mxscl:~$ perl -p -i -e "s/Running/Maintenance/g" serverB.txt
root@mxscl:~$ grep Maintenance serverB.txt
            "state": "Maintenance",
root@mxscl:~$ curl -X PATCH -d @serverB.txt http://127.0.0.1:8989/v1/servers/serverB
root@mxscl:~$ maxctrl list servers
┌─────────┬───────────────┬──────┬─────────────┬───────────────────────────────────┬─────────────┐
│ Server  │ Address       │ Port │ Connections │ State                             │ GTID        │
├─────────┼───────────────┼──────┼─────────────┼───────────────────────────────────┼─────────────┤
│ serverA │ 192.168.8.157 │ 3306 │ 0           │ Master, Running                   │ 0-1-3192420 │
├─────────┼───────────────┼──────┼─────────────┼───────────────────────────────────┼─────────────┤
│ serverB │ 192.168.8.158 │ 3306 │ 0           │ Running, Slave of External Server │ 0-1-3192420 │
└─────────┴───────────────┴──────┴─────────────┴───────────────────────────────────┴─────────────┘
root@mxscl:~$

These commands will work:

curl -X PUT http://127.0.0.1:8989/v1/servers/serverB/set?state=maintenance
curl -X PUT http://127.0.0.1:8989/v1/servers/serverB/clear?state=maintenance



 Comments   
Comment by markus makela [ 2023-08-25 ]

The PATCH serves documentation states:

In addition to the server parameters, the services and monitors fields of the relationships object can be modified. Removal, addition and modification of the links will change which service and monitors use this server.

The state of a server is not a parameter as it is based on whether the server is up or not. On the same page there is documentation for the servers/:id/set endpoint that explains to modify the server state.

This was never intended to work and is documented to not work. Making it work like this would make it so that a modification to a server's parameters could inadvertently roll back the server's state to an older one causing errors, potential loss of data or all sorts of other problems that happen when stuff gets routed to the wrong node.

Generated at Thu Feb 08 04:30:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.