Skip to content

Commit

Permalink
chore(cat-gateway): rm auth k8s health check (#1747)
Browse files Browse the repository at this point in the history
* refactor(rm auth): k8s health check

* refactor(rm auth): k8s health check

* refactor(rm auth): k8s health check

* schema version check tmp removal

* schema version check tmp removal
  • Loading branch information
cong-or authored Jan 31, 2025
1 parent 0d795ac commit d4e105f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions catalyst-gateway/bin/src/service/api/health/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Health Endpoints
use poem_openapi::{param::Query, OpenApi};

use crate::service::common::{auth::api_key::InternalApiKeyAuthorization, tags::ApiTags};
use crate::service::common::{auth::none::NoAuthorization, tags::ApiTags};

mod inspection_get;
mod live_get;
Expand All @@ -28,7 +28,7 @@ impl HealthApi {
method = "get",
operation_id = "healthStarted"
)]
async fn started_get(&self, _auth: InternalApiKeyAuthorization) -> started_get::AllResponses {
async fn started_get(&self, _auth: NoAuthorization) -> started_get::AllResponses {
started_get::endpoint().await
}

Expand All @@ -46,7 +46,7 @@ impl HealthApi {
method = "get",
operation_id = "healthReady"
)]
async fn ready_get(&self, _auth: InternalApiKeyAuthorization) -> ready_get::AllResponses {
async fn ready_get(&self, _auth: NoAuthorization) -> ready_get::AllResponses {
ready_get::endpoint().await
}

Expand All @@ -59,7 +59,7 @@ impl HealthApi {
/// *This endpoint is for internal use of the service deployment infrastructure.
/// It may not be exposed publicly. Refer to []*
#[oai(path = "/v1/health/live", method = "get", operation_id = "healthLive")]
async fn live_get(&self, _auth: InternalApiKeyAuthorization) -> live_get::AllResponses {
async fn live_get(&self, _auth: NoAuthorization) -> live_get::AllResponses {
live_get::endpoint().await
}

Expand All @@ -84,7 +84,7 @@ impl HealthApi {
/// Enable or disable Verbose Query inspection in the logs. Used to find query
/// performance issues.
query_inspection: Query<Option<inspection_get::DeepQueryInspectionFlag>>,
_auth: InternalApiKeyAuthorization,
_auth: NoAuthorization,
) -> inspection_get::AllResponses {
inspection_get::endpoint(log_level.0, query_inspection.0).await
}
Expand Down
32 changes: 16 additions & 16 deletions catalyst-gateway/bin/src/service/api/health/ready_get.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
//! Implementation of the GET /health/ready endpoint
use poem_openapi::ApiResponse;
use tracing::{debug, error};

use crate::{
db::event::{schema_check::MismatchedSchemaError, EventDB},
service::common::responses::WithErrorResponses,
};
use crate::service::common::responses::WithErrorResponses;

/// Endpoint responses.
#[derive(ApiResponse)]
Expand All @@ -14,6 +10,7 @@ pub(crate) enum Responses {
#[oai(status = 204)]
NoContent,
/// Service is not ready, do not send other requests.
#[allow(dead_code)]
#[oai(status = 503)]
ServiceUnavailable,
}
Expand All @@ -38,16 +35,19 @@ pub(crate) type AllResponses = WithErrorResponses<Responses>;
/// and is not able to properly service requests while it is occurring.
/// This would let the load balancer shift traffic to other instances of this
/// service that are ready.
#[allow(clippy::unused_async)]
pub(crate) async fn endpoint() -> AllResponses {
match EventDB::schema_version_check().await {
Ok(_) => {
debug!("DB schema version status ok");
Responses::NoContent.into()
},
Err(err) if err.is::<MismatchedSchemaError>() => {
error!(id="health_ready_mismatch_schema", error=?err, "DB schema version mismatch");
Responses::ServiceUnavailable.into()
},
Err(err) => AllResponses::handle_error(&err),
}
// TODO: fix schema version check
Responses::NoContent.into()
// match EventDB::schema_version_check().await {
// Ok(_) => {
// debug!("DB schema version status ok");
// Responses::NoContent.into()
// },
// Err(err) if err.is::<MismatchedSchemaError>() => {
// error!(id="health_ready_mismatch_schema", error=?err, "DB schema version
// mismatch"); Responses::ServiceUnavailable.into()
// },
// Err(err) => AllResponses::handle_error(&err),
// }
}

0 comments on commit d4e105f

Please sign in to comment.