142 Commits

Author SHA1 Message Date
Markus Mäkelä
fe124b79cc
MXS-1929: Fix state of services created at runtime
If a service was created at runtime, it would be in the Allocated state
until it was stopped. The serviceStart function isn't necessary from a
functional point of view (a new service cannot have listeners that need
starting) but it does set the correct state and it's the "right" thing to
do.
2018-08-23 15:46:46 +03:00
Markus Mäkelä
065ee50d53
MXS-1929: Start monitors after creation
Monitors created via the REST API that were started and configured
successfully should also be started. This removes the extra step of
starting the monitor after creating it.
2018-08-23 15:46:46 +03:00
Markus Mäkelä
276ff70506
MXS-1929: Prevent alterations to filters and servers
These parameters must not be altered at runtime via the `alter service` or
`alter monitor` commands.
2018-08-22 16:43:17 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Markus Mäkelä
02ed338afa
Remove mxs::Closer<json_t*>
As std::unique_ptr can now be used with a json_t, there's no need for the
closer.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
0a0623003e
MXS-1929: Factor out parameter validation
The parameter validation for all module types follows roughly the same
path: first check whether it's a known parameter and then whether the
value is valid. This can be moved into common functions that removes
duplicated code.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
20994351ef
MXS-1929: Fix SSL JSON detection
The SSL initialization should only be attempted if `ssl_key`, `ssl_cert`
or `ssl_ca_cert` is defined. In addition to this, the SSL parameters
requirements for servers and listeners are different: servers require only
`ssl_ca_cert` but listeners require all three.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
eddae78b42
Remove repurposing of servers
This was not very safe or correct. For example statistics and parameters
were reused by a new server.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
a9ff2a7056
MXS-1929: Serialize objects using parameters
The main "non-static" objects are now serialized using their
parameters. This makes it possible to use common code for most modules.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
e2ace578d2
Validate parameters before storing them
The runtime modification of servers, services and monitors now validates
the parameters before starting the update process. This guarantees that
the set of parameters is valid before it is processed.

After the validation, the parameters are now also stored in the list of
configuration parameters. This will simplify the serialization process by
removing the need to explicitly serialize all common object parameters.
2018-08-20 13:56:59 +03:00
Johan Wikman
aaad63ee5e MXS-2008 Move content of maxscale/platform.h to maxbase/cdefs.h
No good reason for keeping that platform adjustments anywhere
else but in cdefs.h.
2018-08-20 11:15:14 +03:00
Johan Wikman
f3f802cabe MXS-2008 Move maxscale/atomic.h to maxbase/atomic.h 2018-08-15 08:44:39 +03:00
Markus Mäkelä
419aefb173
Update basic monitor parameters
All of the monitor parameters are now kept up to date when they are
altered. This simplifies the parameter list generation for the REST API.
2018-08-14 15:08:51 +03:00
Markus Mäkelä
46dee98b25
MXS-1929: Report runtime module loading errors to users
If a module is not found, a proper error message is now given to the
user. Other system errors are also printed if errno is set. Dynamic
library errors aren't printed as they are apparently reset after a call to
`dlerror`, at least according to documentation.
2018-08-13 10:28:03 +03:00
Markus Mäkelä
6661680c4e
MXS-1929: Add direct filter relationship updates
The filters of a service can now be directly updated via the relationships
endpoint.
2018-08-10 09:53:33 +03:00
Markus Mäkelä
290dcff48e
Add runtime size type check
Took the size type validity check function into use in runtime
configuration. This fixes the problem with zero not being accepted as a
valid size for query_classifier_cache_size.
2018-08-10 09:50:54 +03:00
Johan Wikman
f14380243b Rename cppdefs.hh to ccdefs.hh
For obvious reasons; the c++ suffix is .cc and not .cpp
2018-08-10 07:50:18 +03:00
Markus Mäkelä
f560172665
MXS-1929: Fix creation of filters that have no parameters
If the filter does not declare defaults and no parameters are defined, the
list of parameters would be NULL. This was interpreted as an error and the
filter creation failed.
2018-08-09 12:56:48 +03:00
Johan Wikman
2539183be2 MXS-2000 Add query_classifier_cache_size to maxscale resource 2018-08-09 08:37:44 +03:00
Johan Wikman
0b3e9cce75 Fix rebase problems 2018-08-08 09:21:59 +03:00
Johan Wikman
326bb88f70 MXS-1992 Expose config.cc:runtime_error as config_runtime_error 2018-08-08 09:17:58 +03:00
Johan Wikman
1b521b16a9 MXS-1992 Move QC json "parsing" to query_classifier.cc 2018-08-08 09:17:15 +03:00
Johan Wikman
2188090742 MXS-1992 Expose type checking functions of config_runtime.cc
The functions

