Skip to content

Backend: Persist scheduled maintenance windows across process restarts #857

Description

@Junirezz

Context

maintenanceWindow.ts schedules future maintenance windows and auto-enables maintenance mode when a window is active (Issue #714).

Problem / Gap

Scheduled windows live in an in-memory array. Deployments, restarts, or horizontal scaling cause windows to disappear and maintenance mode transitions to drift out of sync across pods.

Proposed approach

  • Persist maintenance windows in Prisma with startsAt, endsAt, title, reason, and createdBy.
  • Load active/upcoming windows on startup and reconcile maintenance mode state.
  • Keep the public read-only status endpoint behavior unchanged.

Acceptance criteria

  • Admin-created windows survive restart and are visible from all instances.
  • Active window automatically enables maintenance mode on every pod via shared storage.
  • Expired windows are archived or pruned per retention policy.
  • Tests cover create, overlap validation, auto-enable, and auto-disable lifecycles.

Files/areas affected

  • backend/src/maintenanceWindow.ts
  • backend/src/maintenanceMode.ts
  • backend/prisma/schema.prisma

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions