feat(httpapi): harden control plane and speed up prefix refresh

Очередь job получила lease и fencing, телеметрия и прогресс deploy сохраняются, ревизия пишет manifest входов. Обновление префиксов не переписывает неизменённый снимок, большие наборы идут через COPY, а устаревшая ревизия не попадает в deploy. Бандл ноды кэшируется, prune и постановка job больше не держат горячий путь.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
DenozordecandCursor committed 2026-11-02 17:23:59 +07:00
1 parent 924f111e48
commit f8e0520817
197 files changed
+18655 -1416

No files matched your search

+24 -4
View File
@@ -20,6 +20,7 @@ type Result struct {
SpeakerID string `json:"speaker_id"`
Endpoint string `json:"endpoint,omitempty"`
Status string `json:"status"`
Confirmation string `json:"confirmation,omitempty"`
AppliedRevisionID string `json:"applied_revision_id,omitempty"`
Error string `json:"error,omitempty"`
}
@@ -62,12 +63,13 @@ func Enabled() bool {
// WakeSpeaker POSTs /v1/agent/sync to a replica agent (HTTPS via Traefik).
func WakeSpeaker(ctx context.Context, sp *store.Speaker, opts Options) Result {
res := Result{SpeakerID: sp.ID}
res := Result{}
if sp == nil {
res.Status = "error"
res.Error = "nil speaker"
return res
}
res.SpeakerID = sp.ID
meta := store.ParseSpeakerMeta(sp.MetaJSON)
url := store.AgentSyncURL(meta)
if url == "" {
@@ -117,13 +119,31 @@ func WakeSpeaker(ctx context.Context, sp *store.Speaker, opts Options) Result {
_ = resp.Body.Close()
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
var out struct {
OK *bool `json:"ok"`
AppliedRevisionID string `json:"applied_revision_id"`
Error string `json:"error"`
}
if len(bytes.TrimSpace(b)) > 0 {
if err := json.Unmarshal(b, &out); err != nil {
res.Status = "error"
res.Error = "invalid agent sync response"
return res
}
}
if (out.OK != nil && !*out.OK) || strings.TrimSpace(out.Error) != "" {
res.Status = "error"
res.Error = strings.TrimSpace(out.Error)
if res.Error == "" {
res.Error = "agent sync reported failure"
}
return res
}
_ = json.Unmarshal(b, &out)
res.Status = "ok"
res.AppliedRevisionID = strings.TrimSpace(out.AppliedRevisionID)
if res.AppliedRevisionID == "" {
res.AppliedRevisionID = strings.TrimSpace(opts.RevisionID)
if res.AppliedRevisionID != "" {
res.Confirmation = "agent_reported"
} else {
res.Confirmation = "unconfirmed"
}
return res
}