Skip to content

Commit 91d72a9

Browse files
committed
Fold both healthz and readyz routes into the same path for now
Also remove the Arc from the config kept in the context.
1 parent ad5f05d commit 91d72a9

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

src/config/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub async fn build_context(cfg: schema::SeafowlConfig) -> Result<SeafowlContext>
236236
// (it will reload its schema before running the query)
237237

238238
Ok(SeafowlContext {
239-
config: Arc::new(cfg),
239+
config: cfg,
240240
inner: context,
241241
metastore: Arc::new(metastore),
242242
internal_object_store,

src/context/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use uuid::Uuid;
2222
// The core Seafowl object, responsible for parsing, logical and physical planning, as well as
2323
// interacting with the catalog and object store.
2424
pub struct SeafowlContext {
25-
pub config: Arc<SeafowlConfig>,
25+
pub config: SeafowlConfig,
2626
pub inner: SessionContext,
2727
pub metastore: Arc<Metastore>,
2828
pub internal_object_store: Arc<InternalObjectStore>,

src/frontend/http.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ async fn load_part(mut part: Part) -> Result<Vec<u8>, ApiError> {
484484
Ok(bytes)
485485
}
486486

487-
/// GET /readyz
487+
/// GET /healthz or /readyz
488488
pub async fn health_endpoint(context: Arc<SeafowlContext>) -> Result<Response, ApiError> {
489489
#[cfg(feature = "frontend-arrow-flight")]
490490
if let Some(flight) = &context.config.frontend.flight {
@@ -527,14 +527,24 @@ pub fn filters(
527527
let path = info.path();
528528

529529
#[cfg(feature = "metrics")]
530-
counter!(
531-
HTTP_REQUESTS,
532-
"method" => info.method().as_str().to_string(),
533-
// Omit a potential db prefix or url-encoded query from the path
534-
"route" => if path.contains("/upload/") { "/upload" } else if path.contains("/readyz") { "/readyz" } else { "/q" },
535-
"status" => info.status().as_u16().to_string(),
536-
)
537-
.increment(1);
530+
{
531+
let route = if path.contains("/upload/") {
532+
"/upload".to_string()
533+
} else if path.contains("/q") {
534+
"/q".to_string()
535+
} else {
536+
path.to_string()
537+
};
538+
539+
counter!(
540+
HTTP_REQUESTS,
541+
"method" => info.method().as_str().to_string(),
542+
// Omit a potential db prefix or url-encoded query from the path
543+
"route" => route,
544+
"status" => info.status().as_u16().to_string(),
545+
)
546+
.increment(1);
547+
}
538548

539549
info!(
540550
target: module_path!(),
@@ -623,9 +633,11 @@ pub fn filters(
623633

624634
// Health-check/readiness probe
625635
let ctx = context;
626-
let health_route = warp::path!("readyz")
636+
let health_route = warp::path!("healthz")
637+
.or(warp::path!("readyz"))
627638
.and(warp::path::end())
628639
.and(warp::get())
640+
.unify()
629641
.and(warp::any().map(move || ctx.clone()))
630642
.then(health_endpoint)
631643
.map(into_response);

tests/main.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@ impl TestSeafowl {
3434
.config
3535
.frontend
3636
.http
37-
.as_ref()
38-
.expect("HTTP frontend configured")
39-
.clone();
37+
.clone()
38+
.expect("HTTP frontend configured");
4039
format!("http://{}:{}", http.bind_host, http.bind_port)
4140
}
4241

4342
pub fn metrics_port(&self) -> u16 {
4443
self.config
4544
.misc
4645
.metrics
47-
.as_ref()
46+
.clone()
4847
.expect("Metrics configured")
4948
.port
5049
}

0 commit comments

Comments
 (0)