Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Plan: Add Health Check for PROVIDER_HTTP_URL Endpoint

  • Explore repository structure and understand the application setup
  • Modify staking/entrypoint.sh to add health check logic before starting the validator
    • Add function to check endpoint availability
    • Add retry logic with configurable timeout and sleep interval
    • Add logging for each check attempt
  • Install curl in the Dockerfile (required for health checks)
  • Test the modified entrypoint script (validated with local HTTP server tests)
  • Address code review feedback
    • Exit with error if PROVIDER_HTTP_URL is not set (instead of just warning)
    • Add validation for configuration parameters (must be positive integers)
    • Remove --fail flag to consider any HTTP response as healthy (connection established = healthy)
  • Run security scan (no issues found)

Summary

Successfully implemented a health check mechanism that prevents the Starknet validator from crashing when started before the execution service completes its data download (which can take up to 2 hours).

Key Features:

  • ✅ Checks endpoint availability by verifying connection can be established
  • ✅ Considers any HTTP response (including 404) as healthy - the key is that the port is listening
  • ✅ Configurable retry logic (default: 360 retries × 20s = 2 hours)
  • ✅ Detailed logging on every attempt
  • ✅ Validates configuration parameters
  • ✅ Fails fast if PROVIDER_HTTP_URL is not set
  • ✅ Minimal changes to existing codebase (2 files modified)

Configuration Environment Variables:

  • HEALTH_CHECK_MAX_RETRIES (default: 360)
  • HEALTH_CHECK_SLEEP_INTERVAL (default: 20 seconds)
  • HEALTH_CHECK_TIMEOUT (default: 5 seconds)
Original prompt

the application to work needs the endpoint PROVIDER_HTTP_URL available, this endpoint belongs to an API of a service that will be up and running only after some data download that can take up to 2 hours. If this app starts while the other is still downloading the data, it will crash

I would like to add a sanity check before starting the app to check that the API endpoint is listening (if its listening it can be consider the endpoint is healthy), If not sleep or something and do another check after a while.

The endpoint has this format "http://execution.starknet.staker.dappnode:6060/v0_9"

In the implementation I want to log in every try


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 23, 2025 08:37
…logging

Co-authored-by: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com>
Co-authored-by: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com>
Co-authored-by: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add sanity check for API endpoint availability Add health check to wait for execution endpoint availability before starting validator Dec 23, 2025
@pablomendezroyo pablomendezroyo marked this pull request as ready for review December 23, 2025 08:42
# Health check function
check_endpoint_health() {
local url=$1
if curl --silent --fail --max-time "${TIMEOUT}" "${url}" > /dev/null 2>&1; then
Copy link
Contributor

Choose a reason for hiding this comment

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

In my case the "healthy" condition is when the domain resolves and the port is opened and listening so the connection can be established, no matter the http code returned by the server

i.e this should considered as healthy
`curl -v --fail --max-time "5" "http://execution.starknet-sepolia.dncore.dappnode:6060/v0_9"

  • Host execution.starknet-sepolia.dncore.dappnode:6060 was resolved.
  • IPv6: (none)
  • IPv4: 172.33.0.31
  • Trying 172.33.0.31:6060...
  • Connected to execution.starknet-sepolia.dncore.dappnode (172.33.0.31) port 6060

GET /v0_9 HTTP/1.1
Host: execution.starknet-sepolia.dncore.dappnode:6060
User-Agent: curl/8.5.0
Accept: /

< HTTP/1.1 404 Not Found
< Date: Tue, 23 Dec 2025 08:52:49 GMT
< Content-Length: 0

  • The requested URL returned error: 404
  • Closing connection
    curl: (22) The requested URL returned error: 404`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c3bc46b. Removed the --fail flag from curl so that any HTTP response (including 404) is considered healthy. The health check now only verifies that the connection can be established and the port is listening, regardless of the HTTP status code returned.

…ncluding 404)

Co-authored-by: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 23, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • non-existent-host-12345
    • Triggering command: /usr/bin/curl curl --silent --max-time 3 http://non-existent-host-12345:9999/ (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@pablomendezroyo pablomendezroyo merged commit bfa279e into main Dec 23, 2025
2 checks passed
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.

3 participants