R-492: delete the always-empty cfg.Paths.HDDPath (field, env binding, every fallback)

Readers (report builder, health check, /api/system, web primaryHDDPath, metrics collector,
AutoDiscoverStoragePaths' fallback parameter) now use the storage registry only. An old
controller.yaml still carrying paths.hdd_path keeps loading (non-strict YAML), pinned by
TestR492_OldConfigWithHDDPathStillLoads.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-05 21:45:53 +02:00
parent d15ad105be
commit 7b8216abac
11 changed files with 45 additions and 47 deletions
+3 -11
View File
@@ -1738,7 +1738,6 @@ func (s *Settings) SetStorageLabel(path, label string) error {
// already in the registry. It is ADDITIVE: pre-existing entries are never removed,
// modified, or reactivated.
// - discoveredPaths are pre-scanned HDD_PATH values from deployed apps' app.yaml.
// - fallbackHDDPath is the legacy controller.yaml paths.hdd_path (may be empty).
//
// Invariants:
// - A path already present in the registry IN ANY STATE (including a Decommissioned
@@ -1747,12 +1746,12 @@ func (s *Settings) SetStorageLabel(path, label string) error {
// - IsDefault is never flipped on an existing entry. A newly-discovered path becomes
// default ONLY if the registry currently has no default at all (and then only the
// first such new path).
func (s *Settings) AutoDiscoverStoragePaths(discoveredPaths []string, fallbackHDDPath string, logger *log.Logger) {
func (s *Settings) AutoDiscoverStoragePaths(discoveredPaths []string, logger *log.Logger) {
s.mu.Lock()
defer s.mu.Unlock()
if s.debug {
s.log.Printf("[DEBUG] [settings] AutoDiscoverStoragePaths discovered=%v fallback=%q existing=%d", discoveredPaths, fallbackHDDPath, len(s.StoragePaths))
s.log.Printf("[DEBUG] [settings] AutoDiscoverStoragePaths discovered=%v existing=%d", discoveredPaths, len(s.StoragePaths))
}
// Index existing paths (in ANY state) and whether a default already exists.
@@ -1765,7 +1764,7 @@ func (s *Settings) AutoDiscoverStoragePaths(discoveredPaths []string, fallbackHD
}
}
// Build the de-duplicated, cleaned candidate list (discovered first, then fallback).
// Build the de-duplicated, cleaned candidate list.
seen := make(map[string]bool)
var ordered []string
for _, p := range discoveredPaths {
@@ -1775,13 +1774,6 @@ func (s *Settings) AutoDiscoverStoragePaths(discoveredPaths []string, fallbackHD
ordered = append(ordered, cleaned)
}
}
if fallbackHDDPath != "" {
cleaned := filepath.Clean(fallbackHDDPath)
if cleaned != "" && cleaned != "." && !seen[cleaned] {
seen[cleaned] = true
ordered = append(ordered, cleaned)
}
}
added := 0
for _, path := range ordered {
@@ -30,7 +30,6 @@ func TestAutoDiscoverStoragePaths_Additive(t *testing.T) {
name string
existing []StoragePath
discovered []string
fallback string
wantPaths []string // expected Path set after discovery (order-insensitive)
wantNewPath string // a path expected to be newly added (may be "")
// assertions run against the resulting registry
@@ -101,17 +100,6 @@ func TestAutoDiscoverStoragePaths_Additive(t *testing.T) {
}
},
},
{
name: "fallback path registered when missing",
existing: []StoragePath{
{Path: "/mnt/felhom-usb", Label: "x", IsDefault: true, Schedulable: true, AddedAt: "2026-01-01T00:00:00Z"},
},
discovered: nil,
fallback: "/mnt/legacy_hdd",
wantPaths: []string{"/mnt/felhom-usb", "/mnt/legacy_hdd"},
wantNewPath: "/mnt/legacy_hdd",
check: nil,
},
}
for _, tc := range tests {
@@ -119,7 +107,7 @@ func TestAutoDiscoverStoragePaths_Additive(t *testing.T) {
s := newTestSettings(t, cloneStoragePaths(tc.existing))
before := cloneStoragePaths(tc.existing)
s.AutoDiscoverStoragePaths(tc.discovered, tc.fallback, logger)
s.AutoDiscoverStoragePaths(tc.discovered, logger)
// Normalize with filepath.Clean so comparisons hold on both Linux (the deploy
// target) and Windows (the dev machine), where Clean uses backslashes.
@@ -158,7 +146,7 @@ func TestAutoDiscoverStoragePaths_DecommissionedNotReactivated(t *testing.T) {
before := cloneStoragePaths(existing)
// A deployed app still points at the decommissioned drive.
s.AutoDiscoverStoragePaths([]string{"/mnt/old_hdd", "/mnt/felhom-usb"}, "", logger)
s.AutoDiscoverStoragePaths([]string{"/mnt/old_hdd", "/mnt/felhom-usb"}, logger)
if len(s.StoragePaths) != 2 {
t.Fatalf("path count changed: got %d want 2 (%v)", len(s.StoragePaths), pathList(s))