Retry validator-agent/prober registration; show validator hostname

Both binaries registered with control-api exactly once at startup and
exited (os.Exit(1)) on any failure — including control-api simply not
being up yet (no ordering guarantee between the two at boot/redeploy) or
the admin not having added this validator_id/site_id to the config yet.
Run() now retries registration with capped exponential backoff (3s->30s)
until it succeeds or the process is asked to shut down, instead of
crashing; registerWithRetry is identical in agentcore and probercore
since their Run/register shape already was.

Separately, the admin dashboard's Validators page had no hostname column
even though the agent already reports one on register (mirroring the
prober) and control-api already persists it — only the admin-config read
DTO (validatorDTO in httpapi and dashboard) dropped it before it reached
the template. Added hostname + last_heartbeat_at to that DTO end-to-end
and a Хост/Heartbeat column to validators.html, matching sites.html.

Rebuilt bin/{control-api,admin-dashboard,prober,validator-agent} and
bin/SHA256SUMS per docs/SETUP.md's documented build recipe.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5 committed 2026-09-18 10:43:00 +03:00
1 parent 399c64e801
commit 95f8066eed
15 files changed
+320 -23

No files matched your search

+5 -3
View File
@@ -97,9 +97,11 @@ type clearQueueResponse struct {
}
type validatorDTO struct {
ValidatorID string `json:"validator_id"`
OSPortID string `json:"os_port_id"`
State string `json:"state"`
ValidatorID string `json:"validator_id"`
Hostname string `json:"hostname"`
OSPortID string `json:"os_port_id"`
State string `json:"state"`
LastHeartbeatAt *time.Time `json:"last_heartbeat_at"`
}
type siteDTO struct {
+11
View File
@@ -376,6 +376,17 @@ func TestSitesPageShowsProberBadge(t *testing.T) {
}
}
func TestValidatorsPageShowsHostname(t *testing.T) {
fake, caURL := newFakeControlAPI(t)
fake.validators = append(fake.validators, validatorDTO{ValidatorID: "val-1", Hostname: "validator-host-1", OSPortID: "port-1", State: "idle"})
ts := newTestServer(t, caURL)
page := get(t, ts, "/validators")
if !strings.Contains(page, "validator-host-1") {
t.Fatalf("expected hostname shown, got:\n%s", page)
}
}
func TestTargetsAndCheckTypesRoundTrip(t *testing.T) {
_, caURL := newFakeControlAPI(t)
ts := newTestServer(t, caURL)
+3 -1
View File
@@ -50,12 +50,13 @@
<div class="panel">
<div class="table-scroll">
<table>
<thead><tr><th>ID</th><th>OS Port ID</th><th>Состояние</th><th></th></tr></thead>
<thead><tr><th>ID</th><th>Хост</th><th>OS Port ID</th><th>Состояние</th><th>Heartbeat</th><th></th></tr></thead>
<tbody>
{{range .Items}}
{{$b := validatorBadge .State}}
<tr>
<td class="mono" data-label="ID">{{.ValidatorID}}</td>
<td class="mono" data-label="Хост">{{if .Hostname}}{{.Hostname}}{{else}}—{{end}}</td>
<td data-label="OS Port ID">
<form class="inline-form" hx-put="/validators/{{.ValidatorID}}" hx-target="#validators-table-wrap" hx-swap="innerHTML">
<input type="text" name="os_port_id" value="{{.OSPortID}}">
@@ -63,6 +64,7 @@
</form>
</td>
<td data-label="Состояние"><span class="pill {{$b.Class}}">{{$b.Label}}</span></td>
<td data-label="Heartbeat">{{fmtTime .LastHeartbeatAt}}</td>
<td data-label="">
<div class="actions">
<button class="btn btn-danger-ghost btn-sm" hx-delete="/validators/{{.ValidatorID}}" hx-target="#validators-table-wrap" hx-swap="innerHTML" hx-confirm="Удалить валидатор {{.ValidatorID}}?">Удалить</button>