feat: Add opt-in POST /maintenance/restart endpoint for k8s#54
Merged
Conversation
…lling restarts Enables lightweight deployments without kubectl: calling the endpoint shuts down the server gracefully (SIGTERM), Kubernetes restarts the pod, and with imagePullPolicy: Always the new image is pulled automatically. The endpoint is disabled by default and must be opted in via --enable-restart (CLI) or by appending it to the Helm chart args. Includes docs and tests. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in maintenance endpoint to trigger a Kubernetes pod restart by terminating the running web process, intended to support lightweight “restart to re-pull image” workflows when imagePullPolicy: Always is used.
Changes:
- Added
POST /maintenance/restartendpoint plus restart scheduling logic in the Sinatra app. - Added
--enable-restartCLI flag / config wiring to toggle the endpoint (default off). - Updated Kubernetes documentation and added endpoint behavior tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/archsight/web/application.rb |
Introduces restart feature flag, restart implementation, and the new maintenance route. |
lib/archsight/cli.rb |
Adds CLI option and wires it to the Sinatra setting. |
test/web/application_test.rb |
Adds tests for disabled-by-default behavior and enabled restart behavior. |
docs/kubernetes.md |
Documents how to enable and use the restart endpoint in Kubernetes. |
chart/archsight/values.yaml |
Notes how to enable the flag via Helm args (documentation comment). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add optional --restart-token / X-Restart-Token shared-secret check (401 on mismatch) to prevent unauthenticated access to the restart endpoint - Move shutdown thread spawn to an `after` filter so it fires after the response is fully assembled, not mid-handler - Increase default shutdown delay to 2.0s and make it configurable via ARCHSIGHT_RESTART_SHUTDOWN_DELAY env var - Update docs with token example, delay config, and security guidance - Expand tests: token missing/wrong/correct cases + helper refactor Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.
This pull request introduces a new optional maintenance endpoint for triggering rolling restarts in Kubernetes deployments. The main change is the addition of a
POST /maintenance/restartendpoint, which allows for lightweight rolling restarts and automatic image re-pulls when used withimagePullPolicy: Always. The feature is opt-in, disabled by default, and can be enabled via a new CLI option and configuration. Documentation and tests are updated accordingly.Maintenance Restart Endpoint Feature:
--enable-restartCLI option to enable thePOST /maintenance/restartendpoint for triggering pod restarts in Kubernetes (lib/archsight/cli.rb,chart/archsight/values.yaml) [1] [2].Archsight::Web::Application, including theperform_restart!method and endpoint handler (lib/archsight/web/application.rb).restart_enabledsetting (lib/archsight/web/application.rb) [1] [2].Documentation:
docs/kubernetes.md).Testing:
application_test.rb(test/web/application_test.rb).