mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-08-31 08:57:14 +02:00
Replace the free-form service_type string with a ServiceType enum (ccms, ccmc, ccb, cces, ccsa, ccnc, ccem). The short code is the canonical value stored in the DB, the config-tree directory name and a NATS discovery subject token; Description() gives the human-readable name. Add a second scope alongside per-node agents: ScopeInfra covers cluster-independent monitoring infrastructure services, which are identified by (hostname, service_type) and carry an empty cluster. InfraRegistry is the ScopeInfra sibling of Registry and shares the same table, state machine and config-revision handshake. It deliberately exposes no StartSweep: MarkStale ages rows by last_heartbeat regardless of scope, so a single sweep goroutine per process covers both scopes. On the repository side ServiceDB gains a Scope column and the two queries the discovery publisher and infra enumeration need, ListActive() and ListByScope(). ResetConnection() now also resets the fleet repository singleton so tests get a fresh handle. Migration 13 is edited in place rather than superseded by a new migration: the service table is unreleased, so no existing deployment has it yet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
24 lines
878 B
SQL
24 lines
878 B
SQL
CREATE TABLE "service" (
|
|
id INTEGER PRIMARY KEY,
|
|
cluster VARCHAR(255) NOT NULL,
|
|
hostname VARCHAR(255) NOT NULL,
|
|
service_type VARCHAR(255) NOT NULL,
|
|
instance_id VARCHAR(64) NOT NULL,
|
|
scope VARCHAR(32) NOT NULL DEFAULT 'cluster'
|
|
CHECK (scope IN ('cluster', 'infra')),
|
|
state VARCHAR(32) NOT NULL DEFAULT 'pending'
|
|
CHECK (state IN ('pending', 'active', 'stale', 'deregistered')),
|
|
registered_at INTEGER NOT NULL,
|
|
last_heartbeat INTEGER,
|
|
config_revision INTEGER NOT NULL DEFAULT 0,
|
|
meta_data TEXT, -- JSON
|
|
UNIQUE (cluster, hostname, service_type),
|
|
UNIQUE (instance_id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS services_cluster ON service (cluster);
|
|
CREATE INDEX IF NOT EXISTS services_scope ON service (scope);
|
|
CREATE INDEX IF NOT EXISTS services_state_heartbeat ON service (state, last_heartbeat);
|
|
|
|
PRAGMA optimize;
|