Documentation
¶
Overview ¶
Package domain defines core cluster entities, host identities, credentials, health reports, and scaling requests shared across chinit services and ports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CoordinatorRole ¶
type CoordinatorRole string
CoordinatorRole is which coordinator shape this node runs: keepers self-resize (the coordinator is keeper-0; peers first in the multi-keeper shape, self last), writers roll the ASG (the ordinal-0 maintenance holder).
const ( // CoordinatorKeeper is the keeper-0 self-resize path. CoordinatorKeeper CoordinatorRole = "keeper" // CoordinatorWriter is the writers' ordinal-0 fleet-roll path. CoordinatorWriter CoordinatorRole = "writer" // CoordinatorNone: this node holds no coordinator designation // this tick (readers/backup scale horizontally; non-ordinal-0 // writers skip — the timer's no-op exit). CoordinatorNone CoordinatorRole = "none" )
type Credentials ¶
type Credentials struct {
// Username is the ClickHouse user to connect as.
Username string
// Password is the plaintext password.
Password string
}
Credentials are ClickHouse connection credentials for control operations. Callers resolve them from the cloud secret store at use time; they never live in spec files.
type HostIdentity ¶
type HostIdentity struct {
// Cloud is the provider short name ("aws", "azure", "gcp").
Cloud string
// Region is the node's cloud region.
Region string
// ProviderID is the cloud-native instance/VM ID.
ProviderID string
// Name is the hostname the cluster knows the node by (ClickHouse
// replica naming keys off this).
Name string
// Address is the resolvable address (IP or DNS) of the node.
Address string
// Role is the node's cluster role.
Role Role
// ScalingGroup names the ASG / VMSS / MIG the node belongs to.
ScalingGroup string
}
HostIdentity identifies one cluster node, cloud-neutrally. Callers fill it from instance metadata or scaling-group listings.
type QueueHealRequest ¶
type QueueHealRequest struct {
// RunOn is the node whose replication queue is inspected and healed.
RunOn string
// StuckTries is the num_tries threshold above which a queue
// entry counts as stuck (0 uses the default, 1000).
StuckTries int
// BusyMergesSkip leaves a node with any running merge untouched
// when true, restarting only when the merge pool is idle.
BusyMergesSkip bool
// Table is the specific table to restart (database.table). Empty
// means every stuck table found by the detection pass.
Table string
}
QueueHealRequest asks the schema service to detect and recover a node's blocked replication queue.
type ReplicaDropRequest ¶
type ReplicaDropRequest struct {
// HostName is the replica being removed.
HostName string
// RunOn is the peer that executes SYSTEM DROP REPLICA.
RunOn string
}
ReplicaDropRequest asks the schema service to remove a dead replica's registration, executed against a live peer.
type ReplicaGcRequest ¶
type ReplicaGcRequest struct {
// RunOn is the peer that executes the detection and drop SQL.
RunOn string
// NamePattern is a path.Match glob (e.g. "reader-*") that a stale
// host name must match to be dropped. Semantics follow Go's
// path.Match: * and ? wildcards, no separator matching, case
// sensitive.
NamePattern string
// ExcludeHosts are exact host names a matching stale host must
// never be dropped for, even though it still appears in Stale (the
// caller's liveness guard: chinit's writer GC pass lists the
// cluster's active ordinal leases and excludes every live writer,
// so a mid-boot re-join whose lease is renewed never loses its
// registration to the weekly sweep). Empty means no exclusion.
ExcludeHosts []string
}
ReplicaGcRequest asks the schema service to detect stale replica registrations on a peer and drop them — the dead-replica GC. Detection and drop both run against RunOn; the pattern gates which detected hosts are eligible, so a GC sweep can never reap a writer or keeper that the pattern does not name.
func (ReplicaGcRequest) NewExcludeSet ¶
func (r ReplicaGcRequest) NewExcludeSet() map[string]bool
NewExcludeSet builds the drop-loop's membership check. A nil request (or empty list) yields a nil map, and the loop skips the lookup entirely — the default shape (no excludes) keeps its zero cost.
type ReplicaSyncRequest ¶
type ReplicaSyncRequest struct {
// HostName is the node that re-queues replication.
HostName string
}
ReplicaSyncRequest asks the schema service to re-queue replication on a restarted node.
type Role ¶
type Role string
Role enumerates a node's cluster role.
const ( // RoleWriter is an ingest-facing ClickHouse server. RoleWriter Role = "writer" // RoleReader is a query-facing ClickHouse server. RoleReader Role = "reader" // RoleKeeper is a ClickHouse Keeper (Raft) node. RoleKeeper Role = "keeper" // RoleBackup is the dedicated backup replica (a replicated-table // member; CR slot after the readers' ceiling). RoleBackup Role = "backup" )
type ScaleDecision ¶
type ScaleDecision struct {
// Signals is what the tick observed.
Signals ScaleSignals
// Breach is whether thresholds judged pressure.
Breach bool
// Action names the execution step: "" (no-op), "keeper-self",
// "keeper-peer", "writer-roll".
Action string
// From/To are the ladder step when Action != "".
From, To string
// Reason is the human line (the journal contract).
Reason string
}
ScaleDecision is the coordinator's verdict for one tick: what it saw, what it concluded, and what it will (or will not) do. The record the CLI prints and the tests assert — a decision is data.
type ScaleSignals ¶
type ScaleSignals struct {
// KeeperMaxLatencyMs is the ensemble's max request latency (ms).
KeeperMaxLatencyMs float64
// KeeperOutstanding is the ensemble's outstanding-request count.
KeeperOutstanding float64
// KeeperCPUIdlePct is the coordinator's own CPU idle (100-idle
// = busy; the keeper's own node is the ensemble's signal source).
KeeperCPUIdlePct float64
// WriterCPUIdlePct is the busiest writer's average CPU idle percentage.
WriterCPUIdlePct float64
}
ScaleSignals is the autoscale decision input: the metric readings one tick observed, with the thresholds a breach is judged against. The values are the BREACH-SIDE aggregates (the least pressure seen in the window — every sample must have breached; one noisy minute never steps a fleet, the alarm's evaluation_periods parity).
type ScaleThresholds ¶
type ScaleThresholds struct {
// KeeperLatencyMs: at-or-beyond = breach.
KeeperLatencyMs float64
// KeeperOutstanding: at-or-beyond = breach.
KeeperOutstanding float64
// KeeperCPUIdlePct: at-or-below = breach (idle LOW = busy).
KeeperCPUIdlePct float64
// KeeperScaleDownIdlePct: at-or-above (with low latency/outstanding) = step down.
KeeperScaleDownIdlePct float64
// WriterCPUIdlePct: at-or-below = breach (the fleet signal).
WriterCPUIdlePct float64
// WriterScaleDownIdlePct: at-or-above = step down toward writer_min_type.
WriterScaleDownIdlePct float64
}
ScaleThresholds is the breach line: a signal at-or-beyond (idle: at-or-below) its threshold is pressure; idle at-or-above the scale-down line is sustained under-utilization eligible to step down one rung toward Min.
func DefaultScaleThresholds ¶
func DefaultScaleThresholds() ScaleThresholds
DefaultScaleThresholds mirrors the CloudWatch alarms' defaults the autoscale path inherits (keeper-max-latency 5000ms — cumulative-window MAX in KeeperConnectionStats::getMaxLatency(); keeper-outstanding-requests 10; the CPU idle lines at the fleet's scale-out/scale-in triggers).
func (ScaleThresholds) KeeperBreach ¶
func (t ScaleThresholds) KeeperBreach(s ScaleSignals) bool
KeeperBreach answers whether any keeper signal breached.
func (ScaleThresholds) KeeperIdle ¶ added in v0.1.2
func (t ScaleThresholds) KeeperIdle(s ScaleSignals) bool
KeeperIdle answers whether keeper signals indicate sustained idle eligible for a one-rung vertical step down toward keeper_min_type.
func (ScaleThresholds) WriterBreach ¶
func (t ScaleThresholds) WriterBreach(s ScaleSignals) bool
WriterBreach answers whether the fleet CPU signal breached.
func (ScaleThresholds) WriterIdle ¶ added in v0.1.2
func (t ScaleThresholds) WriterIdle(s ScaleSignals) bool
WriterIdle answers whether the writer fleet CPU idle sits at or above the vertical scale-down threshold (e.g. >= 85% idle = <= 15% busy across the entire evaluation window).
type SchemaSyncRequest ¶
type SchemaSyncRequest struct {
// HostName is the node whose schema is (re)created from cluster peers
// (the new-reader boot case). Either a CR name ("0-1") or a cloud name
// ("reader-0") resolves; for PruneStaleSelf it must be the replica
// identity the deployment's macros declare (the cloud short name)
// the same name `replica drop` takes.
HostName string
// Retries bounds the number of full create passes (0 = the service
// default, 2). A pass that succeeds ends the loop early; the last
// pass's error is returned.
//
// Why more than one pass: the operator's per-SQL retry re-runs failed
// statements, but ordering across a fresh pass is not guaranteed — a
// materialized view whose TO-target table lands later in the same
// batch needs a second deterministic pass (one MV
// left uncreated until a manual second run).
Retries int
// PruneStaleSelf reclaims the target's OWN stale Keeper registration
// when a create pass fails with Code 253 ("Replica
// .../replicas/<host> already exists") — an ASG/VMSS replacement node
// re-claiming an ordinal whose dead predecessor left a PERSISTENT
// znode. The service runs the `replica drop` pair for the name the
// failed pass reports, then retries the create pass. Safe by
// construction: only the registration the target itself is about to
// claim is ever dropped, never any other host's.
PruneStaleSelf bool
// RunOn is the host the prune drop executes on. Empty = HostName: the
// same host the create pass executes on (HostCreateTables runs its SQL
// on the target itself). A fresh replacement node is schemaless, so
// running the drop there removes only the dead predecessor's
// registration — no peer flag is needed.
RunOn string
}
SchemaSyncRequest asks the schema service to create all objects on a host.
type SpecReference ¶
type SpecReference struct {
// Name is the metadata.name of the CHI (or CHK).
Name string
// Namespace groups specs per environment (informational off-cluster;
// it keeps parity with the operator's naming).
Namespace string
// Data is the raw spec document bytes.
Data []byte
}
SpecReference names a cluster spec document and how to read it.
type TableRef ¶
type TableRef struct {
// Database is the table's database (empty for server-default).
Database string
// Name is the table name.
Name string
}
TableRef names one table (database + name) — the unit of the tables-present health check: expected names parsed from the spec's SQL files vs. existing names read from system.tables.
type TypeLadder ¶
type TypeLadder struct {
// Types is the ascending instance-type list ("t4g.medium" ..).
Types []string
// Min is the ladder floor (a step below it is refused; the
// dev-shape posture sets the floor above the smallest type).
Min string
// Max is the ladder ceiling (a step past it is refused — the
// runaway cap; the cooldown paces, the ceiling bounds).
Max string
}
TypeLadder is the bounded vertical-scaling ladder for one role: the ascending instance types the coordinator may step through, with the floor and ceiling the steps respect.
func (TypeLadder) AtOrAboveMax ¶
func (l TypeLadder) AtOrAboveMax(current string) bool
AtOrAboveMax answers whether current sits at (or past) the ceiling — the "already at max" decision input. An unset ceiling answers false only when current is the ladder's LAST entry (the end is always the ceiling; the Max field tightens it further).
func (TypeLadder) AtOrBelowMin ¶ added in v0.1.2
func (l TypeLadder) AtOrBelowMin(current string) bool
AtOrBelowMin answers whether current sits at (or below) the ladder floor — the "already at min" decision input for vertical scale-down.
func (TypeLadder) Next ¶
func (l TypeLadder) Next(current string) (next string, ok bool)
Next answers the step strictly above current, within bounds. ok is false at the ceiling, below the floor, or when current is not on the ladder (an unknown type never steps — the coordinator logs and stops rather than guessing).
func (TypeLadder) Prev ¶ added in v0.1.2
func (l TypeLadder) Prev(current string) (prev string, ok bool)
Prev answers the step strictly below current, within bounds (vertical scale-down when pressure subsides). ok is false at or below the floor, above the ceiling, or when current is not on the ladder.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fail classifies errors as Retryable or Fatal for the chinit retry engine.
|
Package fail classifies errors as Retryable or Fatal for the chinit retry engine. |
|
Package model defines the declarative node specification (BootSpec), settled node identity (NodeIdentity), disruption budgets, and lifecycle hook models.
|
Package model defines the declarative node specification (BootSpec), settled node identity (NodeIdentity), disruption budgets, and lifecycle hook models. |
|
Package port declares the boundary interfaces between chinit's domain services and infrastructure adapters, including the cloud Provider registry and optional cloud capabilities (ordinal leases, private DNS, spot signals, volume growth, fleet tasks, and node status publishing).
|
Package port declares the boundary interfaces between chinit's domain services and infrastructure adapters, including the cloud Provider registry and optional cloud capabilities (ordinal leases, private DNS, spot signals, volume growth, fleet tasks, and node status publishing). |
|
Package service implements chinit's convergent boot pipeline, retry engine, state persistence, configuration rendering, and recurring cluster maintenance operations.
|
Package service implements chinit's convergent boot pipeline, retry engine, state persistence, configuration rendering, and recurring cluster maintenance operations. |
|
conformance
Package conformance provides a reusable test suite that verifies cloud Provider implementations against chinit's mandatory and optional capability contracts.
|
Package conformance provides a reusable test suite that verifies cloud Provider implementations against chinit's mandatory and optional capability contracts. |