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:
@@ -40,6 +40,8 @@ type mockAgent struct {
|
||||
formatCalls []formatCall
|
||||
guestAttachCalls []string
|
||||
decommissionCalls []string
|
||||
guestRebootCalls int
|
||||
guestRebootErr error
|
||||
}
|
||||
|
||||
type assignCall struct{ uuid, where, fstype string }
|
||||
@@ -71,6 +73,10 @@ func (m *mockAgent) GuestAttach(_ context.Context, where string) error {
|
||||
m.guestAttachCalls = append(m.guestAttachCalls, where)
|
||||
return nil
|
||||
}
|
||||
func (m *mockAgent) GuestReboot(context.Context) error {
|
||||
m.guestRebootCalls++
|
||||
return m.guestRebootErr
|
||||
}
|
||||
|
||||
func testServer(t *testing.T) *Server {
|
||||
t.Helper()
|
||||
@@ -255,6 +261,38 @@ func TestHandleStorageRegister_RegistersStablePath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleServerReboot_CallsGuestReboot exercises the standalone "Kiszolgáló újraindítása" core:
|
||||
// it must invoke the agent's GuestReboot exactly once and return the 202 envelope. (The HTTP handler
|
||||
// HandleServerReboot delegates to this core after building the live agent client — same split-out
|
||||
// pattern as runStorageInit, so the fake diskAgent can be injected here.)
|
||||
func TestHandleServerReboot_CallsGuestReboot(t *testing.T) {
|
||||
s := testServer(t)
|
||||
agent := &mockAgent{}
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/server/reboot", nil)
|
||||
rr := httptest.NewRecorder()
|
||||
|
||||
s.serverReboot(rr, req, agent)
|
||||
|
||||
if agent.guestRebootCalls != 1 {
|
||||
t.Fatalf("expected GuestReboot invoked exactly once, got %d", agent.guestRebootCalls)
|
||||
}
|
||||
if rr.Code != http.StatusAccepted {
|
||||
t.Fatalf("expected 202 Accepted, got %d (body %s)", rr.Code, rr.Body.String())
|
||||
}
|
||||
var resp struct {
|
||||
OK bool `json:"ok"`
|
||||
Data struct {
|
||||
Rebooting bool `json:"rebooting"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatalf("decode response: %v", err)
|
||||
}
|
||||
if !resp.OK || !resp.Data.Rebooting {
|
||||
t.Fatalf("expected {ok:true, data.rebooting:true}, got %+v", resp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFSUUIDForDevice(t *testing.T) {
|
||||
disks := agentapi.DisksResponse{Disks: []agentapi.DiskInfo{
|
||||
{BackingDevice: "/dev/sda1", DurableID: "uuid:AAAA"},
|
||||
|
||||
Reference in New Issue
Block a user