bool runtime_is_string_or_null(json_t* json, const char* path);
bool runtime_is_bool_or_null(json_t* json, const char* path);
bool runtime_is_count_or_null(json_t* json, const char* path);

can now be called from anywhere inside MaxScale.
2018-08-08 09:17:15 +03:00
Johan Wikman
185758ef06 MXS-1992 Allow changing the QC cache size 2018-08-08 09:17:15 +03:00
Markus Mäkelä
bb1efd1b34
Merge branch '2.2' into develop 2018-08-07 22:20:27 +03:00
Markus Mäkelä
446116a8bb
MXS-1999: Fix removal of undefined relationships
If a relationship isn't defined, it should not be removed. Only if a
relationship is change to a null relationship, should it be removed.

Also fixed the maxctrl test suite to verify that both it and the REST API
tests pass.
2018-08-07 22:14:33 +03:00
Markus Mäkelä
4fd4d6bb01
MXS-1999: Fix null relationship handling
The data of the relationship should be set to null to delete the
relationship. Conceptually it is different from setting it to an empty
relationship but in practice both lead to the same end result.

Updated tests to use correct relationships and added test cases for
detection of invalid relationships.
2018-08-07 22:14:32 +03:00
Markus Mäkelä
03553783fb
MXS-1929: Process filter relationships for services
The filter relationships of a service are now interpreted as an ordered
list of filters being used by the service. As the relationship data in the
JSON API specification is represented as an array, it does not prevent
multiple relationships from appearing. For MaxScale, this means that
interpreting the filter's order does not break it.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
5d085f5cdf
MXS-1929: Remove service parameter setters
Removed the explicit setters for the service parameters. Not all of them
were implemented and they were only used internally. Moved the parameter
validation and update processing inside the Service class to reduce the
load on the other parts of the core.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
4d3dbb2040
MXS-1929: Take SFilterDef into use
The service now uses a std::vector<SFilterDef> to store the filters it
uses. Most internal parts deal with the SFilterDef but debugcmd.cc still
moves raw pointers around (needs to be changed).
2018-08-06 21:20:29 +03:00
Markus Mäkelä
a252b45f18
Don't use auto&& in non-template code
Use explicit types instead.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
3be975ba5d
Fix fixing of std::string object names
Comparing two fixed std::strings would have equal C strings but comparing
with operator== they would be different. This was a result of the string
modification done by fix_object_name.

Converted the internal header into a C++ header, added std::string
overload and fixed use of the function.
2018-07-31 09:41:15 +03:00
Markus Mäkelä
cca7757090
MXS-1929: Take internal Service struct into use
The internals now mostly refer to the Service struct instead of the public
SERVICE struct.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
829fdcff83
MXS-1929: Make filters fully opaque
The filter implementation is now fully hidden. Also converted it to a C++
struct allocated with new and stored the filters in a global list instead
of embedding the list in the object itself.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
e39242d6e5
MXS-1929: Add filter deletion entry points
Added the code required to delete a filter via the REST API. The actual
deleting of the filters is still to be implemented.
2018-07-31 09:41:11 +03:00
Markus Mäkelä
22cc155e55
MXS-1929: Process relationships when creating services
The relationships of a service are handled by the service alteration
code. Currently, only server relationships are handled by the code in
question and filter relationships are ignored.
2018-07-31 09:41:10 +03:00
Markus Mäkelä
fb3101f7c4
MXS-1929: Improve JSON type error messages
If an invalid value or type is given to the REST API, having the expected
type as well as the given type make problem resolution easier.

