feat: ha_should_redirect + join.c HA redirect/nomaster guard (P1-6)
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.
This commit is contained in:
parent
c627f69d50
commit
f5b0ac0af3
7 changed files with 191 additions and 0 deletions
|
|
@ -85,6 +85,7 @@ controller_unit_test_src = [
|
|||
'testsuite/test_e2e_capnp.c',
|
||||
'testsuite/test_ha_role.c',
|
||||
'testsuite/test_ha_cluster.c',
|
||||
'testsuite/test_ha_redirect.c',
|
||||
'persist.c',
|
||||
'ha.c',
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue