From fbea347191f6385c51f051af4f53ccd1180a5566 Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <alain.takoudjou@nexedi.com>
Date: Fri, 5 Aug 2022 11:07:48 +0200
Subject: [PATCH] repman: fix problem while requesting slave with cluster bad
 cluster name

If cluster name is not found, use default cluster name
---
 software/repman/buildout.hash.cfg             | 2 +-
 software/repman/instance-repman.cfg.jinja2.in | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/software/repman/buildout.hash.cfg b/software/repman/buildout.hash.cfg
index 5967ef34e..9f2e9f29a 100644
--- a/software/repman/buildout.hash.cfg
+++ b/software/repman/buildout.hash.cfg
@@ -18,7 +18,7 @@ md5sum = 55c7fd4dd6a39b31878889fbfb00f995
 
 [instance-repman.cfg]
 _update_hash_filename_ = instance-repman.cfg.jinja2.in
-md5sum = 6fc82c4b645bceb97ba7b6f5b56d161b
+md5sum = dc01433ffed82386a3feee0b34767bed
 
 [config-toml.in]
 _update_hash_filename_ = templates/config.toml.in
diff --git a/software/repman/instance-repman.cfg.jinja2.in b/software/repman/instance-repman.cfg.jinja2.in
index 4251d20ec..f80ea64db 100644
--- a/software/repman/instance-repman.cfg.jinja2.in
+++ b/software/repman/instance-repman.cfg.jinja2.in
@@ -110,6 +110,9 @@ output = ${directory:bin}/update-proxysql-config
   'cluster_id': instance_dict.get('cluster_id', default_slave_cluster_id),
   'require_ssl': True
   } -%}
+{% if not slave_dict['cluster_id'] in cluster_name_list -%}
+{% do slave_dict.__setitem__('cluster_id', default_slave_cluster_id) -%}
+{% endif -%}
 {% do slave_information_list.append(slave_dict) -%}
 {% do database_slave_dict[slave_dict['cluster_id']].append(slave_dict) -%}
 {% do db_name_dict[slave_dict['cluster_id']].append([slave_dict['name'], slave_dict['user']]) -%}
-- 
2.30.9