feat(maintenance): add sm down/up + middleware (closes #160)#201
Open
antosubash wants to merge 2 commits into
Open
feat(maintenance): add sm down/up + middleware (closes #160)#201antosubash wants to merge 2 commits into
antosubash wants to merge 2 commits into
Conversation
Tracks the 17 open issues with priority order, cross-issue dependencies, and execution protocol. Per-issue sub-plans land on the corresponding feature branches.
Drops a JSON sentinel at the host content root that the new
MaintenanceModeMiddleware polls every second. While active:
- health probes (/health/live, /health/ready) pass through
- ?sm_bypass=<secret> verifies the SHA-256 hash and sets an
HttpOnly, SameSite=Lax sm_bypass cookie
- Inertia / API callers get a JSON 503 with Retry-After
- browsers get a minimal styled HTML 503 (renders without JS)
- the React side resolves System/Maintenance to the existing
ErrorPage503, so future Inertia.Render("System/Maintenance")
calls light up automatically
CLI:
sm down --secret X --message ... --retry 60 [--until ISO]
sm down --status
sm up
Tests:
- 9 middleware tests cover state-off, state-on, health exemption,
bypass query (correct + wrong secret), bypass cookie, and the
Inertia-vs-browser response branch
- 4 sentinel tests cover write hashes the secret, delete, and
HashSecret determinism
Deploying simplemodule-website with
|
| Latest commit: |
d91aa1c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b61e6953.simplemodule-website.pages.dev |
| Branch Preview URL: | https://issue-160-maintenance-mode.simplemodule-website.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #160.
MaintenanceModeMiddlewarepolls a JSON sentinel (<content-root>/.maintenance) every second. While the sentinel exists the middleware short-circuits with 503.?sm_bypass=<secret>verifies the SHA-256 hash and drops anHttpOnly,SameSite=Lax,Secure-when-HTTPSsm_bypasscookie so the deploying engineer can keep verifying the release.Retry-After; browsers get a minimal HTML 503 that renders without a JS bundle. The Inertia routeSystem/Maintenanceresolves to the existingErrorPage503component, so once an authenticated admin endpoint wants to render the maintenance page through Inertia it just works./health/live,/health/ready) are exempt — load balancers can still distinguish "host down" from "deploying".sm down --secret X --message ... --retry 60 [--until ISO],sm down --status,sm up. The secret is hashed before it touches disk — only the hash sits in the sentinel.Test plan
dotnet test tests/SimpleModule.Core.Tests --filter Maintenance— 9/9 pass (state-off, state-on, health exemption, bypass query right/wrong, bypass cookie, Inertia vs browser response)dotnet test tests/SimpleModule.Cli.Tests -p:IsTestProject=true --filter MaintenanceSentinel— 4/4 pass (write hashes secret, delete, idempotent delete, hash format)dotnet test tests/SimpleModule.Core.Tests— full suite still 222/222dotnet build— greendotnet run --project template/SimpleModule.Host, then in another shellsm down --secret xyz, hit/(expect 503), hit/?sm_bypass=xyz(expect 302+cookie), hit/again (expect 200),sm up, hit/(expect 200). Reviewer to verify.Not in scope (deferred)
sm downover a shared volume or wire it into the deploy pipeline.