MXS-1647: Detect API version mismatch
If the API versions do not match, MaxScale will treat this as an error. The API versioning would allow backwards compatible changes but the functionality to handle that is not implemented in MaxScale. Updated API versions based on changes done to module APIs in 2.2.
This commit is contained in:
parent
6132ebd24f
commit
4089b6b6fd
@ -214,7 +214,7 @@ typedef struct mxs_filter_object
|
||||
* is changed these values must be updated in line with the rules in the
|
||||
* file modinfo.h.
|
||||
*/
|
||||
#define MXS_FILTER_VERSION {2, 2, 0}
|
||||
#define MXS_FILTER_VERSION {3, 0, 0}
|
||||
|
||||
/**
|
||||
* MXS_FILTER_DEF represents a filter definition from the configuration file.
|
||||
|
@ -95,7 +95,7 @@ typedef struct mxs_monitor_object
|
||||
* The monitor API version number. Any change to the monitor module API
|
||||
* must change these versions using the rules defined in modinfo.h
|
||||
*/
|
||||
#define MXS_MONITOR_VERSION {3, 0, 0}
|
||||
#define MXS_MONITOR_VERSION {3, 1, 0}
|
||||
|
||||
/**
|
||||
* Specifies capabilities specific for monitor.
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define QUERY_CLASSIFIER_VERSION {1, 1, 0}
|
||||
#define MXS_QUERY_CLASSIFIER_VERSION {2, 0, 0}
|
||||
|
||||
/**
|
||||
* qc_init_kind_t specifies what kind of initialization should be performed.
|
||||
|
@ -218,7 +218,7 @@ typedef struct mxs_router_object
|
||||
* must update these versions numbers in accordance with the rules in
|
||||
* modinfo.h.
|
||||
*/
|
||||
#define MXS_ROUTER_VERSION { 2, 0, 0 }
|
||||
#define MXS_ROUTER_VERSION { 3, 0, 0 }
|
||||
|
||||
/**
|
||||
* Specifies capabilities specific for routers. Common capabilities
|
||||
|
@ -3526,7 +3526,7 @@ extern "C"
|
||||
{
|
||||
MXS_MODULE_API_QUERY_CLASSIFIER,
|
||||
MXS_MODULE_IN_DEVELOPMENT,
|
||||
QUERY_CLASSIFIER_VERSION,
|
||||
MXS_QUERY_CLASSIFIER_VERSION,
|
||||
"Query classifier based upon MySQL Embedded",
|
||||
"V1.0.0",
|
||||
MXS_NO_MODULE_CAPABILITIES,
|
||||
|
@ -5037,7 +5037,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_MODULE_API_QUERY_CLASSIFIER,
|
||||
MXS_MODULE_BETA_RELEASE,
|
||||
QUERY_CLASSIFIER_VERSION,
|
||||
MXS_QUERY_CLASSIFIER_VERSION,
|
||||
"Query classifier using sqlite.",
|
||||
"V1.0.0",
|
||||
MXS_NO_MODULE_CAPABILITIES,
|
||||
|
@ -32,6 +32,12 @@
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/json_api.h>
|
||||
#include <maxscale/modulecmd.h>
|
||||
#include <maxscale/protocol.h>
|
||||
#include <maxscale/router.h>
|
||||
#include <maxscale/filter.h>
|
||||
#include <maxscale/authenticator.h>
|
||||
#include <maxscale/monitor.h>
|
||||
#include <maxscale/query_classifier.h>
|
||||
|
||||
#include "internal/modules.h"
|
||||
#include "internal/config.h"
|
||||
@ -78,6 +84,56 @@ static LOADED_MODULE* register_module(const char *module,
|
||||
MXS_MODULE *mod_info);
|
||||
static void unregister_module(const char *module);
|
||||
|
||||
static bool api_version_mismatch(const MXS_MODULE *mod_info, const char* module)
|
||||
{
|
||||
bool rval = false;
|
||||
MXS_MODULE_VERSION api = {};
|
||||
|
||||
switch (mod_info->modapi)
|
||||
{
|
||||
case MXS_MODULE_API_PROTOCOL:
|
||||
api = MXS_PROTOCOL_VERSION;
|
||||
break;
|
||||
|
||||
case MXS_MODULE_API_AUTHENTICATOR:
|
||||
api = MXS_AUTHENTICATOR_VERSION;
|
||||
break;
|
||||
|
||||
case MXS_MODULE_API_ROUTER:
|
||||
api = MXS_ROUTER_VERSION;
|
||||
break;
|
||||
|
||||
case MXS_MODULE_API_MONITOR:
|
||||
api = MXS_MONITOR_VERSION;
|
||||
break;
|
||||
|
||||
case MXS_MODULE_API_FILTER:
|
||||
api = MXS_FILTER_VERSION;
|
||||
break;
|
||||
|
||||
case MXS_MODULE_API_QUERY_CLASSIFIER:
|
||||
api = MXS_QUERY_CLASSIFIER_VERSION;
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_ERROR("Unknown module type: 0x%02hhx", mod_info->modapi);
|
||||
ss_dassert(!true);
|
||||
break;
|
||||
}
|
||||
|
||||
if (api.major != mod_info->api_version.major ||
|
||||
api.minor != mod_info->api_version.minor ||
|
||||
api.patch != mod_info->api_version.patch)
|
||||
{
|
||||
MXS_ERROR("API version mismatch for '%s': Need version %d.%d.%d, have %d.%d.%d",
|
||||
module, api.major, api.minor, api.patch, mod_info->api_version.major,
|
||||
mod_info->api_version.minor, mod_info->api_version.patch);
|
||||
rval = true;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static bool check_module(const MXS_MODULE *mod_info, const char *type, const char *module)
|
||||
{
|
||||
bool success = true;
|
||||
@ -118,6 +174,12 @@ static bool check_module(const MXS_MODULE *mod_info, const char *type, const cha
|
||||
MXS_ERROR("Module '%s' does not implement the query classifier API.", module);
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (api_version_mismatch(mod_info, module))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (mod_info->version == NULL)
|
||||
{
|
||||
MXS_ERROR("Module '%s' does not define a version string", module);
|
||||
|
Loading…
x
Reference in New Issue
Block a user