29 Commits

Author SHA1 Message Date
Markus Mäkelä
96d9c47016 MXS-1553: Enforce SSL usage for monitors
If a server is configured to use SSL, then MaxScale should respect the
configuration and refuse to use a connection that is not encrypted.
2017-12-01 03:50:57 +02:00
Markus Mäkelä
d5d41349ae MXS-1509: Add ignore_external_masters parameter
The new parameter allows ignoring of master servers that are external to
the monitor configuration. This allows sub-trees of the actual replication
tree to be used as fully fledged replication trees.
2017-11-30 12:39:00 +02:00
Markus Mäkelä
b56594470b Add persistent pool statistics
Added number of times a connection was taken from the pool as well as the
availability of the pool as a percentage of connections taken from the
pool.
2017-08-20 21:54:18 +03:00
Markus Mäkelä
0b5d164855 MXS-1167: Skip permission checks for internal services
If a server points to a local MaxScale listener, the permission checks for
that server are skipped. This allows permission checks to be used with a
mix of external servers and internal services.
2017-03-20 11:10:55 +02:00
Johan Wikman
5648f708af Update license to BSL 1.1 2017-02-14 21:42:28 +02:00
Esa Korhonen
7d51864402 Clean config.h some more
Moved some typedefs to router.h and server.h, changed a few
constants to these enums. Renamed some types in config.h to
remove "Gateway".

There are still some functions in the public header which are
only used in core, but they seem to fit the theme of public functions
so were not moved.
2017-01-25 16:05:51 +02:00
Johan Wikman
c3ddc3ac22 Cleanup server.h
- All (but the printing/debug functions) are now in snake_case.
- Functions made const correct.
- All function prototypes now have named arguments.

Documentation still to be moved, and file possibly split into
include/mascale/server.h and server/core/maxscale/server.h
2017-01-09 12:14:46 +02:00
Johan Wikman
78928dc575 Make session_[getUser|get_remote] const correct
- Rename session_getUser to session_get_user
- Change session_get_user and session_get_remote to take a const
  SESSION* as argument and to return a const char*.
- Change server_get_persistent, so that user is passed as const.
- Update all users of these functions as appropriate.
2017-01-02 16:16:37 +02:00
Markus Mäkelä
ae8c21929f Serialize server weighting parameters
The server weighting parameters couldn't be altered online and they
weren't serialized to disk. Only servers that are created online will have
their weighting parameters persisted to disk.
2016-12-19 18:40:14 +02:00
Markus Mäkelä
180728dde6 Only serialize created servers
Any changes to servers that aren't created online need to be manually
added to the configuration file in order for them to take effect after the
restart.
2016-12-19 18:40:14 +02:00
Esa Korhonen
7e9db7ed0c Have server status updates applied during monitor loop
Previously, server status changes from MaxAdmin would be set immediately
as long as the server lock could be acquired. This meant that it might take
several seconds until the next monitor pass is executed. Usually, this was
fine but in some situations we would want the monitor to run immediately
after the change (MXS-740 and Galera). This patch changes the logic of
setting and clearing status bits to a delayed mode: changes are first applied
to a "status_pending"-variable, and only once the monitor runs will the
setting be applied. To reduce the delay, the monitor now has a flag
which is checked during sleep (between short 0.1s naps). If set, the
sleep is cut short.

If a server is not monitored, the status bits are set directly.

There is a small possibility of a race condition: If a monitor is stopped or
destroyed before the pending change is applied, the change is forgotten.
2016-12-19 10:19:23 +02:00
ekorh475
259e944b3d Server status changes now happen under a lock
MXS-873 To prevent monitors and MaxAdmin from interfering with each other,
changes to the server status flags now happen under a lock. To avoid
interfering with monitor logic, the monitors now acquire locks to all
of their servers at the start of the monitor loop and release them
before sleeping.
2016-12-12 15:04:05 +02:00
Markus Makela
5aa791d16e Move persistent connections to thread specific lists
Making the lists of persistent DCBs thread specific is both a bug fix and
a performance enhancement. There was a small window where a non-owner
thread could receive events for a DCB. By partitioning the DCBs into
thread specific lists, this is avoided by removing the possibility of DCBs
moving between threads.
2016-11-30 10:28:23 +02:00
Markus Makela
8ef99c9066 Move configuration changes to a common file
The config_runtime.h header contains functions that can be used to
manipulate the running configuration. Currently the header contains the
function to create, add, remove and destroy servers.
2016-11-24 10:29:04 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Markus Makela
8b692b0754 Add SSL support for created servers
Servers created at runtime can now be configured to use SSL. The
configuration is only possible if the server is not in use.

