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:
@@ -182,8 +182,14 @@ func FinalizeAttach(req AttachRequest, progress chan<- FormatProgress) (string,
|
||||
progress <- FormatProgress{Step: "error", Message: msg, Error: errStr, Percent: 0}
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
}
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if req.Logger != nil && req.Debug {
|
||||
req.Logger.Printf("[DEBUG] FinalizeAttach: "+format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
mountPath := "/mnt/" + req.MountName
|
||||
dbg("starting: device=%s mountName=%s subPath=%s", req.DevicePath, req.MountName, req.SubPath)
|
||||
|
||||
// --- Step 1: Validate ---
|
||||
send("validating", "Paraméterek ellenőrzése...", 5)
|
||||
@@ -244,6 +250,7 @@ func FinalizeAttach(req AttachRequest, progress chan<- FormatProgress) (string,
|
||||
subRel := strings.TrimPrefix(cleanSub, rawMountPath)
|
||||
subRel = strings.TrimPrefix(subRel, "/")
|
||||
|
||||
dbg("raw mount path: %s, sub relative: %q", rawMountPath, subRel)
|
||||
send("mounting", "fstab bejegyzések hozzáadása...", 35)
|
||||
|
||||
// Backup fstab (non-fatal)
|
||||
@@ -251,13 +258,17 @@ func FinalizeAttach(req AttachRequest, progress chan<- FormatProgress) (string,
|
||||
|
||||
// Fstab entry 1: raw partition mount
|
||||
// Use nofail so a missing disk doesn't block boot
|
||||
dbg("fstab entry 1: UUID=%s → %s (fstype=%s)", uuid, rawMountPath, fsType)
|
||||
if err := AppendFstabEntry(FstabPath, uuid, rawMountPath, fsType, "defaults,nofail,noatime"); err != nil {
|
||||
dbg("fstab raw mount entry failed: %v", err)
|
||||
return "", fail("mounting", "fstab bejegyzés hozzáadása sikertelen (raw mount)", err)
|
||||
}
|
||||
|
||||
// Fstab entry 2: bind mount from subfolder to final path
|
||||
bindSource := cleanSub
|
||||
dbg("fstab entry 2: bind %s → %s", bindSource, mountPath)
|
||||
if err := appendBindFstabEntry(FstabPath, bindSource, mountPath); err != nil {
|
||||
dbg("fstab bind entry failed: %v", err)
|
||||
// Roll back the raw mount fstab entry
|
||||
_ = RemoveFstabEntry(FstabPath, uuid)
|
||||
return "", fail("mounting", "fstab bejegyzés hozzáadása sikertelen (bind mount)", err)
|
||||
@@ -272,20 +283,25 @@ func FinalizeAttach(req AttachRequest, progress chan<- FormatProgress) (string,
|
||||
return "", fail("mounting", "Csatlakoztatási mappa nem hozható létre: "+mountPath, err)
|
||||
}
|
||||
|
||||
dbg("bind mount: mount --bind %s %s", cleanSub, mountPath)
|
||||
if out, err := exec.Command("mount", "--bind", cleanSub, mountPath).CombinedOutput(); err != nil {
|
||||
dbg("bind mount failed: %s", string(out))
|
||||
_ = RemoveFstabEntry(FstabPath, uuid)
|
||||
_ = removeBindFstabEntry(FstabPath, mountPath)
|
||||
return "", fail("mounting", "Bind mount sikertelen: "+string(out), err)
|
||||
}
|
||||
|
||||
// Verify bind mount
|
||||
dbg("verifying bind mount with findmnt")
|
||||
verifyOut, verifyErr := exec.Command("findmnt", "-n", "-o", "SOURCE", "--target", mountPath).Output()
|
||||
if verifyErr != nil || strings.TrimSpace(string(verifyOut)) == "" {
|
||||
dbg("bind mount verification failed: findmnt returned %q err=%v", string(verifyOut), verifyErr)
|
||||
_ = exec.Command("umount", mountPath).Run()
|
||||
_ = RemoveFstabEntry(FstabPath, uuid)
|
||||
_ = removeBindFstabEntry(FstabPath, mountPath)
|
||||
return "", fail("mounting", "A bind mount nem ellenőrizhető", fmt.Errorf("mount point %s not found after bind mount", mountPath))
|
||||
}
|
||||
dbg("bind mount verified: source=%q", strings.TrimSpace(string(verifyOut)))
|
||||
|
||||
send("mounting", "Csatlakoztatva: "+mountPath, 70)
|
||||
|
||||
@@ -301,6 +317,7 @@ func FinalizeAttach(req AttachRequest, progress chan<- FormatProgress) (string,
|
||||
}
|
||||
}
|
||||
|
||||
dbg("attach completed successfully: %s", mountPath)
|
||||
send("done", "Meghajtó sikeresen csatolva: "+mountPath, 100)
|
||||
|
||||
return mountPath, nil
|
||||
|
||||
Reference in New Issue
Block a user