v0.24.0 — Pre-testing observability: debug logging, diagnostic dump, startup self-test

- Add [DEBUG] logging across all modules (backup, storage, sync, selfupdate,
  monitor, notify, report, assets, setup) gated behind logging.level: "debug"
- Add /api/debug/dump endpoint returning full controller state JSON (debug only)
- Add startup self-test validating 9 subsystems (Docker, dirs, storage, hub,
  restic repos, metrics DB) with pass/warn/fail summary
- New packages: internal/selftest, internal/util
- Constructor/signature changes: debug bool params, logger params on
  RunHealthCheck and BuildReport, smart watchdog probe logging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 18:32:26 +01:00
parent 6f02536243
commit be7803c0ac
30 changed files with 1281 additions and 67 deletions
+12 -1
View File
@@ -35,6 +35,7 @@ type Pusher struct {
httpClient *http.Client
logger *log.Logger
enabled bool
debug bool
statusMu sync.RWMutex
status PushStatus
@@ -45,7 +46,7 @@ type Pusher struct {
}
// NewPusher creates a new report pusher from hub configuration.
func NewPusher(cfg *config.HubConfig, logger *log.Logger) *Pusher {
func NewPusher(cfg *config.HubConfig, logger *log.Logger, debug bool) *Pusher {
return &Pusher{
hubURL: strings.TrimRight(cfg.URL, "/"),
apiKey: cfg.APIKey,
@@ -54,6 +55,7 @@ func NewPusher(cfg *config.HubConfig, logger *log.Logger) *Pusher {
},
logger: logger,
enabled: cfg.Enabled,
debug: debug,
}
}
@@ -69,6 +71,9 @@ func (p *Pusher) Push(report *Report) error {
}
url := p.hubURL + "/api/v1/report"
if p.debug {
p.logger.Printf("[DEBUG] Push: url=%s payload=%d bytes", url, len(data))
}
p.statusMu.Lock()
p.status.LastAttempt = time.Now()
@@ -143,6 +148,9 @@ func (p *Pusher) PushInfraBackup(data []byte) error {
}
url := p.hubURL + "/api/v1/infra-backup"
if p.debug {
p.logger.Printf("[DEBUG] PushInfraBackup: url=%s payload=%d bytes", url, len(data))
}
var lastErr error
for attempt := 0; attempt < 3; attempt++ {
@@ -173,6 +181,9 @@ func (p *Pusher) PushInfraBackup(data []byte) error {
return nil
}
lastErr = fmt.Errorf("HTTP %d", resp.StatusCode)
if p.debug {
p.logger.Printf("[DEBUG] PushInfraBackup: attempt %d failed — HTTP %d", attempt+1, resp.StatusCode)
}
}
return fmt.Errorf("infra backup push failed after 3 attempts: %w", lastErr)