406 Commits

Author SHA1 Message Date
Markus Mäkelä
e627740777 MXS-1354: Enable muting of admin interface authentication failures
The warnings generated by the admin interface can now be silenced.
2017-08-18 10:28:20 +03:00
Markus Mäkelä
2430f1b6b1 Fix message about journal_max_age default value
The monitor and parameter names were the wrong way around and the message
stated the value was in milliseconds when in fact it is in seconds.
2017-08-16 13:26:46 +03:00
Johan Wikman
49ba1f8fa0 MXS-1360 Add 'thread_stack_size' configuration value
Using the 'thread_stack_size' configuration value, the stack size
of the worker threads can be adjusted.
2017-08-14 15:31:00 +03:00
Markus Mäkelä
b448b129d0 MXS-1262: Move journal_max_age to MaxScale core
The parameter is now defined in the monitor. Further refactoring is needed
to make the interface of the journal system simpler.
2017-08-11 04:09:08 +03:00
Markus Mäkelä
c2a2688b93 Fix duplicate listener checks
Only the protocol, port and address of the listener were used to check if
a listener exists. The check should also use the name of the listener to
be sure that each name is unique.

Expanded tests to check that the creation of duplicate listeners is
detected. Did minor improvements to related test code.
2017-08-09 11:39:25 +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
Esa Korhonen
8e9c943d48 Proxy protocol setting error detection + documentation
The setting parsing is now similar to the other server settings.
The header is printed if log_info is on.
Changed the setting name to simply "proxy_protocol".
Updated documentation.
2017-08-04 11:43:29 +03:00
Markus Mäkelä
854c4a1ed3 Add support for non-glibc systems
MaxScale can now be built on systems that use an alternative libc
implementation e.g. musl.
2017-08-02 11:51:55 +03:00
Markus Mäkelä
c7b9b7ac4a MXS-1220: Unify resource member naming
All resoures now use the `state` member to describe their internal
state. This includes servers, services and monitors. This means that the
`status` keyword can be reserved for something else and it can be removed
until it is needed again.

Changed the module maturity field to `maturity` to better describe its
purpose.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
61241f9e07 Remove old feedback system
The feedback system wasn't used and was starting to cause problems on
Debian 9 where the libcurl required different version of OpenSSL than what
MaxScale was linked against.
2017-07-10 16:03:50 +03:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02:00
Esa Korhonen
14bb6cf99b Add convenience functions for common tasks with regular expressions
Several filters use a match-or-ignore logic with two regular
expressions when filtering queries. This commit adds a convenience
function for this task. Also adds a convenience function for reading
several regular expression parameters at once, compiling them and
saving the code while checking for errors.

Also, use the new functions in QLA and CCR filters.
2017-06-28 13:26:52 +03:00
Markus Mäkelä
4a298b4024 Return NULL if no regex parameter is defined
If no regex type parameters are defined and a compiled pattern is
requested, the function will return a NULL value. This allows code that
directly calls the config_get_compiled_regex function to work without
doing additional checks for the presence of optional parameters.
2017-06-21 10:13:47 +03:00
Esa Korhonen
39c6328e9b Refactor config_get_compiled_regex_capcount()
The function now returns the compiled code or null or error. Also,
instead of capcount, it writes the ovector size. The ovector pointer
can be null. Removed the other config_get_compiled_regex()-function
and replaced it with the refactored function since they are almost
identical.
2017-06-12 10:56:00 +03:00
Markus Mäkelä
2778056212 MXS-1220: Enable admin authentication by default
The admin interface now uses HTTP BA authentication by default. This will
prevent unrestricted access to the REST API but the authentication is by
no means secure and the HTTPS mode for the REST API should be enabled for
all production systems.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
b3c1e15f22 MXS-1220: Add output for module commands
The module commands can now produce JSON formatted output which is passed
to the caller. The output should conform to the JSON API as closely as
possible.

Currently, the REST API wraps all JSON produced by module commands inside
a meta-object of the following type:

  {
    "meta": <output of module command>
  }

This allows the output to be JSON API conformant without modifying the
modules and allows incremental updates to code.
2017-06-12 10:08:25 +03:00
Esa Korhonen
66a45fc37e MXS_MODULE_PARAM_REGEX and QUOTED_STRING now accept non-enclosed values
This is for backwards compatibility to allow current modules to use
the automatically compiled regex parameters. The enforcement should
be restored in a later version. A warning is output for every non-
enclosed regex.

Similar changes are also applied for QUOTED_STRING.
2017-06-09 12:59:11 +03:00
Esa Korhonen
47b7f1c69c Add automatically compiled PCRE2_REGEX config parameter type
The regex strings are compiled automatically. During file parsing,
the string is compiled once using default settings to check that
the pattern is valid. Once a module asks for the compiled pcre2_code,
the pattern is compiled again with module given settings.

The regex string in the config file should be enclosed within '/ ... /'
2017-06-05 09:42:42 +03:00
Markus Mäkelä
ba546fcd21 MXS-1220: Add execution of module commands to REST API
The module command self links now point to an endpoint that executes the
module command. Depending on the type of the module command, either a GET
or a POST request must be made.
2017-06-02 12:52:33 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
948a059004 MXS-1220: Add module commands to /maxscale/modules
The module commands are now exposed as an additional sub-resource for the
module type.
2017-05-29 19:27:45 +03:00
Esa Korhonen
88bf361e61 Add MXS_MODULE_PARAM_QUOTEDSTRING configuration value type
A quoted string is a string enclosed in '"':s. This makes it clear
where the string begins and ends, avoiding ambiguity with whitespace.
After the config file has been loaded, the '"':s at the beginning
and at the end of the string are erased. Querying the config value
with config_get_string() will return this de-quoted value.