The `alter server` command in maxadmin now takes a list of `key=value`
strings. This allows the user to define multiple alter operations with one
command.
2016-11-14 22:58:26 +02:00
Markus Makela
b893ca7ba8 Move configuration context processing into subfunctions
The functions allow simple operations on configuration context
objects. This makes it easier to understand what the code does and allows
reuse of the configuration processing code.
2016-11-14 22:58:26 +02:00
Markus Makela
2fcfc102be Abstract server active checks
The checks for the server active status are now hidden behind a
macro. This allows for the conditions of the activity to change without
having to alter the code that uses it.
2016-11-11 11:35:13 +02:00
Markus Makela
08ebb88aec Make server creation simpler
Server creation and allocation are now the same apart from the fact that
allocation only adds the server to the running configuration where as the
creation of a server also persist it to disk.

The server serialization should not be seen through the server.h API. This
allows the serialization method to change without actually having to
change the interfaces.
2016-11-11 10:54:34 +02:00
Markus Makela
e67a829daf Take server destruction into use
The servers can now be destroyed with the `destroy server NAME` maxadmin
command.
2016-11-11 10:54:33 +02:00
Markus Makela
261f5fdc36 Enable destruction of servers
The servers can now be destroyed which removes them from the list of
active servers. If the server was not created at runtime, a warning is
logged.
2016-11-11 10:54:32 +02:00
Markus Makela
f0082256f5 Only print servers that aren't destroyed
If a server were to be destroyed, it should not show up among
non-destroyed servers. Even though the servers aren't actually destroyed,
it hides unnecessary information from the user.
2016-11-11 10:47:47 +02:00
Markus Makela
c9218351b8 MXS-922: Serialize created servers
When a server is created via MaxAdmin, it will be serialized to disk. This
allows created servers to be retained through a restart of MaxScale.

Currently, all serialized objects are stored in one folder and there is no
structure in the created files. In the future, servers could be created
under a `servers` subdirectory so that it is easier to see what was
added. Whether there is a need for this will be seen.
2016-11-10 15:15:10 +02:00
Markus Makela
35d2959395 Enable online modification of servers
The address, port, monuser and monpw parameters of an existing server can
be changed at runtime. The support for enabling SSL will come in a later
commit.

Allowing servers to be modified could also be done by destroying and
recreating them. Since the servers are never actually destroyed, it is
better to allow the alteration of the existing ones.
2016-11-10 15:15:10 +02:00
Markus Makela
28fc3d2b83 MXS-922: Add server serialization function
The function serializes a server to a file. This is intended to be used
with dynamically created servers. The output of the server serialization
will eventually be stored in the configuration file directory (default is
/etc/maxscale.cnf.d/) so that created servers persist even after a
restart.
2016-11-10 15:15:10 +02:00
Johan Wikman
d7ce3ad75b Replace include guards with #pragma once 2016-10-26 08:23:15 +03:00
Johan Wikman
c03b8079fd Move @file comment
Where it exists, the @file comment has now been moved to be
consistently right after the license blurb.
2016-10-14 13:20:52 +03:00
Johan Wikman
1a978be6b6 Cleanup header files
- All now include maxscale/cdefs.h as the very first file.
- MXS_[BEGIN|END]_DECLS added to all C-headers.
  Strictly speaking not necessary for private headers, but
  does not hurt either.
- Include guards moved to the very top of the file.
- #pragma once added.
2016-10-14 11:54:37 +03:00
Johan Wikman
e41589be10 Move headers from server/include to include/maxscale
- Headers now to be included as <maxscale/xyz.h>
- First step, no cleanup of headers has been made. Only moving
  from one place to another + necessary modifications.
2016-10-13 16:19:20 +03:00