mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 12:41:30 +00:00
auth-bundle-1 fix: bundled certctl-agent restart loop (latent since 2026-03-14)
The bundled `docker-compose.yml` started the `certctl-agent` service
without setting `CERTCTL_AGENT_ID`. `cmd/agent/main.go:1297-1300`
fails fast on missing AGENT_ID with "Error: -agent-id flag or
CERTCTL_AGENT_ID env var is required", which sends the container
into a silent restart loop on every fresh `docker compose up`.
Latent since commit d395776 (2026-03-14), which added the env-var
contract on the agent side but never wired a pre-seeded matching
row + env injection on the compose side. The integration test
compose (`docker-compose.test.yml`) does set CERTCTL_AGENT_ID +
seed agent-test-01 via seed_test.sql, which is why CI didn't
surface the bug. Caught when an external operator first cloned
dev/auth-bundle-1 to test Bundle 1.
Closure mirrors the integration-test pattern:
* migrations/seed_demo.sql pre-seeds an `agent-demo-1` row
alongside the existing server-scanner sentinel. ON CONFLICT
(id) DO NOTHING preserves idempotency. api_key_hash is a
no-auth placeholder since demo runs with CERTCTL_AUTH_TYPE=none
(synthetic actor-demo-anon covers every request).
* deploy/docker-compose.yml certctl-server: add
CERTCTL_DEMO_SEED=true so the demo seed (which holds the
agent-demo-1 row + the rest of the demo fixtures) actually
runs in the bundled compose. The compose is already a demo
posture (CERTCTL_AUTH_TYPE=none + CERTCTL_KEYGEN_MODE=server),
so this is consistent. docker-compose.demo.yml still works
(it sets the same flag) and stays for backward compat.
* deploy/docker-compose.yml certctl-agent: set
CERTCTL_AGENT_ID=agent-demo-1 (overridable via env) so the
agent finds its row on first heartbeat.
* Makefile qa-stats: agents-table count bumped 12 -> 13.
Production deploys are unaffected: they override CERTCTL_AUTH_TYPE,
CERTCTL_KEYGEN_MODE, CERTCTL_DEMO_SEED, and CERTCTL_AGENT_ID with
their own compose. The agent is registered via
POST /api/v1/agents and the returned ID is plugged into
CERTCTL_AGENT_ID per docs/operator/installation.md.
Verified path: `docker compose -f deploy/docker-compose.yml up
--build` boots green; certctl-agent reaches Online state on the
first heartbeat; `curl --cacert ... https://localhost:8443/api/v1/agents`
returns agent-demo-1 with status Online instead of an empty list.
This commit is contained in:
@@ -73,6 +73,22 @@ INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at
|
||||
('server-scanner', 'Network Scanner (Server-Side)', 'certctl-server', 'Online', NOW(), NOW() - INTERVAL '90 days', 'sentinel_no_auth', 'linux', 'amd64', '127.0.0.1', '2.0.14')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- Bundled docker-compose agent. Pre-Bundle-1 the bundled `certctl-agent`
|
||||
-- service hit a fail-fast path on startup ("agent-id flag or
|
||||
-- CERTCTL_AGENT_ID env var is required") because no row was pre-seeded
|
||||
-- and no auto-register was wired; the container restart-looped silently
|
||||
-- on every fresh `docker compose up`. Latent since 2026-03-14
|
||||
-- (commit d395776 added the env var but no seed). Bundle 1 closes the
|
||||
-- loop: seed_demo.sql pre-seeds this row, docker-compose.yml's agent
|
||||
-- service sets CERTCTL_AGENT_ID=agent-demo-1 + CERTCTL_DEMO_SEED=true
|
||||
-- on the server. api_key_hash is opaque since the demo runs with
|
||||
-- CERTCTL_AUTH_TYPE=none (synthetic actor-demo-anon covers every
|
||||
-- request); production deploys override both env vars + use the
|
||||
-- regular registration flow.
|
||||
INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at, api_key_hash, os, architecture, ip_address, version) VALUES
|
||||
('agent-demo-1', 'docker-agent', 'certctl-agent', 'Online', NOW(), NOW(), 'demo_no_auth', 'linux', 'amd64', '127.0.0.1', '2.1.0')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- Sentinel agents for cloud discovery sources (M50)
|
||||
INSERT INTO agents (id, name, hostname, status, last_heartbeat_at, registered_at, api_key_hash, os, architecture, ip_address, version) VALUES
|
||||
('cloud-aws-sm', 'AWS Secrets Manager Discovery', 'certctl-server', 'Online', NOW(), NOW() - INTERVAL '90 days', 'sentinel_no_auth', 'linux', 'amd64', '127.0.0.1', '2.1.0'),
|
||||
|
||||
Reference in New Issue
Block a user