Also added a value check into MaxCtrl for listener ports.
2018-07-31 09:41:10 +03:00
Markus Mäkelä
0c63471715
MXS-1929: Use correct object type when loading defaults
The service creation attempted to load defaults for a filter module when
the module in question was a router.
2018-07-31 09:41:09 +03:00
Markus Mäkelä
037cedf70e
MXS-1929: Allow service creation at runtime
Services can now be created at runtime. The command to create services is
exposed in the REST API.
2018-07-31 09:41:07 +03:00
Markus Mäkelä
5a40064826
MXS-1929: Make services destroyable
Services can now be destroyed if they have no active listeners and they
are not linked to servers. When these conditions are met, the service will
be destroyed when the last session for the service is closed.

The closing of a service will close all listeners that were once assigned
to the service. This allows closing of the ports at runtime which
previously was done only on shutdown.

Exposed the command through the REST API but not through MaxAdmin as it is
deprecated.
2018-07-31 09:41:07 +03:00
Markus Mäkelä
18c1ec2678
MXS-1929: Make listeners inactive when destroyed
By using service_remove_listener the listener is marked as inactive when
it is destroyed.
2018-07-31 09:41:06 +03:00
Markus Mäkelä
b93eaf6fb2
MXS-1929: Validate multiple JSON relationships
The runtime configuration JSON validation now allows multiple
relationships to be verified at one time. This makes it easier to validate
all objects using the same framework.
2018-07-31 09:41:06 +03:00
Markus Mäkelä
2c1f79c5d1
MXS-1929: Add runtime creation of filters
Filters can now be created at runtime. This is not yet a usable feature
since the filters can't be added to services at runtime.
2018-07-31 09:41:05 +03:00
Markus Mäkelä
d9fde54b95
Use mxs::SpinLock in config_runtime.cc
The C++ version with the lock guard is easier to manage when there are
multiple return points from a function. It also makes sure that the lock
is freed after it's used.
2018-07-17 11:52:37 +03:00
Markus Mäkelä
df94ef990c
Use module-type parameters for servers
The server base objects now use the module-type parameters for generic
configuration.
2018-07-17 11:52:20 +03:00
Markus Mäkelä
d28b1c9d1d
Validate SSL parameters via the module-type parameters
The configuration system that modules use allows the SSL parameter
validation to be simplified. It should also provide more consistent error
messages for similar types of errors.

The SSL_LISTENER initialization is now done in one step. There was no good
reason to do it in two separate steps for listeners but in one step for
servers.

The `ssl` parameter now also accepts boolean values. As the parameter
behaves like a boolean and looks like a boolean, it ought to be a
boolean. It still accepts the custom `required` and `disabled` values
simply for backwards compatibility.

Also added the missing freeing functions for the SSL_LISTENER type. This
prevents failed SSL_LISTENER creations from leaking memory.
2018-07-17 11:52:20 +03:00
Markus Mäkelä
4a0ace2a72
Use module-style parameters with monitors
The common monitor parameters are now stored as module-style
parameters. This makes the error reporting as well as the type checks for
the parameters consistent with parameters declared by the modules.
2018-07-17 11:52:15 +03:00
Markus Mäkelä
f807c21242
Treat service parameters as module parameters
The same mechanism that is used for modules can be used for the
configuration of the core objects. This removes the need for the redundant
code that validates various values that is already present in the code
that modules use.
2018-07-17 11:52:14 +03:00
Markus Mäkelä
313bb0a5b4
Fix alteration of new router parameters
If a router parameter has no default value, the previous value would be
returned as an empty string. A debug assertion would be triggered when a
parameter of this type was altered.

When a new router parameter is encountered and the alteration fails, the
modified value in the service need to be removed. Previously, the new
value would have been stored in the service with an empty value which
would have caused problems.
2018-07-11 14:08:53 +03:00
Markus Mäkelä
6d663c79ac
Extend router alteration test
Extended the test to cover modifications to readconnroute as well as do
checks on detection of invalid parameters.

Also allowed modifications to router_options at runtime.
2018-07-11 14:08:52 +03:00