62 Commits

Author SHA1 Message Date
Markus Mäkelä
612b4e1a32
MXS-1847: Fix server_get_parameter
The function now takes an output buffer as a parameter. This prevents race
conditions by copying the parameter value into a local buffer.
2018-05-03 09:50:52 +03:00
Markus Mäkelä
48e2b50e68
MXS-1731: Persist only non-empty values
When the service configurations are persisted, they need to be valid. This
means that no empty values are written into the file.
2018-03-22 13:29:28 +02:00
Markus Mäkelä
dcf9d7f152
Fix calls to diagnostics_json
Add missing listener JSON diagnostics call. Check that the
diagnostics_json function exists before calling it.

As the protocol modules don't have diagnostics functions, they aren't
called.

Replace hard-coded strings with constant parameters. This makes it
slightly cleaner.
2018-03-20 13:07:27 +02:00
Johan Wikman
391ec78a0b MXS-1721 Destroy a filter instance only once
If two services referred to the same filter instance, it would
cause the filter to deleted twice at MaxScale shutdown with a
crash as the result.

Now when the services are deleted we just collect the unique
filter instances and then delete them after all services have
been deleted.
2018-03-16 12:00:18 +02:00
Johan Wikman
633b08ed0d MXS-1717 Show which listener users are coming from
Earlier, if a service had multiple listeners you would have had

   MaxScale> show dbusers MyService
   User names: alice@% ...
   User names: bob@% ...

That is, no indication of which listener is reporting what. With
this commit the result will be

   User names (MyListener1): alice@% ...
   User names (MyListener2): bob@% ...

Further, the diagnostics function of an authenticator is now expected
to write the list of users to the provided DCB, without performing any
other formatting. The formatting (printing "User names" and appending
a line-feed) is now handled by the handler for the MaxAdmin command
"show dbusers".
2018-03-13 10:25:42 +02:00
Johan Wikman
7ae3931511 MXS-1689 Properly check for duplicate port/socket of service
It is now impossible to create two listeners for a service that
would listen on the same port/socket (as before), but the error
message is now sensible and provides detailed information to the
user.
2018-03-07 15:25:43 +02:00
Markus Mäkelä
55276be6f2
MXS-1699: Log progress messages at startup
When MaxScale is starting, the loading of the listeners can take a while
if there are a large number of services and users to load. To signal this
to the user, progress messages should be logged after every service is
started.
2018-03-06 15:56:07 +02:00
Johan Wikman
e346968e0e Merge branch '2.1' into 2.2 2018-02-10 08:28:11 +02:00
Markus Mäkelä
bb1bfcb52b Fix memory leak in service parameter output
When the service parameters were converted into JSON, an array was created
that was not used.
2018-01-22 15:29:21 +02:00
Markus Mäkelä
6ee5307624 Only pre-seed asynchronous authenticators
Only asynchronous authenticators require the thread-specific loading of
users as the synchronous ones all share the same data. If the service does
not declare asynchronous capabilities at startup, the users are not
seeded. This prevents unnecessary loading of users at startup.
2018-01-09 13:59:12 +02:00
Markus Mäkelä
5c8c20abe4 MXS-1539: Also synchronize rate limitations
If a synchronous authenticator is used, the rate limitations are also
synchronous.
2018-01-04 15:02:24 +02:00
Markus Mäkelä
8d15256d70 MXS-1539: Add asynchronous authenticator capability
The new ACAP_TYPE_ASYNC capability allows the authenticator to tell the
core that all entry points for it support asynchronous usage.
2018-01-03 08:56:41 +02:00
Markus Mäkelä
6036c1cdca MXS-1539: Assign capability bits for all module types
All modules now have an 8-bit range for capability flags. Currently only
the client side authenticator and protocol capability bits are loaded due
to the fact that backend versions of these modules don't relate to a
particular service.
2018-01-03 08:56:41 +02:00
Johan Wikman
140620a366 MXS-1582 Close listener sockets on exit
If the listener socket refers to a Unix domain socket, the socket file
will be deleted as well.
2017-12-29 08:34:46 +02:00
Markus Mäkelä
8ef681d8cd Fix trivial memory leaks
Fixed trivial memory leaks detected by ASAN when running internal test
suite.
2017-12-27 11:56:39 +02:00
Markus Mäkelä
fb1875c61c Pre-load users for all threads
Pre-loading users for all threads at startup significantly reduces the
chance for failures caused by the lazy initialization of the user database
done by the authenticators.

If users are not loaded at startup and the connection limit for all
servers is reached, authentication in MaxScale will fail not due to too
many connections but due to the lack of authentication data. This causes
repeated reloading of users, which floods the log with messages, and
unnecessary stress on the cluster itself.
2017-12-22 11:45:32 +02:00
Markus Mäkelä
79afaa447e Merge branch '2.1' into 2.2 2017-12-12 13:23:02 +02:00
Markus Mäkelä
74ae3d9ff3 MXS-1539: Actually assign the allocated member pointer
The memory for the rate limit struct was allocated but it was not assigned
for the service. Also corrected a false debug assertion in
service_refresh_users.
2017-12-05 09:43:05 +02:00
Markus Mäkelä
a2d275aca3 MXS-1539: Make refresh rate limitations thread-specific
The refresh rate limitations are now also thread-specific. This is
required when the authentication data is partitioned on a per thread
basis.
2017-12-05 09:43:05 +02:00
Markus Mäkelä
396b81f336 Fix in-source builds
The internal header directory conflicted with in-source builds causing a
build failure. This is fixed by renaming the internal header directory to
something other than maxscale.

