Skip to content

fix: healthcheck endpoint during graceful shutdown#71

Merged
cv65kr merged 1 commit into
masterfrom
fix/health-endpoint
Jun 18, 2024
Merged

fix: healthcheck endpoint during graceful shutdown#71
cv65kr merged 1 commit into
masterfrom
fix/health-endpoint

Conversation

@cv65kr
Copy link
Copy Markdown
Member

@cv65kr cv65kr commented Jun 18, 2024

Reason for This PR

Follow up for #65

Description of Changes

During shutdown
/health endpoint should returns 200
/ready endpoint should returns 503

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]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue where the service incorrectly returned a Service Unavailable status during shutdown. It now correctly returns an OK status.
  • Tests

    • Enhanced tests to validate the correct status codes during service shutdown scenarios.

Signed-off-by: Kajetan <cv65kr@gmail.com>
@cv65kr cv65kr added the bug Something isn't working label Jun 18, 2024
@cv65kr cv65kr requested a review from rustatian June 18, 2024 07:22
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 18, 2024

Walkthrough

The recent updates focused on changing the HTTP status code returned by the Health struct’s ServeHTTP method during shutdown from 503 Service Unavailable to 200 OK. Furthermore, additional logic was introduced in the TestShutdown503 unit test to check and handle HTTP status codes both before and after waiting on a wait group.

Changes

File Change Summary
health.go Modified the ServeHTTP method to return 200 OK instead of 503 Service Unavailable when the service is shutting down.
tests/plugin_test.go Enhanced the TestShutdown503 function with logic to handle and validate HTTP requests before and after wait group completion.

Poem

In the code, a gentle switch was made,
From troubled 503 to calm 200 displayed.
With grace the service doesn't frown,
Even when it's shutting down.
Testers probe with thoughtful intention,
Ensuring stability meets pure perfection.
🐇🚀


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a 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

Commits

Files that changed from the base of the PR and between 06d44d9 and e567c81.

Files selected for processing (2)
  • health.go (1 hunks)
  • tests/plugin_test.go (1 hunks)
Additional comments not posted (2)
health.go (1)

30-30: The change to return HTTP 200 OK during a graceful shutdown is aligned with the PR objectives. Consider adding a comment explaining why a 200 status code is used during shutdown, as it might not be immediately clear to other developers or maintainers.

tests/plugin_test.go (1)

572-572: The updated assertions in the test cases correctly check for the expected HTTP status codes during a graceful shutdown. Consider adding comments to explain why the /health endpoint returns 200 OK and the /ready endpoint returns 503 Service Unavailable during a shutdown, to clarify the test's intent.

Also applies to: 580-580

@cv65kr cv65kr merged commit 6bd8d54 into master Jun 18, 2024
@rustatian rustatian deleted the fix/health-endpoint branch June 18, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants