Skip to content

Commit 1b1df76

Browse files
committed
clusterer_controller: an MI reload of the DB clusters keeps the controller clusters
clusterer:reload replaced the whole cluster list with what the DB holds, so on a node with DB clusters beside controller clusters it dropped the controller clusters from clusterer - their nodes, sharing tags' cluster and the capabilities tm and dialog registered on them. They now move into the reloaded list as they are, and a DB cluster with the id of one of them makes the reload fail.
1 parent dc87bb9 commit 1b1df76

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎modules-contrib/clusterer_controller/clusterer_mod.c‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ mi_response_t *clusterer_reload(const mi_params_t *params,
882882
{
883883
cluster_info_t *new_info;
884884
cluster_info_t *old_info;
885+
cluster_info_t *cl, *new_cl, **old_next, **new_tail;
885886

886887
if (!db_mode) {
887888
LM_ERR("Running in non-DB mode\n");
@@ -894,6 +895,19 @@ mi_response_t *clusterer_reload(const mi_params_t *params,
894895
}
895896

896897
lock_start_write(cl_list_lock);
898+
for (cl = *cluster_list; cl; cl = cl->next) {
899+
if (!cl->controller_managed)
900+
continue;
901+
for (new_cl = new_info; new_cl; new_cl = new_cl->next)
902+
if (new_cl->cluster_id == cl->cluster_id) {
903+
lock_stop_write(cl_list_lock);
904+
LM_ERR("cluster %d in the DB is controller-managed here - "
905+
"not reloaded\n", cl->cluster_id);
906+
free_info(new_info);
907+
return init_mi_error(400,
908+
MI_SSTR("DB defines a controller-managed cluster"));
909+
}
910+
}
897911
if (preserve_reg_caps(new_info) < 0) {
898912
lock_stop_write(cl_list_lock);
899913
LM_ERR("Failed to preserve registered capabilities\n");
@@ -904,6 +918,18 @@ mi_response_t *clusterer_reload(const mi_params_t *params,
904918
return init_mi_error(500, "Failed to reload", 16);
905919
}
906920
old_info = *cluster_list;
921+
/* the controller clusters are not in the DB: they move over as they are */
922+
for (new_tail = &new_info; *new_tail; new_tail = &(*new_tail)->next) ;
923+
for (old_next = &old_info; (cl = *old_next); ) {
924+
if (cl->controller_managed) {
925+
*old_next = cl->next;
926+
cl->next = NULL;
927+
*new_tail = cl;
928+
new_tail = &cl->next;
929+
} else {
930+
old_next = &cl->next;
931+
}
932+
}
907933
*cluster_list = new_info;
908934
lock_stop_write(cl_list_lock);
909935

0 commit comments

Comments
 (0)