Commit Graph

224 Commits

Author SHA1 Message Date
d89f0c062b MXS-2271 Change Monitor->m_name to std::string
Also, monitor address is no longer printed.
2019-04-02 13:08:38 +03:00
1417292f0d Destroy monitor only if it's not used
If a service uses a monitor as the source of its servers, it must not be
destroyed before the monitor is removed from all services that use it.
2019-04-02 10:08:59 +03:00
388e952c5f MXS-1951: Fix port conflict detection
With the addition of SO_REUSEPORT support, it is no longer possible to
rely on the network stack to prevent multiple listeners from listening on
the same port. Without explicitly checking for the ports it would be
possible for two listeners from two different services to listen on the
same port in which case the service would be almost randomly chosen.
2019-03-28 16:34:12 +02:00
abd6e0924f Always load module defaults for monitors
The creation of a monitor from JSON relied on the non-JSON version for the
addition of default parameters but it proceeded to check the validity of
the parameters before it. Whenever parameters are checked, the default
parameters should be present.
2019-03-28 13:21:24 +02:00
c3f3200d2c Fix removal of last server from monitor
If the last server was removed, the parameter would be rejected due to it
being empty. To remove the parameter, the
MonitorManager::reconfigure_monitor should be used. Also fixed the
unnecessary serialization after a failure to remove server from a monitor
and the fact that some errors were logged instead of written to the caller
of the command.
2019-03-28 13:21:23 +02:00
906f0ed3cd Add RAII class for stopping monitors
This way the state is encapsulated in the object and the required changes
are done in one place. This makes the code reusable across all functions
making it easier to implement better monitor alteration code.
2019-03-28 13:21:23 +02:00
03121c63d4 Add monitor reconfiguration helper
The MonitorManager function reconfigured a monitor and rolls back to the
old configuration if the new one doesn't work.
2019-03-26 17:30:38 +02:00
22004702bc Don't use CONFIG_CONTEXT in config_runtime.cc
The only thing that's needed is MXS_CONFIG_PARAMETER.
2019-03-26 15:53:20 +02:00
156abe81ee Add type and module to default parameters
When default parameters are loaded, the type and module name are
added. This helps object serialization and allows all the code to expect
that all the parameters needed to create an object are always present.
2019-03-26 15:53:20 +02:00
4880edd373 Fix removal of servers from monitors
The last server wasn't removed as the set of relationships was empty. In
addition to this, changes to relationships via the relations endpoint
wasn't reflected by the monitor parameters.
2019-03-25 12:37:11 +02:00
9bb5e12413 Fix monitor creation and alteration
If a monitor was created at runtime, it was missing some parameters that
were assumed to be always present. In addition to that, the parameters
weren't validated against the list of common and module parameters.

Since the monitors always reconstruct the server list, the new servers can
be stored as a parameter. To make this possible, the
server_relationship_to_parameter helper function is needed.

This commit fixes the MaxCtrl test suite failures but does not fix the
failures in the REST API test suite.
2019-03-25 12:37:11 +02:00
40df519be4 Never reactivate monitors
Reactivating monitors shouldn't be done as it's simpler to actually
destroy and create a new one. The performance of reactivation is
insignificant compared to the possible inconsistency problems it allows.
2019-03-21 18:19:10 +02:00
203bba0e1d Add support for multiple runtime error messages
Storing all the runtime errors makes it possible to return all of them
them via the REST API. MaxAdmin will still only show the latest error but
MaxCtrl will now show all errors if more than one error occurs.
2019-03-21 18:19:10 +02:00
0130bc16e2 Fix monitor alteration
Alterations to monitors are now done with all changes present in the first
call to configure. This fixes the case where two parameters depended on
each other and one would get configured before the other.
2019-03-21 18:19:09 +02:00
60917238c3 Format config.cc and config_runtime.cc 2019-03-21 18:19:09 +02:00
c2fc80f122 Fix monitor creation
When the monitor was created, no parameters were passed to it.
2019-03-21 18:19:09 +02:00
3eef2648e1 MXS-2313: Expose only two rank values
The rank can now only be used to define two groups of servers: primary and
secondary servers. This limits the exposure and reduces the number of
possibilities that can arise from the use of this parameter thus making it
more predictable.
2019-03-18 13:12:59 +02:00
9b6b5270f1 MXS-2313: Use 64-bit integers to store rank
Although the default value is the maximum value of a signed 32-bit
integer, the value is stored as a 64-bit integer. The integer type
conversion functions return 64-bit values so storing it as one makes
sense.

Currently values higher than the default are allowed but the accepted
range of input should be restricted in the future.
2019-03-18 13:12:58 +02:00
0693514047 MXS-2313: Add server ranks
The servers now accept a rank parameter that tells which servers to
prioritize.
2019-03-18 13:10:23 +02:00
14b4fa632a MXS-2271 Move Monitor inside maxscale-namespace
Rearranged monitor.cc by namespace.
2019-03-15 12:57:35 +02:00
5e3f837b42 MXS-2271 Continue monitor header cleanup
No more free functions. Local functions moved to anonymous namespace.
2019-03-15 12:57:35 +02:00
ac5ee1278c MXS-2271 Cleanup internal monitor header and its functions
Some functions still accessed the servers-array. Most functions are now
inside class. Removed unused defines.
2019-03-12 15:32:56 +02:00
1858fe9127 MXS-2271 Monitor modifications always go through Monitor::configure()
Previously, runtime monitor modifications could directly alter monitor fields,
which could leave the text-form parameters and reality out-of-sync. Also,
the configure-function was not called for the entire monitor-object, only the
module-implementation.

