Dynamic trunk add/remove via Redis pub/sub

Reflector::onRedisConfigChanged now handles 'trunk:<section>' events by
reading the trunk:<section>:peer hash from Redis:
  - peer present + no local link  -> create new TrunkLink
  - peer absent + local link       -> destroy local TrunkLink (Redis-managed only)
  - both present                   -> reload filters (existing behavior)
  - neither                        -> log and ignore

Tracks which sections were loaded from Redis (m_redis_trunk_sections) so
conf-based test trunks (e.g. TRUNK_TEST) correctly fall back to
reloadConfig() rather than being destroyed on a filter-change event.

Dashboards can now add/remove trunk peers without restarting the reflector.
This commit is contained in:
Audric committed 2026-04-15 15:09:17 +02:00
1 parent 9c6f27e12b
commit 1d639dd0b0
2 files changed
+111 -2

No files matched your search

+4
View File
@@ -319,6 +319,7 @@ class Reflector : public sigc::trackable
Json::Value m_status;
std::vector<TrunkLink*> m_trunk_links;
std::set<std::string> m_redis_trunk_sections; // sections loaded from Redis
std::set<uint32_t> m_cluster_tgs;
bool m_trunk_debug = false;
Async::Timer m_nodelist_timer;
@@ -368,6 +369,9 @@ class Reflector : public sigc::trackable
std::string new_cs);
void onRedisConfigChanged(std::string scope);
void reloadClusterTgs(void);
bool addTrunkLink(const std::string& section);
bool removeTrunkLink(const std::string& section);
std::vector<std::string> collectAllTrunkPrefixes(void) const;
void refreshStatus(void);
void initTrunkLinks(void);
void initTrunkServer(void);