v0.11.0 — Phase C: Storage Init Wizard, Data Migration & Startup Fix

- Startup ping: fire heartbeat + health + hub report immediately on boot
  (5s delay after scheduler start, instead of waiting 5-15 min for first tick)

- Storage init wizard: new internal/storage/ package with disk scanning
  (lsblk -J), format+mount pipeline (sfdisk → mkfs.ext4 → blkid → fstab →
  mount → chown), safety guards (system disk detection, confirmation "FORMÁZÁS"),
  progress channel, auto-register in settings.json

- Data migration: MigrateAppData() with rsync --info=progress2 progress parsing,
  stop/rsync/update-config/start flow, rollback on failure, old data preserved

- New pages: /settings/storage/init (wizard), /stacks/{name}/migrate (migration)
- New API routes: /api/storage/{scan,init,init/status,migrate,migrate/status}
- Deploy page: storage info section for deployed apps (path, size, free, migrate link)
- Settings page: "Mozgatás" button per app in storage path details
- Container: privileged: true, /dev:/dev, /etc/fstab:/host-fstab, /run/udev:/run/udev:ro
- Dockerfile: add util-linux, e2fsprogs, rsync, parted for disk ops

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 10:27:18 +01:00
parent e7c27364bf
commit 2fb2c6e1ae
23 changed files with 2236 additions and 6 deletions
+50
View File
@@ -0,0 +1,50 @@
package storage
import (
"bufio"
"fmt"
"strings"
)
// FormatRequest holds parameters for formatting and mounting a disk.
type FormatRequest struct {
DevicePath string // "/dev/sdb" or "/dev/sdb1"
MountName string // "hdd_1" → mounts at /mnt/hdd_1
Label string // Display label for the UI
CreatePartition bool // If true, create a single partition first (wipes disk)
SetDefault bool // Register as default storage path
}
// FormatProgress tracks the formatting/mounting progress.
type FormatProgress struct {
Step string // "validating","partitioning","formatting","mounting","permissions","done","error"
Message string // Human-readable status
Error string // Non-empty if Step == "error"
Percent int // 0100
}
// parseRsyncProgress parses a single line of rsync --info=progress2 output.
// Returns (bytesCopied, percent, ok).
func parseRsyncProgress(line string) (int64, int, bool) {
// Format: " 45,678,901 49% 12.34MB/s 0:00:30"
scanner := bufio.NewScanner(strings.NewReader(line))
scanner.Split(bufio.ScanWords)
var tokens []string
for scanner.Scan() {
tokens = append(tokens, scanner.Text())
}
if len(tokens) < 2 {
return 0, 0, false
}
bytesStr := strings.ReplaceAll(tokens[0], ",", "")
var bytesCopied int64
if _, err := fmt.Sscanf(bytesStr, "%d", &bytesCopied); err != nil {
return 0, 0, false
}
pctStr := strings.TrimSuffix(tokens[1], "%")
var pct int
if _, err := fmt.Sscanf(pctStr, "%d", &pct); err != nil {
return 0, 0, false
}
return bytesCopied, pct, true
}