Add default parameters to created monitors
When a monitor is created at runtime, it also needs to have the default parameters. Ideally, this would be done when the monitor is allocated but because of the way the configuration is processed, we need to do it after user defined parameters are added.
This commit is contained in:
parent
72ea3ad453
commit
eef0619865
@ -265,6 +265,19 @@ const char* config_get_string(const CONFIG_PARAMETER *params, const char *key);
|
||||
*/
|
||||
int config_get_enum(const CONFIG_PARAMETER *params, const char *key, const MXS_ENUM_VALUE *values);
|
||||
|
||||
/**
|
||||
* @brief Generate default module parameters
|
||||
*
|
||||
* Adds any default parameters to @c ctx that aren't already in it.
|
||||
*
|
||||
* @param ctx Configuration context where the parameters are added
|
||||
* @param module Module name
|
||||
* @param type Module type
|
||||
*
|
||||
* TODO: Move this to a header internal to the MaxScale core
|
||||
*/
|
||||
void config_add_defaults(CONFIG_CONTEXT *ctx, const char *module, const char *type);
|
||||
|
||||
char* config_clean_string_list(const char* str);
|
||||
CONFIG_PARAMETER* config_clone_param(const CONFIG_PARAMETER* param);
|
||||
void config_enable_feedback_task(void);
|
||||
|
@ -2384,7 +2384,7 @@ static int validate_ssl_parameters(CONFIG_CONTEXT* obj, char *ssl_cert, char *ss
|
||||
* @param ctx Configuration context where the default parameters are added
|
||||
* @param module Name of the module
|
||||
*/
|
||||
static void config_add_defaults(CONFIG_CONTEXT *ctx, const char *module, const char *type)
|
||||
void config_add_defaults(CONFIG_CONTEXT *ctx, const char *module, const char *type)
|
||||
{
|
||||
const MXS_MODULE *mod = get_module(module, type);
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <maxscale/config_runtime.h>
|
||||
#include <maxscale/gwdirs.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
#include <maxscale/modules.h>
|
||||
|
||||
#include "maxscale/service.h"
|
||||
|
||||
@ -336,6 +337,21 @@ static long get_positive_int(const char *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add default parameters to a monitor
|
||||
*
|
||||
* @param monitor Monitor to modify
|
||||
*/
|
||||
static void add_monitor_defaults(MONITOR *monitor)
|
||||
{
|
||||
/** Inject the default module parameters in case we only deleted
|
||||
* a parameter */
|
||||
CONFIG_CONTEXT ctx = {.object = ""};
|
||||
config_add_defaults(&ctx, monitor->module_name, MODULE_MONITOR);
|
||||
monitorAddParameters(monitor, ctx.parameters);
|
||||
config_parameter_free(ctx.parameters);
|
||||
}
|
||||
|
||||
bool runtime_alter_monitor(MONITOR *monitor, char *key, char *value)
|
||||
{
|
||||
spinlock_acquire(&crt_lock);
|
||||
@ -402,6 +418,8 @@ bool runtime_alter_monitor(MONITOR *monitor, char *key, char *value)
|
||||
CONFIG_PARAMETER p = {.name = key, .value = value};
|
||||
monitorAddParameters(monitor, &p);
|
||||
}
|
||||
|
||||
add_monitor_defaults(monitor);
|
||||
}
|
||||
|
||||
monitorStart(monitor, monitor->parameters);
|
||||
@ -560,6 +578,7 @@ bool runtime_create_monitor(const char *name, const char *module)
|
||||
{
|
||||
/** Mark that this monitor was created after MaxScale was started */
|
||||
monitor->created_online = true;
|
||||
add_monitor_defaults(monitor);
|
||||
|
||||
if (monitor_serialize(monitor))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user