Files
cloud-ip-validator/internal/dashboard/templates/validators.html
T
ayurishchevandClaude Sonnet 5 95f8066eed 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>
2026-09-18 10:43:00 +03:00

81 lines
2.4 KiB
HTML

{{define "validators_page"}}
<!doctype html>
<html lang="ru">
<head>{{template "html_head" .}}</head>
<body>
<div class="bg-grid"></div>
<input type="checkbox" id="nav-toggle" class="nav-toggle">
<div class="shell">
{{template "sidebar_nav" .}}
<div>
{{template "topbar_mobile" .}}
<main class="main">
<div id="error-banner">{{template "banner_inner" .Banner}}</div>
{{template "validators_content" .}}
</main>
</div>
</div>
</body>
</html>
{{end}}
{{define "validators_content"}}
<div class="topbar"><h1>Валидаторы</h1></div>
<div class="panel">
<div class="panel-head"><h2>Новый валидатор</h2></div>
<div class="panel-body">
<form hx-post="/validators" hx-target="#validators-table-wrap" hx-swap="innerHTML" hx-on::after-request="this.reset()">
<div class="field-row">
<div class="field">
<label>validator_id</label>
<input type="text" name="validator_id" required>
</div>
<div class="field">
<label>os_port_id</label>
<input type="text" name="os_port_id" placeholder="Neutron port ID">
</div>
<button type="submit" class="btn btn-primary">Добавить</button>
</div>
</form>
</div>
</div>
<div id="validators-table-wrap">
{{template "validators_table" .}}
</div>
{{end}}
{{define "validators_table"}}
<div class="panel">
<div class="table-scroll">
<table>
<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}}">
<button type="submit" class="btn btn-ghost btn-sm">Сохранить</button>
</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>
</div>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
{{if not .Items}}<p class="muted">Валидаторов нет.</p>{{end}}
{{end}}