madara-alliance / madara

Madara is a powerful hybrid Starknet client written in Rust.
https://madara.build
Apache License 2.0
71 stars 25 forks source link

Node readiness overhaul #223

Open cchudant opened 1 month ago

cchudant commented 1 month ago

Is there an existing issue?

Motivation

The /health endpoint on the node is a health check endpoint designed to work with kubernetes startup probe so that the node does not appear as available in k8s (i.e. not ready to answer rpc requests) when it is starting up

Returning anything other than 200 on this endpoint marks the node as not ready.

This is not a priority, but this feature would be important for node operators running multiple madara node in a cluster, so that a madara node that is restarting / starting for the first time does not get registered in the load balancer and doesn't receive rpc calls while it is starting.

Request

The current endpoint is always up at the same time rpcs go up

Solution

Readiness should be defined as:

In any case, I'd like to have a generic struct like

pub type ServiceName = String;
struct ServiceReadiness {
  service: String,
  on_ready: oneshot::Receiver<()>,
}
pub struct ReadinessProbe(Arc<Mutex<Vec<Readiness>>>);
impl ReadinessProbe {
  fn register_service_readiness(service: ServiceName) -> oneshot::Sender<()> {}
  fn is_all_ready(&self) -> bool {}
}

this would be shared between the services, and the start function of each service would register their readiness condition.

Are you willing to help with this request?

Yes!