Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-4729

Rest API does not accept commands to modify

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 6.4.6
    • N/A
    • REST-API
    • None

    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
      

      Attachments

        Activity

          markus makela markus makela added a comment - - edited

          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.

          markus makela markus makela added a comment - - edited 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.

          People

            Unassigned Unassigned
            edward Edward Stoever
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.