For example, if the config file reads 'my_string="test""', the actual
string will be 'test"'.
2017-05-29 16:15:49 +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ä
69be4d263f MXS-1220: Add admin interface parameters to /maxscale/ resource
The admin interface parameters are now a part of the /maxscale/ resource.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
ead9059eeb MXS-1220: Add /users/ resource
The /users/ resource shows all user accounts that can be used with
MaxScale. This resource is further split into two resource collections,
/users/inet and /users/unix, which contain the network users and Linux
accounts respectively.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
7fc2d25cf2 MXS-1220: Allow new REST API users to be created
The REST API now uses the same users as MaxAdmin network interface. This
allows them to be created with MaxAdmin.

The next step is to add user creation to the REST API.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
adbf537d80 MXS-1220: Add more information to the /maxscale/ resource
The /maxscale/ resource now has values for most of the configuration
parameters in the [maxscale] section as well as the version, commit and
uptime information.
2017-05-17 10:14:56 +03:00
Markus Mäkelä
551f635f50 MXS-1220: Make the http.hh header public
As it contains utility functions for formatting time_t values to HTTP-date
values, there's no real need to make it an internal header.
2017-05-17 10:14:56 +03:00
Markus Mäkelä
ca7b24f6fa MXS-1220: Allow admin interface to be disabled
Allowing the admin interface to be disabled completely makes it possible
to remove any security concerns that could arise from its use.
2017-05-14 10:06:02 +03:00
Markus Mäkelä
ac21443529 MXS-1220: Make modules proper resources
The /maxscale/modules/ endpoint is now a resource collection and the
/maxscale/modules/:module endpoint exposes the individual resources.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
798ee840a8 MXS-1220: Make /maxscale/ resource conform to JSON API
The /maxscale/ resource now conforms to the JSON API and a test checks
that it the returned JSON is valid.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
ca62749f25 MXS-1220: Factor out common code from JSON object creation
The JSON objects that are created from the various core MaxScale objects
share a lot of common code. Moving this into a separate files removes the
redundant code.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
49b45acd13 MXS-1220: Reorganize server resource
The server resource now conforms to the JSON API schema.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
dcf9c8dab6 MXS-1220: Reorganize sessions resource
The sessions resource now follows the JSON API specification:

    http://jsonapi.org/

This makes the API relatively easier to use as the specification and the
client libraries to consume this data exist.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
301e3f0d19 MXS-1220: Fix parameter values that refer to objects
The parameters were validated with the correct object names but the actual
parameter values weren't converted to the new system. This caused a crash
when the service parameter validation was successful but the actual
retrieval of that parameter resulted in a NULL pointer.
2017-05-04 09:17:53 +03:00
Markus Mäkelä
73cf7999f2 MXS-1220: Implement /maxscale/ resource
The resource exposes the various directories that MaxScale uses. Further
information, like uptime, could be added at a later point.
2017-05-04 09:17:51 +03:00
Markus Mäkelä
bf44cd0d14 MXS-1220: Add HTTPS support
The REST API now supports encryption. The user needs to configure
certificates for the REST API before encryption is used.
2017-05-04 09:17:51 +03:00
Markus Mäkelä
4ed4773d91 MXS-1220: Allow binding to a specific address
The admin interface can now bind to a specific network interface.
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ä
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ä
e62be5034a Use constant sized arrays for some service strings
The `user`, `password`, `version_string` and `weightby` values should be
allocated as a part of the service structure. This allows them to be
modified at runtime without having to worry about memory allocation
problems.

Although this removes the problem of reallocation, it still does not make
the updating of the strings thread-safe. This can cause invalid values to
be read from the service strings.
2017-05-04 09:17:48 +03:00
Markus Mäkelä
cd6e0ab5e9 MXS-1220: Show parameters for services, filters and monitors
The service, filter and monitor resources now have a "parameters" value
which contains a set of all configuration parameters for that object. This
set contains both standard and non-standard parameters.

Also fixed a mistake in the constant name definitions for the monitor
parameters "events" and "script".
2017-05-04 09:17:47 +03:00
Markus Mäkelä
722ca4c8d1 MXS-1220: Add service parameters to service resource
The service resource now exposes the parameters that were given to
it. This allows general service parameters to be changed at runtime
through the REST API.
2017-05-04 09:17:47 +03:00
Markus Mäkelä
50eafe19fe MXS-1220: Add self links to all resources
A self link to the resource itself provides a convenient way for the
client to request a resource, modify it and call the self link to update
it. This removes some of the burden on the client to keep track of the
resource links by placing these in the resource itself.
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ä
52e0cc8e16 MXS-1220: Add HTTP BA authentication
The admin interface now supports Basic Access authentication. This is not
a secure method of authentication and it should not be used without
unencrypted connections.

Made the admin interface port, authentication, username and password
configurable.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
47c1e9d533 MXS-1220: Deprecate whitespace in object names
All whitespace in object names is now converted to a compacted format with
whitespace replaced with hyphens. If a conversion takes place, a warning
is logged.

Converted some of the tests into C++ as they directly include .cc files.
2017-05-04 09:12:15 +03:00
Esa Korhonen
8f50269338 Add proxy protocol support
Adds a server-specific parameter, "use_proxy_protocol". If enabled,
a header string is sent to the backend when a routing session connection
changes state to MXS_AUTH_STATE_CONNECTED. The string contains the real
client IP and port.
2017-04-27 12:29:46 +03:00