Now, all modifications go through the overridden configure-function, which calls the
base-class function. As most configuration changes are given in text-form, this
removes the need for specific setters. The only exceptions are the server add/remove
operations, which must modify the text-form serverlist.
2019-03-12 10:19:45 +02:00
c2459c420d MXS-2304 Rename fields of CONFIG_CONTEXT
Added m_-prefix.
2019-03-04 12:27:36 +02:00
2a63fb0776 MXS-2304 Store config parameter container as value in monitor and service 2019-02-22 16:53:17 +02:00
3fa4a85a1e MXS-2304 Use values instead of pointers in CONFIG_CONTEXT
Simplifies ctor/dtor.
2019-02-22 16:39:45 +02:00
5828c93112 MXS-2304 Convert static config parameter methods to non-static
Parameter handling changed in several places.
2019-02-22 15:17:55 +02:00
b64e9b3ee0 MSX-2304 Store configuration parameters in a map
Also adds begin() and end() functions for loops.
2019-02-22 15:04:14 +02:00
1fed465fdb MXS-2246 Remove duplicate info in SERVICE and Service
Both of them contained fields for the service and router names.
Now the names are in SERVICE and they must be accessed via member
function.
2019-02-14 15:24:10 +02:00
7a99b5d253 MXS-2314 Define monitor state in terms of worker state
Worker::STOPPED    -> MONITOR_STATE_STOPPED
Worker::POLLING    -> MONITOR_STATE_RUNNING
Worker::PROCESSING -> MONITOR_STATE_RUNNING

By defining the monitor state from the worker state there is
no risk they will ever get out of sync. And there is one thing
less to maintain.
2019-02-11 13:03:18 +02:00
cac1d76e48 MXS-2314 Monitor decides whether servers are added to services
When the servers of a service are defined by a monitor, then
at startup all servers of the monitor should be added to relevant
services. Likewise, when a server is added to or removed from a
monitor at runtime, those changes should affect services as well.

However, whether that should happen or not depends upon the monitor.
In the case of the Clustrix monitor this should not happen as it
adds and removes servers depending on the runtime state of the
Clustrix cluster.
2019-02-11 13:03:18 +02:00
0e3ec06c5b MXS-2314 Prevent removal of servers from clustered services
If the servers of a service are defined by a monitor, then it must
not be possible to dynamically add or remove servers from the
service.
2019-02-11 13:03:18 +02:00
35ab911d5c MXS-2304 Use configuration class methods instead of separate implementations
Replaces parameter add/set/remove/free.
2019-02-07 13:51:16 +02:00
ed80680da9 MXS-2304 Add ctor/dtor and other functions to parameter class
The manipulation functions are currently static so that the container can be initialized
if required. This will be fixed later.

The new functions are taken into use in monitor management.
2019-02-07 13:51:16 +02:00
4132c9bbbc MXS-2304 Use get_c_str_copy instead of config_copy_string()
Also uses get_string() in core-code when appropriate.
2019-02-05 10:28:37 +02:00
03411e825d MXS-2271 Move journal_max_age inside settings container 2019-01-31 17:05:35 +02:00
ce9b49d8d5 MXS-2271 Move script-related settings to the settings-container
Also moves related functions to class methods.
2019-01-31 17:05:34 +02:00
0903648542 MXS-2271 Move connection settings inside settings struct
Since the settings are now protected fields, all related functions were
moved inside the monitor class. mon_ping_or_connect_to_db() is now a method
of MXS_MONITORED_SERVER. The connection settings class is defined inside the
server since that is the class actually using the settings.
2019-01-31 17:00:47 +02:00
6326172325 MXS-2271 Rename basic Monitor fields
Adds the m_-prefix.
2019-01-28 15:41:00 +02:00
cef4e836bc MXS-2271 Store monitored servers in a vector
The array is still a public member because it's used in several non-member functions.
2019-01-28 15:41:00 +02:00
546b80de4b MXS-2271 Move monitor interval to settings container 2019-01-25 13:46:01 +02:00
7d92717b66 MXS-2274 Prevent dynamic creation of object with invalid name
Unfortunately there is not a single place where the name could be
validated, but it has to be done separately for each object type.
2019-01-24 17:42:29 +02:00
f559bf3d95 MXS-2271 Move disk space settings to a settings-container 2019-01-24 09:49:53 +02:00
9ac8bf93bb MXS-2271 Rename monitor-related classes
MXS_MONITOR->Monitor
MonitorInstance->MonitorWorker
MonitorInstanceSimple->MonitorWorkerSimple
2019-01-22 15:59:17 +02:00
3321a591ef MXS-2271 Move some monitor management functions to an internal class
The class MonitorManager contains monitor-related functions that should not
be called from modules. MonitorManager can access private fields and methods
of the monitor.
2019-01-22 10:31:06 +02:00
dd16a09342 MXS-2271 Move some initializers out of monitor_create() 2019-01-17 18:24:28 +02:00
ac61e205d8 MXS-2219 Dynamically create Clustrix servers
MaxScale server objects are now created for all Clustrix nodes.
Currently the name is "Clustrix-Server-N" where N is the number
of the node.

The server is created using runtime_create_server() that has been
modified so that it optionally will not persist the created server.
That is probably just a temporary solution as a monitor should not
need to include .../core/internal-stuff.
2019-01-17 11:11:21 +02:00
87913f8cb8 MXS-2220 Miscellaneous cleanup
Removes some duplicate includes.
2019-01-11 11:00:24 +02:00
df17619722 MXS-2220 Move server_update_address inside class
Should be moved to internal class once blr is cleaned up.
2019-01-10 10:26:53 +02:00
d5c78eb31f MXS-2220 Move more server functions inside class 2019-01-08 15:12:47 +02:00