Add redirect helpers to ha.c/ha.h so a standby controller never accepts join requests as if it were the primary: - ha_should_redirect(): returns 1 when role is STANDBY and primary_host/port are known — caller should send E_XCE_REDIRECT. - ha_no_primary_known(): returns 1 when role is STANDBY but primary address is not yet known — caller should send E_XCE_NOMASTER (retry later). - Add E_XCE_NOMASTER and E_XCE_REDIRECT to errnox.h. - Wire both guards into handle_join_() in join.c (before the role switch) so all join types (worker, scheduler, apiserver, client) are protected. - Full redirect response sends status=-E_XCE_REDIRECT with nodata body; the primary host:port are logged so operators can trace misrouted clients. Full Cap'n Proto RedirectInfo response body is deferred to a follow-up (schema union would require regenerating capnp bindings). 5 new TDD tests — 110 total, 0 failures.
27 lines
566 B
C
27 lines
566 B
C
#if !defined(__XCE_ERRNOX_H__)
|
|
|
|
#define __XCE_ERRNOX_H__ 1
|
|
|
|
#include <errno.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
#define XCE_ERRNO_BASE (10001)
|
|
|
|
enum {
|
|
E_XCE_BAD_JOB = XCE_ERRNO_BASE,
|
|
E_XCE_BAD_WORKER,
|
|
E_XCE_DUP_JOB,
|
|
E_XCE_DUP_WORKER,
|
|
E_XCE_BAD_OPCODE,
|
|
E_XCE_BAD_ROLE,
|
|
E_XCE_BAD_RES,
|
|
E_XCE_BAD_QUEUE,
|
|
E_XCE_BAD_GROUP,
|
|
E_XCE_INTERNAL,
|
|
E_XCE_NOMASTER, /* Standby has no known primary — client should retry */
|
|
E_XCE_REDIRECT, /* Standby is redirecting client to primary */
|
|
E_XCE_MAX
|
|
};
|
|
|
|
#endif
|