Skip to content

Let an instance be deployed as the control plane - #480

Merged
em3s merged 5 commits into
mainfrom
feat/control-role-topology
Aug 6, 2026
Merged

em3s merged 5 commits into
mainfrom
feat/control-role-topology

Conversation

@em3s

@em3s em3s commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Operational actions reach several clusters at once — a tenant's active and its standby — and every client carries its own table of which hostname is which. That table belongs in one place.

actionbase.role decides what an instance is. It defaults to DATA, so an existing deployment that sets nothing keeps behaving exactly as it does now, with no /control surface at all. CONTROL adds the operational endpoints.

One binary, two roles, deployed as separate processes with different config. A control instance carries storage drivers it never opens; that buys us one artifact, one image, one release instead of two, and the runtime isolation is the same either way. This is a departure from the original sketch of a standalone control-server module — the dependency argument for splitting turned out to be about image size, not correctness.

Nothing calls out to a cluster yet.

Part of #370

Changes

  • Add ServerRole and @ConditionalOnControlRole, mirroring @ConditionalOnHBaseDatastore
  • Add actionbase.control.tenants.*, resolved at startup so a relative or blank URL, or no tenants at all, fails the boot rather than the first request
  • Add GET /control/topology and /control/topology/{tenant}
  • Add ServerRoleRequestFilter: the two roles serve exclusive surfaces, DATA refusing /control and CONTROL refusing /graph/v2, /graph/v3 and /queue/v1
  • Add /control to the read-only filter's prefixes

Fanout is opt-in and forgiving: asking for the standby on an unpaired tenant reaches the active only, since a caller should not have to know which tenants are paired.

Roles serve exclusive surfaces

A control instance answering a graph query would run it against its own cluster rather than the one the caller meant, and a console pointed at the control plane could issue DDL there by accident. Leaving that to the routing layer leaves a direct hit on the pod unguarded, so one filter enforces it in both directions, reads included.

It refuses by data prefix rather than allowing only /control, because health lives at /graph/health: an allowlist would fail readiness on every control pod and take the actuator endpoints with it. PathPrefixes holds the prefix sets so this filter and the read-only one cannot come to disagree about what the data plane is.

A hole in the read-only exhaustiveness check

ReadOnlyRequestFilterTest claims that adding an endpoint without classifying it breaks the build. It did not. EndpointScanner evaluates @Conditional against a bare environment, so every conditionally registered controller dropped out of the scan and the check passed by not looking.

The /control endpoints escaped it, and so had thirteen HBase datastore endpoints since #478 and #479 added them — seven of them writes a read-only instance must refuse, including DELETE /graph/v3/datastore/hbase/tables/{tableName} and POST .../replication/enable. The scanner now satisfies the conditions, and everything it surfaces is classified. That part is a pre-existing gap rather than something this branch introduced, but it could not be fixed by halves.

How to Test

./gradlew :server:test --tests "*control.topology*" --tests "*RequestFilterTest*"

DefaultRoleE2ETest pins the compatibility claim: no role configured means DATA and a 404 on /control/topology. ControlRoleE2ETest pins the other side — a control instance 404s /graph/v3/databases and still answers /graph/health/liveness.

Not touched

Only the http surface is gated. A CONTROL instance still opens the datastore and initializes the graph, since that configuration is required of every instance; skipping it reaches into readiness and warm-up, and is better done once we know the deployment shape. Note that kc.graph.warmup must stay off on a control instance — it calls the data plane it is refused.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 5)

Operational actions reach several clusters at once - a tenant's active and its standby - and today
every client carries its own table of which hostname is which. That table belongs in one place.

`actionbase.role` decides what an instance is. It defaults to `DATA`, so an existing deployment
that sets nothing keeps behaving exactly as it does now, with no `/control` surface at all. Setting
`CONTROL` adds the operational endpoints.

One binary, two roles, deployed as separate processes with different config. A control instance
carries storage drivers it never opens; that is the price of not maintaining a second artifact,
image, and release, and the runtime isolation is the same either way.

Topology is deployment config resolved at startup, so a relative or blank URL fails the boot rather
than the first request. Fanout is opt-in and forgiving: asking for the standby on an unpaired
tenant reaches the active only, since a caller should not have to know which tenants are paired.

`/control` joins the read-only filter's prefixes so a future write there is refused in read-only
mode. Nothing calls out to a cluster yet.

Part of #370
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 6, 2026
em3s and others added 4 commits August 6, 2026 22:10
ReadOnlyRequestFilterTest claims that adding an endpoint without
classifying it breaks the build. It does not: EndpointScanner evaluates
@conditional against a bare environment, so every conditionally
registered controller drops out of the scan and the check passes by not
looking. The /control endpoints escaped it, and so had thirteen HBase
datastore endpoints since they were added - seven of them writes that a
read-only instance must refuse.

Satisfy the conditions in the scanner and classify what becomes visible.
The control prefix also gets a filter test of its own, since every
/control endpoint is a GET today and nothing else would notice if the
prefix were dropped from the filter.

Also: fail the boot when a CONTROL instance configures no tenants, same
reasoning as the url checks; pin the unknown-tenant 400 over HTTP; move
the topology model out of the api package, since env and side become
authorization inputs and non-api code should not reach into api to get
them; and note that namespace is declared rather than reconciled.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A control instance answering a graph query would run it against its own
cluster rather than the one the caller meant, and a console pointed at
the control plane could issue DDL there by accident. The routing layer
was the only thing standing in the way, which leaves a direct hit on the
pod unguarded.

One filter, both directions: DATA refuses /control, CONTROL refuses the
data prefixes, reads included. It refuses by data prefix rather than
allowing only /control because health lives under /graph - an allowlist
would fail readiness on every control pod and take the actuator
endpoints with it.

The prefix sets move to PathPrefixes so this filter and the read-only
one cannot come to disagree about what the data plane is. The endpoint
classification grows a CONTROL set, and both filter tests now decide
against the same four sets, so the exhaustiveness check carries both.

The http surface is all this gates. A control instance still opens the
datastore and initializes the graph, because that configuration is
required of every instance; that one is left for later.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Turning kc.graph.use-token on protected the data plane and left the
control plane open: protectedPaths named /graph/v2 and /graph/v3 only, so
/control/topology answered any caller with the tenant list, their
environments and namespaces. An operator enabling auth has no reason to
expect the newer surface to be exempt, and the cross-cluster operations
that land under the same prefix next would inherit the exemption.

The filter had no test. It has one now, including that the probes still
answer unauthenticated - protecting those would fail readiness on every
pod.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The token filter still spelled its prefixes out, which is how it came to
disagree with the others about what is worth protecting in the first
place. Splitting GRAPH from QUEUE names the slice each filter actually
wants, and leaves the queue omission visible in the code rather than
buried in a literal - a test pins it as a decision instead of an
accident.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@em3s
em3s merged commit 6f1d73f into main Aug 6, 2026
2 checks passed
@em3s
em3s deleted the feat/control-role-topology branch August 6, 2026 13:49
@em3s em3s mentioned this pull request Aug 6, 2026
1 task done
@em3s em3s self-assigned this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant