From 4880edd37329d624de9c9025c4e7340f1ee1e29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 22 Mar 2019 00:11:32 +0200 Subject: [PATCH] Fix removal of servers from monitors The last server wasn't removed as the set of relationships was empty. In addition to this, changes to relationships via the relations endpoint wasn't reflected by the monitor parameters. --- server/core/config_runtime.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index d6d1fae19..7b86e71b0 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -2263,6 +2263,15 @@ bool server_relationship_to_parameter(json_t* json, MXS_CONFIG_PARAMETER* params }); params->set(CN_SERVERS, servers); } + else if (json_t* rel = mxs_json_pointer(json, MXS_JSON_PTR_RELATIONSHIPS_SERVERS)) + { + if (json_is_array(rel) || json_is_null(rel)) + { + mxb_assert(json_is_null(rel) || json_array_size(rel) == 0); + // Empty relationship, remove the parameter + params->remove(CN_SERVERS); + } + } } return rval; @@ -2558,7 +2567,7 @@ bool runtime_alter_monitor_relationships_from_json(Monitor* monitor, json_t* jso "data", json_object_get(json, "data"))); - if (object_to_server_relations(monitor->m_name, old_json.get(), j.get())) + if (runtime_alter_monitor_from_json(monitor, j.get())) { rval = true; }