-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: properly return 503 status when shutdown was initiated #65
Conversation
Signed-off-by: Valery Piashchynski <[email protected]>
WalkthroughThe recent updates enhance the GitHub Actions workflow, linter configurations, and introduce a mechanism for managing graceful shutdowns in the server. Key enhancements include more frequent dependency updates, updated linting tools, and refined linting rules. Additionally, server behavior is improved by adding an Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
go.work.sum
is excluded by!**/*.sum
Files selected for processing (9)
- .github/dependabot.yml (1 hunks)
- .github/workflows/linters.yml (1 hunks)
- .golangci.yml (2 hunks)
- health.go (2 hunks)
- jobs.go (2 hunks)
- plugin.go (10 hunks)
- ready.go (2 hunks)
- tests/configs/.rr-status-503.yaml (1 hunks)
- tests/plugin_test.go (2 hunks)
Files skipped from review due to trivial changes (3)
- .github/dependabot.yml
- .golangci.yml
- tests/configs/.rr-status-503.yaml
Additional comments not posted (18)
.github/workflows/linters.yml (1)
19-19
: Updated the GitHub Action and linter version to the latest. This is a good practice as it ensures compatibility and access to the latest features and fixes.Also applies to: 21-21
jobs.go (2)
21-21
: Introduced ashutdownInitiated
field to manage shutdown state. Usingatomic.Pointer
ensures thread safety, which is crucial for concurrent access in a server environment.Also applies to: 24-29
34-37
: Properly handles the shutdown scenario by checking theshutdownInitiated
status and returning a 503 status code. This aligns with the PR's objectives to improve shutdown behavior.health.go (2)
16-16
: AddedshutdownInitiated
to theHealth
struct to manage shutdown states usingatomic.Pointer
for thread safety. Consistent and appropriate use of concurrency mechanisms.Also applies to: 19-24
29-32
: Correctly handles the shutdown scenario by checking theshutdownInitiated
status and returning a 503 status code. Ensures graceful degradation of service during shutdowns.ready.go (2)
19-19
: AddedshutdownInitiated
to theReady
struct to manage shutdown states usingatomic.Pointer
for thread safety. Consistent and appropriate use of concurrency mechanisms.Also applies to: 22-27
32-35
: Correctly handles the shutdown scenario by checking theshutdownInitiated
status and returning a 503 status code. Ensures readiness checks respond appropriately during shutdowns.plugin.go (9)
8-8
: Import ofsync/atomic
added to manage atomic operations, aligning with the new shutdown handling logic.
28-28
: Addition of theHas
method in theConfigurer
interface allows checking for configuration existence, improving robustness.
36-36
: Definition of theChecker
interface is crucial for status checks, ensuring plugins can report their own status.
48-48
: Clarification in theReadiness
interface comment helps in understanding the readiness logic related to worker pool status.
57-67
: Introduction ofshutdownInitiated
usingatomic.Pointer
ensures thread-safe handling of shutdown state across various server components.
85-85
: Proper initialization ofshutdownInitiated
tofalse
at the start of theInit
method, ensuring correct default state.
96-98
: Modification of theServe
method to include shutdown state in handlers. This change is critical for returning a 503 status during shutdowns.
131-132
: SettingshutdownInitiated
totrue
in theStop
method ensures that the server correctly signals a shutdown state.
187-189
: Utility functiontoPtr
added for generic pointer conversion, aiding in clean and reusable code for handling pointers.tests/plugin_test.go (2)
4-4
: Import additions to support the testing environment setup, including context handling and HTTP operations.
464-549
: New testTestShutdown503
added to simulate graceful shutdown and verify that the server returns a 503 status correctly during the shutdown process. This test is crucial for ensuring the new functionality works as intended.
Signed-off-by: Valery Piashchynski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- tests/configs/.rr-status-503.yaml (1 hunks)
- tests/plugin_test.go (6 hunks)
Files skipped from review as they are similar to previous changes (2)
- tests/configs/.rr-status-503.yaml
- tests/plugin_test.go
Signed-off-by: Valery Piashchynski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
tests/php_test_files/composer.lock
is excluded by!**/*.lock
Files selected for processing (4)
- .gitignore (1 hunks)
- plugin.go (11 hunks)
- tests/configs/.rr-status-503.yaml (1 hunks)
- tests/plugin_test.go (10 hunks)
Files skipped from review due to trivial changes (1)
- .gitignore
Files skipped from review as they are similar to previous changes (1)
- tests/configs/.rr-status-503.yaml
Additional comments not posted (12)
plugin.go (6)
8-8
: Added importsync/atomic
to handle atomic operations on boolean values for shutdown initiation.
64-65
: Introduced ashutdownInitiated
field to track if a shutdown has been initiated. This is crucial to ensure that the status server can respond appropriately during the shutdown.
85-85
: Correctly initializing theshutdownInitiated
atomic pointer tofalse
on plugin initialization. This ensures the plugin starts in a non-shutdown state.
96-98
: Updated the handlers for/health
,/ready
, and/jobs
to check theshutdownInitiated
state. This modification is central to the PR's objective of ensuring these endpoints return a 503 status during shutdown.
131-131
: Setting theshutdownInitiated
totrue
in theStop
method to signal that a shutdown is in progress. This change is essential for the correct behavior during shutdown.
197-199
: Utility functiontoPtr
added to simplify the creation of pointers, particularly useful in the context of handling atomic operations withsync/atomic
.tests/plugin_test.go (6)
4-4
: Import ofcontext
added to support context management in HTTP requests, aligning with best practices for handling request cancellation and timeouts.
36-36
: Setup of the test environment using theendure
container with a new configuration. This setup is crucial for testing the new functionality in an isolated environment.Also applies to: 39-39, 43-43, 49-49
102-104
: Proper cleanup usingt.Cleanup
to ensure the HTTP server is stopped after tests, preventing side effects on subsequent tests.
176-178
: Repetition of the cleanup pattern in another test function, maintaining consistency across test cases.
248-250
: Consistent use of cleanup steps across all test functions, which is a good practice to ensure clean test states.
576-578
: Ensuring that the HTTP server is stopped in the cleanup phase of the shutdown test, which is critical for testing the new 503 functionality during shutdown.
Reason for This PR
closes: roadrunner-server/roadrunner#1924
Description of Changes
License Acceptance
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).CHANGELOG.md
.Summary by CodeRabbit
New Features
shutdownInitiated
to enhance the health, jobs, plugin, and ready handlers for better management of service shutdowns.TestShutdown503
to simulate and verify graceful shutdown scenarios with HTTP status checks.Chores
golangci/golangci-lint-action
to versionv6.0.1
andgolangci-lint
tov1.59
..gitignore
to include composer lock files.Configuration Changes
.golangci.yml
.rr-status-503.yaml
.