fix: prevent ghost records from 'configuring' progress pings

When the container sends 'configuring' before the host's 'installing'
record was written (race condition or curl timeout), UpsertTelemetry
created a new record with ct_type=0, all-zero hardware values, and
repo_source=N/A. These ghost records were then hidden by the dashboard
(which filters repo_source='ProxmoxVE').

Changes:
- Skip record creation for 'configuring' status when no existing record
  is found (log warning instead of creating ghost)
- Add RepoSource to TelemetryStatusUpdate so PATCH updates carry
  repo_source through to PocketBase
- Final states (failed/success) still create fallback records since
  post_update_to_api sends full payloads with all fields
This commit is contained in:
CanbiZ (MickLesk)
2026-02-23 16:45:04 +01:00
parent 9c92479710
commit 7f5c65c4c7
+12 -2
View File
@@ -166,6 +166,7 @@ type TelemetryStatusUpdate struct {
CPUVendor string `json:"cpu_vendor,omitempty"`
CPUModel string `json:"cpu_model,omitempty"`
RAMSpeed string `json:"ram_speed,omitempty"`
RepoSource string `json:"repo_source,omitempty"`
}
// Allowed values for 'repo_source' field
@@ -499,8 +500,16 @@ func (p *PBClient) UpsertTelemetry(ctx context.Context, payload TelemetryOut) er
}
if recordID == "" {
// Record not found - this shouldn't happen normally
// Create a full record as fallback
// "configuring" is just a progress ping — never create a new record for it.
// This prevents ghost records (ct_type=0, all zeros, repo_source=N/A) when
// the container sends "configuring" before the host's "installing" was written.
if payload.Status == "configuring" {
log.Printf("[WARN] configuring update for %s (exec=%s) but no existing record found, skipping",
payload.NSAPP, payload.ExecutionID)
return nil
}
// For final states (failed/success/aborted) — create as fallback.
// post_update_to_api sends full payload so the record will have all fields.
return p.CreateTelemetry(ctx, payload)
}
@@ -518,6 +527,7 @@ func (p *PBClient) UpsertTelemetry(ctx context.Context, payload TelemetryOut) er
CPUVendor: payload.CPUVendor,
CPUModel: payload.CPUModel,
RAMSpeed: payload.RAMSpeed,
RepoSource: payload.RepoSource,
}
return p.UpdateTelemetryStatus(ctx, recordID, update)
}