Skip to content

Commit be7dbf2

Browse files
committed
clusterer: controller-support API, gated behind a build-time flag
Groundwork for clusterer_controller (added later in this series): an API the controller binds to, a way to declare which clusters it manages, and the hooks that let a controller-managed cluster take its identity at runtime instead of from the config. Declaring a managed cluster uses a per-cluster 'cluster_options' modparam - the same "key=value, key=value" idiom as my_node_info: modparam("clusterer", "cluster_options", "cluster_id=1, use_controller=1") cluster_id is required; use_controller is a 0/1 flag defaulting to 0 (native), and only use_controller=1 pre-creates the controller-managed stub, which never touches the DB and is guarded against hijacking a native cluster of the same id. Native clusters need no cluster_options line at all, and every other clusterer setting (db_mode, ping_*, my_node_id, sharing_tag, ...) stays a global modparam. The interim 'use_controller' / 'cluster_id' int modparams (never released) are kept registered only to fail with a migration hint. The managed-id set is exported through the ctrl binds (managed_count / managed_ids) so the controller can cross-check it pre-fork: a managed id with no matching 'cluster' config has no BIN socket or crypto params, and a 'cluster' config for an unmanaged id has nothing legitimate to drive. Either mismatch aborts at startup naming the offending id, rather than half-forming a cluster. All of it is compiled only under CLUSTERER_CTRL_SUPPORT: - the clusterer_ctrl API (clusterer_ctrl.c) and the cluster_options modparam plus the load_clusterer_ctrl_binds export; - the controller stub pre-create loop, the child_init guard, the shm current_id mirror, the on-demand stub, and the shtag_managed / controller_managed logic; - the per-cluster identity and hybrid-db_mode accessors (cluster_self_id, cl_db_mode, GET_CURRENT_ID, use_controller), which get #else fallbacks to the stock globals (current_id / db_mode / 0) so their call sites compile to the exact upstream object code with no per-site #ifdef. add_node_info's internal self_id parameter is gated the same way. The top-level Makefile exports CLUSTERER_CTRL_SUPPORT=1 iff clusterer_controller is in the configured build - derived from the include/exclude lists rather than the current 'modules' subset, so it is stable across 'make all' and a single-module rebuild - and clusterer/Makefile turns that into the -D. The point of the gate: a build without clusterer_controller produces the stock clusterer module. No cluster_options parameter (rejected as unknown), no behavioural change, no added exports. Verified with 'unifdef -UCLUSTERER_CTRL_SUPPORT' against the base - no semantic difference from upstream. Enabling the controller rebuilds clusterer with the hooks; the two are a matched pair.
1 parent 01d6f6d commit be7dbf2

12 files changed

Lines changed: 1293 additions & 66 deletions

File tree

‎Makefile‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ include Makefile.defs
7070
# always exclude the SVN dir
7171
override exclude_modules+= .svn $(skip_modules)
7272

73+
# The clusterer module exposes its controller-support API (and the extra
74+
# cluster_options modparam) only when the clusterer_controller module is part of
75+
# this build; otherwise it is a stock module. Mirror the module-selection rule
76+
# below (built if force-included, else unless excluded) and export the result so
77+
# clusterer/Makefile can define -DCLUSTERER_CTRL_SUPPORT. Derived from the
78+
# configured include/exclude lists (not the current 'modules' subset) so it stays
79+
# consistent whether you 'make all' or rebuild just modules/clusterer.
80+
ifneq ($(filter clusterer_controller,$(include_modules)),)
81+
export CLUSTERER_CTRL_SUPPORT:=1
82+
else ifeq ($(filter clusterer_controller,$(exclude_modules)),)
83+
export CLUSTERER_CTRL_SUPPORT:=1
84+
endif
85+
7386
#always include this modules
7487
#include_modules?=
7588

‎modules/clusterer/Makefile‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ NAME=clusterer.so
66
#DEFS+= -DCLUSTERER_DBG
77
#DEFS+= -DCLUSTERER_EXTRA_BIN_DBG
88

9+
# Controller support (the clusterer_ctrl API, the cluster_options modparam and
10+
# the controller hooks) is compiled only when the clusterer_controller module is
11+
# part of this build - the top-level Makefile exports CLUSTERER_CTRL_SUPPORT=1 in
12+
# that case. A stock build produces the vanilla clusterer module.
13+
ifeq ($(CLUSTERER_CTRL_SUPPORT),1)
14+
DEFS+= -DCLUSTERER_CTRL_SUPPORT
15+
endif
16+
917
include ../../Makefile.modules

0 commit comments

Comments
 (0)