142 Commits

Author SHA1 Message Date
Markus Mäkelä
1743f4c1b7 Handle server repurposing under a lock
By moving the repurposing of the servers under the global server lock, the
repurposing of a server and allocation of a new server behave in the same
way.

Also fixed the wrong error message on server creation failure referring to
invalid server relationships.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
e133e758a6 MXS-1300: Fix deletion of monitors
The monitors should only be reused if they have the same name and they use
the same module. This way the only difference is in configuration.

Fixed MaxCtrl detection of bad options and altered monitor creation test
to expect correct results. Also improved some of the error messages.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
af847c29c3 Improve runtime configuration error messages
The error messages are now more specific and describe in detail what is
wrong in the request.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
512c3c018d Add recycling of destroyed monitors
If a destroyed monitor is created again, it will be reused. This should
prevent excessive memory growth when the same monitor is created and
destroyed again.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
03b00c7746 Fix error message for unknown global parameter
When an unknown global parameter was modified, the error message
mistakenly logged onl the value of the parameter instead of the name and
value.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
d515094646 Return error on bad service parameter alteration
When a service parameter is being altered and it is not in the list of
dynamic parameters, the alteration function returns an error.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
de546a0356 MXS-1220: Validate integer values for alter operations
All of the alter operations weren't properly validating the integer
parameters. This appeared to the client as successful modifications of
parameters with bad value.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
46339d620a MXS-1220: Interpret no relationships as old relationships
When a PATCH request to a resource is made with no relationships defined,
it should be interpreted to be the same as the old relationships. Removal
of relationships can still be done by defining an empty relationships
object.
2017-07-10 22:23:48 +03:00
Markus Mäkelä
b0f2d02787 MXS-1300: Add link/unlink command to MaxCtrl
The link/unlink commands are similar to the add/remove commands in
MaxAdmin but they link services and monitors to a list of servers instead
of linking servers to a list of either services or monitors. This can
reduce the number of required calls to alter the configuration while
making the process easier for MaxCtrl to do via the REST API.

Also fixed a false negative where a service alteration which results in a
no-op would be counted as an error.
2017-07-10 22:23:47 +03:00
Markus Mäkelä
35745ee925 MXS-1220: Add deletion of listeners
The listeners can now be deleted via the REST API. Documented the added
endpoint in the REST API documentation.
2017-07-10 22:23:46 +03:00
Markus Mäkelä
63d2eee0e3 MXS-1220: Add endpoint for set/clear of server status
The server status can now be manipulated via the REST API. Added tests for
the state manipulation. Fixed minor issues in related code.
2017-07-10 22:23:44 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
6b8b19b439 MXS-1220: Add PUT support for /maxscale/ resource
The /maxscale/ resource now supports PUT requests which modify core
parameters. As not all parameters can be changed at runtime, only
modifications to parameters that support runtime configuration are
allowed.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
3fd82ebae6 MXS-1220: Add alter maxscale MaxAdmin command
A set of the core MaxScale parameters can now be altered at runtime. This
set consists of the authentication timeouts and the admin interface
authentication. Other parameters either can't be modified due to internal
limitations or aren't sensible to modify at runtime.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
1067fd352c MXS-1220: Add creation and deletion of admin users
Admin users can now be created via the REST API. This allows remote
management of the administrative interface itself.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
db78eae9a8 MXS-1220: Use thread-local buffer for errors
The runtime error buffer is now a thread-local buffer. This fixes the
build failure on older systems where the compiler doesn't allow
thread-local non-POD objects to be created.

Also expanded some of the JSON validation functions so that they provide
better errors.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
e3c4bd7f72 MXS-1220: Add more validation checks to request JSON
The requests that send a body should define at least a `data` member.

Added a simple test that checks that bad requests are rejected. This test
should be expanded to check that the returned error body contains the
correct members.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
f1c790db52 MXS-1220: Add logging priorities to logs resoure
The logging priorities can now be queried and altered.
2017-05-17 10:14:57 +03:00
Markus Mäkelä
05cb49d48a MXS-1220: Add error messages to bad request
Requests now contain a JSON API-conforming, human-readable error message.
2017-05-17 10:14:57 +03:00
Markus Mäkelä
ffc6dba720 MXS-1220: Fix error on PUT request with no parameters
Whena server was modified and no parameters were given, the operation was
reported as a failure even though it was successful.
2017-05-14 10:06:02 +03:00
Markus Mäkelä
c30b817abc MXS-1220: Add warnings for invalid request JSON
Converted info level log messages to warnings and added a missing warning
to server creation.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
461cd6afd9 MXS-1220: Add creation of listeners via REST API
Listeners can now be created via the REST API by doing a POST request to
the service listener resource.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
a384665141 MXS-1220: Allow modification of logging options
The logging options can now be modified with a PUT request.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
18b52adaeb MXS-1220: Fix minor bug in monitor creation
The JSON validation function wasn't using the JSON Pointer function for
all values.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
c1968aac2f MXS-1220: Migrate create/update monitor to JSON API format
The creation and modification of moitor now supports the JSON API
conforming format generated by the GET endpoints.

