Make maxscaled upgrade friendlier
Currently, if the address/port information of a maxscaled protocol listener is not updated to socket when MaxScale is upgraded to 2.0, maxscaled would not start, with the effect of a user loosing maxadmin after an upgrade. After this change, if address/port information is detected, a warning is logged and the default socket path is used. That way, maxadmin will still be usable after an upgrade, even if the address/port information is not updated.
This commit is contained in:
@ -349,7 +349,7 @@ static int maxscaled_close(DCB *dcb)
|
|||||||
*/
|
*/
|
||||||
static int maxscaled_listen(DCB *listener, char *config)
|
static int maxscaled_listen(DCB *listener, char *config)
|
||||||
{
|
{
|
||||||
char *socket_path;
|
char *socket_path = NULL;
|
||||||
|
|
||||||
/* check for default UNIX socket */
|
/* check for default UNIX socket */
|
||||||
if (strncmp(config, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG_LEN) == 0)
|
if (strncmp(config, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG_LEN) == 0)
|
||||||
@ -358,19 +358,28 @@ static int maxscaled_listen(DCB *listener, char *config)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
socket_path = config;
|
const char* colon = strchr(config, ':');
|
||||||
}
|
ss_dassert(colon);
|
||||||
|
const char* port = colon + 1;
|
||||||
|
|
||||||
/* check for UNIX socket path*/
|
if (*port == '0')
|
||||||
if (strchr(socket_path,'/') == NULL)
|
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to start listening on '%s' with 'MaxScale Admin' protocol,"
|
// It seems "socket=socket-path" has been specified.
|
||||||
" only UNIX domain sockets are supported. Remove all 'port' and 'address'"
|
|
||||||
" parameters from this listener and add 'socket=default' to enable UNIX domain sockets.", socket_path);
|
// The colon etc. will be stripped away in dcb_listen_create_socket_unix.
|
||||||
return -1;
|
socket_path = config;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MXS_WARNING("The 'maxscaled' protocol can only be used with a domain socket, but "
|
||||||
|
"it seems to have been configured with a socket and port: %s. "
|
||||||
|
"Using the default socket path instead: %s. "
|
||||||
|
"Remove all 'port' and 'address' entries from maxscaled protocol "
|
||||||
|
"listeners and replace with 'socket=default' or 'socket=path-to-socket'.",
|
||||||
|
config, MAXADMIN_DEFAULT_SOCKET);
|
||||||
|
socket_path = MAXADMIN_DEFAULT_SOCKET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (dcb_listen(listener, socket_path, "MaxScale Admin") < 0) ? 0 : 1;
|
return (dcb_listen(listener, socket_path, "MaxScale Admin") < 0) ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user