Skip to content
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

rpc server: add health/readiness endpoint #4802

Merged
merged 7 commits into from
Jun 19, 2024
Merged

rpc server: add health/readiness endpoint #4802

merged 7 commits into from
Jun 19, 2024

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Jun 14, 2024

Previous attempt paritytech/substrate#14314

Close #4443

Ideally, we should move /health and /health/readiness to the prometheus server but because it's was quite easy to implement on the RPC server and that RPC server already exposes /health.

Manual tests on a polkadot node syncing:

➜ polkadot-sdk (na-fix-4443) ✗ curl -v localhost:9944/health
* Host localhost:9944 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9944...
* connect to ::1 port 9944 from ::1 port 55024 failed: Connection refused
*   Trying 127.0.0.1:9944...
* Connected to localhost (127.0.0.1) port 9944
> GET /health HTTP/1.1
> Host: localhost:9944
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: application/json; charset=utf-8
< content-length: 53
< date: Fri, 14 Jun 2024 16:12:23 GMT
<
* Connection #0 to host localhost left intact
{"peers":0,"isSyncing":false,"shouldHavePeers":false}%
➜ polkadot-sdk (na-fix-4443) ✗ curl -v localhost:9944/health/readiness
* Host localhost:9944 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9944...
* connect to ::1 port 9944 from ::1 port 54328 failed: Connection refused
*   Trying 127.0.0.1:9944...
* Connected to localhost (127.0.0.1) port 9944
> GET /health/readiness HTTP/1.1
> Host: localhost:9944
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< content-type: application/json; charset=utf-8
< content-length: 0
< date: Fri, 14 Jun 2024 16:12:36 GMT
<
* Connection #0 to host localhost left intact

//cc @BulatSaif you may be interested in this..

@niklasad1 niklasad1 added the T0-node This PR/Issue is related to the topic “node”. label Jun 14, 2024
@niklasad1 niklasad1 changed the title rpc: add health readiness endpoint rpc server: add health readiness endpoint Jun 14, 2024
@niklasad1 niklasad1 requested review from bkchr and lexnv June 14, 2024 16:30
doc:
- audience: Node Operator
description: |
Add health readiness endpoint to the rpc server
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to mention the path to poll this?

substrate/client/rpc-servers/src/middleware/node_health.rs Outdated Show resolved Hide resolved
Comment on lines 184 to 185
"/health" if req.method() == http::Method::GET => InterceptRequest::Health,
"/health/readiness" if req.method() == http::Method::GET => InterceptRequest::Readiness,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe could return an error if method() is not Get?

Copy link
Member Author

@niklasad1 niklasad1 Jun 18, 2024

Choose a reason for hiding this comment

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

good idea, done :)

substrate/client/rpc-servers/src/middleware/node_health.rs Outdated Show resolved Hide resolved
substrate/client/rpc-servers/src/middleware/node_health.rs Outdated Show resolved Hide resolved
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6488101

@niklasad1 niklasad1 requested review from acatangiu and a team as code owners June 18, 2024 08:23
@niklasad1
Copy link
Member Author

Sorry I fucked up a merge commit and I had to rebase

@niklasad1 niklasad1 removed request for a team and acatangiu June 18, 2024 08:42
@niklasad1 niklasad1 changed the title rpc server: add health readiness endpoint rpc server: add health/readiness endpoint Jun 18, 2024
Copy link
Contributor

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

LGTM!

@niklasad1 niklasad1 enabled auto-merge June 19, 2024 15:23
@niklasad1 niklasad1 added this pull request to the merge queue Jun 19, 2024
Merged via the queue into master with commit 6c85760 Jun 19, 2024
162 checks passed
@niklasad1 niklasad1 deleted the na-fix-4443 branch June 19, 2024 16:46
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
Previous attempt paritytech/substrate#14314

Close paritytech#4443 

Ideally, we should move /health and /health/readiness to the prometheus
server but because it's was quite easy to implement on the RPC server
and that RPC server already exposes /health.

Manual tests on a polkadot node syncing:

```bash
➜ polkadot-sdk (na-fix-4443) ✗ curl -v localhost:9944/health
* Host localhost:9944 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9944...
* connect to ::1 port 9944 from ::1 port 55024 failed: Connection refused
*   Trying 127.0.0.1:9944...
* Connected to localhost (127.0.0.1) port 9944
> GET /health HTTP/1.1
> Host: localhost:9944
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: application/json; charset=utf-8
< content-length: 53
< date: Fri, 14 Jun 2024 16:12:23 GMT
<
* Connection #0 to host localhost left intact
{"peers":0,"isSyncing":false,"shouldHavePeers":false}%
➜ polkadot-sdk (na-fix-4443) ✗ curl -v localhost:9944/health/readiness
* Host localhost:9944 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9944...
* connect to ::1 port 9944 from ::1 port 54328 failed: Connection refused
*   Trying 127.0.0.1:9944...
* Connected to localhost (127.0.0.1) port 9944
> GET /health/readiness HTTP/1.1
> Host: localhost:9944
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< content-type: application/json; charset=utf-8
< content-length: 0
< date: Fri, 14 Jun 2024 16:12:36 GMT
<
* Connection #0 to host localhost left intact
```

//cc @BulatSaif you may be interested in this..

---------

Co-authored-by: Bastian Köcher <[email protected]>
DaMandal0rian added a commit to autonomys/subspace that referenced this pull request Sep 12, 2024
DaMandal0rian added a commit to autonomys/subspace that referenced this pull request Sep 12, 2024
nazar-pc added a commit to autonomys/subspace that referenced this pull request Sep 12, 2024
* change health checkendpoint dockerfiles

elated to paritytech/polkadot-sdk#4802

* Add http:// prefix

---------

Co-authored-by: Nazar Mokrynskyi <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Nov 5, 2024
make the eth-rpc proxy /health and /health/readiness from the proxied
substrate chain
see #4802

---------

Co-authored-by: GitHub Action <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

readiness and liveness endpoints for service health monitoring
4 participants