Skip to content

feat(relay): Healthcheck command for self hosted and devservices#5044

Merged
Dav1dde merged 7 commits intogetsentry:masterfrom
aldy505:feat/relay-healthcheck
Aug 13, 2025
Merged

feat(relay): Healthcheck command for self hosted and devservices#5044
Dav1dde merged 7 commits intogetsentry:masterfrom
aldy505:feat/relay-healthcheck

Conversation

@aldy505
Copy link
Collaborator

@aldy505 aldy505 commented Aug 9, 2025

We're (on self-hosted) trying to add healthcheck on Relay since David changed the base image to distroless, hence the only thing on the Docker image is just the relay binary.

I don't know how to pass in the config file while making it optional. If this is specific for self-hosted, I don't think reading from the config file is mandatory since we will be executing this on Docker Compose's healthcheck mechanism.

@aldy505 aldy505 requested a review from a team as a code owner August 9, 2025 15:54
@aldy505 aldy505 requested a review from Dav1dde August 9, 2025 15:54
cursor[bot]

This comment was marked as outdated.

@aldy505 aldy505 changed the title feat: healthcheck command for relay program feat(relay): healthcheck command for relay program Aug 10, 2025
@aldy505 aldy505 changed the title feat(relay): healthcheck command for relay program feat(relay): Healthcheck command for relay program Aug 10, 2025
Comment on lines +14 to +19
if mode != "live" && mode != "ready" {
return Err(format_err!(
"Invalid mode. Expected `live` or `ready`, got `{}`.",
mode
));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have clap validate this as an enum and then here just extract the enum?

match response {
Ok(response) => {
if response.status().is_success() {
println!("Relay is healthy.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally avoid prints, if they are useful we can keep them, otherwise I would just only use the status code and instead work more with some log messages.

@aldy505 aldy505 requested a review from Dav1dde August 11, 2025 12:56
Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding an integration test (maybe a new test_healthcheck.py) which asserts that the command has a bad exit code when Relay is not running but a successful one when it is running?

Bonus: a test which asserts a bad exit code when Relay is unhealthy (possible to configure through e.g. memory thresholds).

The get_relay_binary should give you the necessary binary to run the command via subprocess.

@aldy505
Copy link
Collaborator Author

aldy505 commented Aug 12, 2025

@Dav1dde Can I do that on a separate PR? I'm trying to chase the next release schedule on the 15th.

@Dav1dde
Copy link
Member

Dav1dde commented Aug 12, 2025

Sure, if you're certain what you added works ;)

@Dav1dde Dav1dde changed the title feat(relay): Healthcheck command for relay program feat(relay): Healthcheck command for self hosted and devservices Aug 13, 2025
@Dav1dde Dav1dde enabled auto-merge August 13, 2025 06:37
@Dav1dde Dav1dde added this pull request to the merge queue Aug 13, 2025
Merged via the queue into getsentry:master with commit 1100a80 Aug 13, 2025
47 of 49 checks passed
@aldy505 aldy505 deleted the feat/relay-healthcheck branch August 13, 2025 07:16
aldy505 added a commit to aldy505/sentry-symbolicator that referenced this pull request Oct 1, 2025
Dav1dde added a commit to getsentry/symbolicator that referenced this pull request Oct 1, 2025
Similar work to getsentry/relay#5044 due to
distroless migration

This works on relay and this is making CI's red right now.

Changes made:
- Adds a new `healthcheck` sub-command
- Defaults to the values from the config
- Changes logger to use `stderr` to still allow for logging and parsing
of the healthcheck output (Relay uses the same mechanism here)

---------

Co-authored-by: David Herberth <david.herberth@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants