v0.81.0: retire drive-activation banner; add standalone "Kiszolgáló újraindítása" button
In the intermediary-mount model an enrolled drive binds live into the running guest (no reboot), so the "… meghajtó aktiválásra vár / Újraindítás most" banner was an obsolete relic — also dead since v0.78 (pendingActivationDrives keyed on the raw MountPath vs the now-stable sp.Path). Removed the banner block + activatePendingDrives JS (settings.html), the PendingDrives feed (handlers.go), and the dead pendingActivationDrives helper + its unused internal/system import. Renamed handleStorageActivate -> HandleServerReboot (split out a testable serverReboot core), removed the /api/storage/activate case, and mounted the handler at the new non-storage route /api/server/reboot (RequireAuth+CsrfProtect). The agent GuestReboot primitive is reused unchanged. Added the standalone "Kiszolgáló újraindítása" settings card (sibling to the controller-only "Vezérlő újraindítása"), reusing the pollRestart() loop. Test: TestHandleServerReboot_CallsGuestReboot (fake diskAgent asserts GuestReboot invoked once + 202). diskAgent/mockAgent gained GuestReboot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017PsnU2ASocYrvzqE82YDYW
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/appbackup"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/system"
|
||||
)
|
||||
|
||||
// Guided storage provisioning (rebuilt on the agent-delegated disk model). The controller is a thin
|
||||
@@ -35,6 +34,7 @@ type diskAgent interface {
|
||||
EjectDisk(ctx context.Context, where string) (agentapi.EjectResult, error)
|
||||
Decommission(ctx context.Context, where string) (agentapi.DecommissionResult, error)
|
||||
GuestAttach(ctx context.Context, where string) error
|
||||
GuestReboot(ctx context.Context) error
|
||||
}
|
||||
|
||||
// mountNameRe is the safe `/mnt/<name>` component (DNS-ish: letters, digits, _ , -).
|
||||
@@ -164,44 +164,6 @@ func (s *Server) runStorageAttach(ctx context.Context, agent diskAgent, device,
|
||||
return storageInitResult{Registered: true, Where: stable}, nil
|
||||
}
|
||||
|
||||
// pendingActivationDrives returns registered storage paths that are NOT yet live-mounted in this
|
||||
// container but whose backing drive the agent reports present+attached — enrolled drives waiting for
|
||||
// the guest restart that activates their bind (slice 10 P2; the host-side live inject is blocked on an
|
||||
// unprivileged guest). The customer activates them with the "Újraindítás most" button (one restart
|
||||
// batches all). Best-effort: agent unreachable → none.
|
||||
func (s *Server) pendingActivationDrives() []string {
|
||||
paths := s.settings.GetStoragePaths()
|
||||
if len(paths) == 0 {
|
||||
return nil
|
||||
}
|
||||
agent, err := s.agentClient()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
resp, err := agent.Disks(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
attached := map[string]bool{}
|
||||
for _, d := range resp.Disks {
|
||||
if d.MountPath != "" && d.State == "attached" {
|
||||
attached[d.MountPath] = true
|
||||
}
|
||||
}
|
||||
var pending []string
|
||||
for _, sp := range paths {
|
||||
if sp.Decommissioned {
|
||||
continue
|
||||
}
|
||||
if attached[sp.Path] && !system.IsMountPoint(sp.Path) {
|
||||
pending = append(pending, sp.Path)
|
||||
}
|
||||
}
|
||||
return pending
|
||||
}
|
||||
|
||||
// reEnrollClearMarker un-retires a re-plugged decommissioned drive (Change 4): clears the soft marker
|
||||
// and restores Schedulable so its apps' "missing storage" indicator clears. Returns true if it acted.
|
||||
func (s *Server) reEnrollClearMarker(where string) (bool, error) {
|
||||
@@ -283,8 +245,6 @@ func (s *Server) ServeStorageAPI(w http.ResponseWriter, r *http.Request) {
|
||||
s.handleStorageImpact(w, r)
|
||||
case r.URL.Path == "/api/storage/register" && r.Method == http.MethodPost:
|
||||
s.handleStorageRegister(w, r)
|
||||
case r.URL.Path == "/api/storage/activate" && r.Method == http.MethodPost:
|
||||
s.handleStorageActivate(w, r)
|
||||
case r.URL.Path == "/api/storage/migrate" && r.Method == http.MethodPost:
|
||||
s.handleStorageMigrate(w, r)
|
||||
case r.URL.Path == "/api/storage/migrate-app" && r.Method == http.MethodPost:
|
||||
@@ -643,21 +603,31 @@ func (s *Server) handleStorageWipe(w http.ResponseWriter, r *http.Request) {
|
||||
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"device": req.Device, "wiped": fr.Formatted, "durable_id": fr.DurableID})
|
||||
}
|
||||
|
||||
// handleStorageActivate reboots the guest to activate pending drive binds (slice 10 P2). The agent
|
||||
// reboots detached + returns 202; this controller restarts with the guest, so the caller's response
|
||||
// may be cut short — the UI handles that and reloads after the restart window.
|
||||
func (s *Server) handleStorageActivate(w http.ResponseWriter, r *http.Request) {
|
||||
// HandleServerReboot reboots the whole guest (server) as a deliberate maintenance action — the
|
||||
// standalone "Kiszolgáló újraindítása" affordance, a sibling to the controller-only restart
|
||||
// (/api/selfrestart). The agent reboots detached + returns 202; this controller restarts with the
|
||||
// guest, so the caller's response may be cut short — the UI handles that and reloads after the
|
||||
// restart window. (It reuses the agent GuestReboot primitive that previously backed the now-retired
|
||||
// drive-activation banner; in the intermediary-mount model a drive binds live, so no reboot is needed
|
||||
// to activate storage — this button is purely a full-server restart.)
|
||||
func (s *Server) HandleServerReboot(w http.ResponseWriter, r *http.Request) {
|
||||
agent, err := s.agentClient()
|
||||
if err != nil {
|
||||
writeDiskJSON(w, http.StatusServiceUnavailable, false, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
s.serverReboot(w, r, agent)
|
||||
}
|
||||
|
||||
// serverReboot is the testable core of HandleServerReboot: invoke the agent's guest reboot and return
|
||||
// the 202 envelope (or the agent error). Split out so it can be exercised with a fake diskAgent.
|
||||
func (s *Server) serverReboot(w http.ResponseWriter, r *http.Request, agent diskAgent) {
|
||||
if err := agent.GuestReboot(r.Context()); err != nil {
|
||||
s.logger.Printf("[ERROR] [web] guest reboot (activate pending drives) failed: %v", err)
|
||||
s.logger.Printf("[ERROR] [web] server reboot (guest restart) failed: %v", err)
|
||||
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
s.logger.Printf("[WARN] [web] guest restart requested to activate pending drive binds")
|
||||
s.logger.Printf("[WARN] [web] full server (guest) restart requested by operator")
|
||||
writeDiskJSON(w, http.StatusAccepted, true, "", map[string]any{"rebooting": true})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user