The renaming pointed out a few problems in a couple of source files that
appeared to include internal headers when the headers were in fact public
headers.

Fixed maxctrl in-source builds by making the copying of the sources
optional.
2017-11-22 18:40:18 +02:00
Johan Wikman
b1b78a5be7 Remove references to QUEUE_CONFIG
Only used in conjunction with queued connections, which are not
enabled anyway. Once that comes on the table again, better to use
some standard data structures.
2017-11-08 10:44:14 +02:00
Markus Mäkelä
582a65f77c Do not return empty relationships
If no relationships of a particular type are defined for a resource, the
key for that relationship should not be defined.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
895d950da0 Format all source files with Astyle
Formatted all source files Astyle.
2017-09-28 07:04:21 +03:00
Johan Wikman
de7004cb95 Merge branch '2.1' into develop 2017-08-15 10:31:30 +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ä
090de1a0f7 MXS-1220: Make individual listeners resources
The listeners are now a proper sub-resource of the service resource. This
means that it acts like a normal resource and can be queried both as a
collection of resources and as an individual resource.
2017-07-23 08:21:00 +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ä
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
086e7abe77 CentOS 6 compile issues fixed
CentOS 6 compile issues fixed
2017-06-30 10:45:30 +02:00
Johan Wikman
33fe89772a MXS-1249: Return service version
Since it is now a single value, the service version can be returned
as a return value instead of via an out-argument. More convenient to
use that way.
2017-06-21 13:28:59 +03:00
Johan Wikman
997416ab82 MXS-1249: Server version stored as uint64_t value
That allows the version to be updated and read atomically. If
major/minor/patch are stored as separate variables, you can get an
inconsistent set. Now it may be out of date by the time it is used,
but it will never be internally inconsistent.
2017-06-21 13:28:59 +03:00
Johan Wikman
b8702b8d95 MXS-1249: Add function for getting the "version" of a service
The behaviour of the query classifier needs to change depending
on the version of the servers of a service. With this function
"some" version of the service can be obtained.
2017-06-21 13:28:59 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
157b7f853b MXS-1220: Fix resource self links
The top level resource self links pointed to the collection instead of the
resource itself. The individual resoures now also have a links field that
contains the self link to the resource. This should make navigation of the
API easier as all objects have valid links in them.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
613b924f2e Add listener iterator
The listener iterator hides the details of the listener iteration behind a
small set of functions.

The following for-loop demonstrates the main use-case for the iterator:

    LISTENER_ITERATOR iter;

    for (SERV_LISTENER *listener = listener_iterator_init(service, &iter);
         listener; listener = listener_iterator_next(&iter))
    {
        /** Do something with the listener */
    }

As the listeners are mostly iterated to either check a fact about them or
print their information, the functions cater to that use-case. For this
reason, they should always be allocated off the stack.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
717f883839 Make service ports lock-free
The service port list is now iterated in a safe and lock-free manner. This
makes the handling of service ports somewhat simpler since once an item
has been added to the list it will never be removed. It also removes the
need to lock the service when checking whether a service listens on a port
which caused potential deadlocks.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
08dca8c273 MXS-1220: Treat service listeners as service sub-resources
The listeners under the /services/:service/listeners collection are now
fully JSON API compliant resources.

The listeners could also be exposed as a /listeners collection to easily
group all listener type resources in one place. This approach does has
some semantical and practical problems, namely the fact that each listener
has a many-to-one relationship with its service and listeners by
themselves can't exist alone.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
fb7f283316 MXS-1220: Reorganize service resource
The service resource now conforms to the JSON API schema. Added a test
case for individual resources and resource collections.
2017-05-09 15:32:41 +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ä
dcbd91deee Fix filters parameter processing
The filter names for the service parameter `filters` weren't converted
into the new format. This caused a configuration error when a filter with
significant whitespace in its name was used in a service.
2017-05-04 09:17:53 +03:00
Markus Mäkelä
fce0edce8e Allow NULL parameters for start/stop functions
The functions that start and stop monitors and services now accept NULL
parameters.
2017-05-04 09:17:52 +03:00
Markus Mäkelä
60526f15b8 MXS-1220: Add GET support for service listeners
The service listeners can now be queried as a separate resource. This is
the first step towards the creation and destruction of listeners.
2017-05-04 09:17:52 +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ä
dd68069471 MXS-1220: Add back the old diagnostic entry point
This makes 2.2 maxadmin backwards compatible with 2.1.
2017-05-04 09:14:04 +03:00
Markus Mäkelä
84d085ef39 MXS-1220: Only list active server references
The services listed disabled server references in their relationships.
2017-05-04 09:14:04 +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