Also added tests for creating and altering monitors via the REST API.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
6c220a1151 MXS-1220: Migrate create/update server to JSON API format
The creation and modification of servers now supports the JSON API
conforming format generated by the GET endpoints.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
af2a4e792f MXS-1220: Process monitor parameters on resource creation
When a monitor is created, any parameters given to it are immediately
processed. This is done by processing the initial request as if it were an
update to the monitor that was just created.

Changed the order in which servers are linked to objects. The old
relations are removed first and only after that are the new relations
added. This fixed a problem when the monitor which monitors a server was
being changed.

Also fixed a few minor bugs.
2017-05-04 09:17:50 +03:00
Markus Mäkelä
fdf279265a MXS-1220: Fix minor bugs
Destroyed servers were still shown as a part of the servers resource
collection.

If a parameter defined in persisted configurations was replaced, the value
would be appended to itself after it was replaced.

Return correct error codes for internal errors.

The server check was checking for old parameter locations.
2017-05-04 09:17:50 +03:00
Markus Mäkelä
d248c7e081 MXS-1220: Add PUT support for services
Service parameters can now be altered with a PUT request to the REST
API. This allows general level parameters to be altered.

Module specific parameters need to be altered with a different mechanism,
namely the module command system. This requires that a generic way to call
a function needs to be devised.
2017-05-04 09:17:49 +03:00
Markus Mäkelä
d282b14b36 Allow runtime changes to service parameters
General service parameters can now be altered at runtime.
2017-05-04 09:17:49 +03:00
Markus Mäkelä
f7fefad2e6 Improve persisted configuration handling
When a persisted configuration file is read, the values in it are
considered to be more up-to-date than the ones in the main configuration
file. This allows all objects to be persisted in a more complete form
making it easier to change configuration values at runtime.

This change is intended to help make runtime alterations to services
possible.
2017-05-04 09:17:49 +03:00
Markus Mäkelä
1e1c4abcb7 MXS-1220: Add PUT support for monitors
Monitor resources can now be altered with a PUT request. The method allows
alterations on all parameters that the maxadmin `alter monitor` command
allows.
2017-05-04 09:17:48 +03:00
Markus Mäkelä
bab7957952 MXS-1220: Only process updated server parameters
The alteration function is only called when the value of a parameter
changes. This removes some of the redundant logging that was caused by
calling the alteration function with the same values.
2017-05-04 09:14:04 +03:00
Markus Mäkelä
043ed95bdf MXS-1220: Add PUT support for servers
The server can now be modified with a PUT request of a modified server
resource. The server resource was reorganized to have the parameters as a
separate entity from the other more general entities of the resource.

The PUT/POST functions return a more appropriate error message when no
request body is provided.

Moved some of the constant names used in server.cc into the config.h
header.
2017-05-04 09:14:04 +03:00
Markus Mäkelä
1e55ee5b2f Add more common constants
Now all relevant and working core configuration parameters have constants
for their names. This removes some of the risk that comes with the
repetition of the same parameter name in more than place.
2017-05-04 09:14:04 +03:00
Markus Mäkelä
695a4032ca Use common constants for monitor and server parameters
The parameter names for monitors and servers now use a set of constant
names. This removes some of the errors caused by spelling mistakes when
the same parameter name is repeated in multiple places.

The service, filter and listener parameters should also be converted to
constants. This allows for a consistent user experience.
2017-05-04 09:14:04 +03:00
Markus Mäkelä
9aa4138705 MXS-1220: Add POST handling for monitors
Doing a POST on the /monitors/ resource now creates a new monitor.
2017-05-04 09:14:03 +03:00
Markus Mäkelä
80104d6dad MXS-1220: Add POST handling for servers
New servers can now be created by POSTing a new server definition to the
/servers/ resource.
2017-05-04 09:14:03 +03:00
Markus Mäkelä
ad1c05b015 Merge branch '2.1' into develop 2017-04-05 11:35:13 +03:00
Esa Korhonen
a362bd0024 Add parameter backend_connect_attempts to monitor
This number (defaults to 1) sets how many times mon_connect_to_db
will try to connect to a backend before returning an error. Every
connection attempt may take backend_connect_timeout seconds to
complete.

Also refactored code a bit. Renamed mon_connect_to_db to
mon_ping_or_connect_to_db, since it does not connect if the connection
is already alive.
2017-04-03 09:56:22 +03:00
MassimilianoPinto
8e24f847e6 Fix compile errors in Centos 6
Fix compile errors in Centos 6
2017-03-27 09:49:21 +02:00
Johan Wikman
71ae3cf524 Compile config_runtime.c as C++ 2017-03-24 09:21:20 +02:00