feat(scheduler-core): register picker plugin category + job_elect_fn compat wrapper (task 1.2)

plugin_register() now adapts an old-style job_elect_fn-only plugin to
xce_job_picker_iface_t via legacy_picker_wrapper_iface (next_job()
forwards to job_elect_fn; other hooks are safe no-ops covered elsewhere
in the existing lifecycle), logging a one-time deprecation warning. A
plugin that already sets picker_iface directly skips the wrapper and
the warning. Reuses the existing plugin_register()/key_find() mechanism
-- no parallel registration system.

Requirements: 1.6, 2.5
This commit is contained in:
Rongsong Shen 2026-08-03 05:23:53 +00:00
parent 065025a3a6
commit 4d8d72142e
5 changed files with 409 additions and 2 deletions

View file

@ -53,6 +53,13 @@ typedef struct {
plugin_job_rusage_hook_t rusage_hook;
} plugin_hooks_t;
/* Forward declaration -- xce_job_picker_iface_t is fully defined below
* (Req 1 AC 2). Only needed here as a pointer field on xce_sched_plugin_t
* (picker plugin registration category, scheduler-core task 1.2);
* re-declared as the same typedef once the struct body is complete below
* -- same idiom as cluster_t across myconf.h/persist.h/ha.h/cluster_def.h. */
typedef struct xce_job_picker_iface_s xce_job_picker_iface_t;
typedef struct {
char* name;
void* sched;
@ -65,6 +72,14 @@ typedef struct {
plugin_job_allocate_fn_t job_alloc_fn;
plugin_hooks_t hooks;
plugin_data_t data;
/* Picker plugin registration category (task 1.2): non-NULL once this
* plugin participates in the xce_job_picker_iface_t contract -- either
* because it was authored against the new interface directly, or
* because plugin_register() adapted it from the deprecated job_elect_fn
* hook via the compatibility wrapper (Req 5 "Migration from old
* job_elect_fn"). Stays NULL for plugin categories that are neither
* (allocator/limit plugins never set job_elect_fn). */
xce_job_picker_iface_t* picker_iface;
} xce_sched_plugin_t;
extern int plugin_register(void*, void*);
@ -175,7 +190,7 @@ typedef struct xce_sched_core_s xce_sched_core_t;
* - next_job() returns NULL exactly when no ready job remains for the
* current session.
*/
typedef struct {
typedef struct xce_job_picker_iface_s {
int (*init)(void* picker, xce_sched_core_t* core);
void (*fini)(void* picker);
int (*begin_session)(void* picker);