diff --git a/include/maxscale/config.h b/include/maxscale/config.h index c5f685ba3..7a5b02918 100644 --- a/include/maxscale/config.h +++ b/include/maxscale/config.h @@ -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); diff --git a/server/core/config.c b/server/core/config.c index 1f2fb9a8c..3fcb650c2 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -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); diff --git a/server/core/config_runtime.c b/server/core/config_runtime.c index 3bd33f156..3a1631c1e 100644 --- a/server/core/config_runtime.c +++ b/server/core/config_runtime.c @@ -16,6 +16,7 @@ #include #include #include +#include #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)) {