Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ rstest = "0.26.1"
rustls-pemfile = "2.2.0"
rustyline = "15.0.0"
serde_bare = "0.5.0"
serde_html_form = "0.2.7"
serde_yaml = "0.9.34"
sha2 = "0.10"
slog = "2.7"
Expand Down
1 change: 0 additions & 1 deletion docker/template/src/docker-compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ export function generateDockerCompose(context: TemplateContext) {
restart: "unless-stopped",
environment: [
`RIVET_ENDPOINT=http://${context.getServiceHost("rivet-engine", datacenter.name, 0)}:6420`,
`RUNNER_HOST=${context.getServiceHost("runner", datacenter.name, i)}`,
],
stop_grace_period: "4s",
ports: isPrimary && i === 0 ? [`5050:5050`] : undefined,
Expand Down
2 changes: 0 additions & 2 deletions packages/common/api-builder/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ impl fmt::Debug for ApiCtx {

impl ApiCtx {
pub fn new(global: GlobalApiCtx, ray_id: Id, req_id: Id) -> Result<Self> {
// Create StandaloneCtx synchronously by using a blocking call
// This is necessary because we need Clone support and async Clone is not possible
let standalone_ctx = StandaloneCtx::new(
global.db.clone(),
global.config.clone(),
Expand Down
1 change: 1 addition & 0 deletions packages/common/api-builder/src/error_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl IntoResponse for ApiError {
internal: if error_response.group == rivet_error::INTERNAL_ERROR.group
&& error_response.code == rivet_error::INTERNAL_ERROR.code
{
tracing::debug!(err=?self.0, "internal debug error");
Some(format!("{}", self.0).into())
} else {
None
Expand Down
1 change: 1 addition & 0 deletions packages/common/api-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rivet-config.workspace = true
rivet-error.workspace = true
rivet-pools.workspace = true
rivet-util.workspace = true
serde_html_form.workspace = true
serde.workspace = true
tokio.workspace = true
tracing.workspace = true
36 changes: 24 additions & 12 deletions packages/common/api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,26 @@ pub async fn request_remote_datacenter_raw(
.ok_or_else(|| errors::Datacenter::NotFound.build())?;

let client = rivet_pools::reqwest::client().await?;
let url = dc.api_peer_url.join(endpoint)?;

let mut request = client.request(method, url).headers(headers);
let mut url = dc.api_peer_url.join(endpoint)?;

// NOTE: We don't use reqwest's `.query` because it doesn't support list query parameters
if let Some(q) = query {
request = request.query(q);
url.set_query(Some(&serde_html_form::to_string(q)?));
}

let mut request = client.request(method, url).headers(headers);

if let Some(b) = body {
request = request.json(b);
}

let res = request.send().await?;
rivet_api_util::reqwest_to_axum_response(res).await
let res = request
.send()
.await
.context("failed sending request to remote dc")?;
rivet_api_util::reqwest_to_axum_response(res)
.await
.context("failed parsing response from remote dc")
}

/// Generic function to make requests to a specific datacenter
Expand All @@ -59,20 +65,26 @@ where
.ok_or_else(|| errors::Datacenter::NotFound.build())?;

let client = rivet_pools::reqwest::client().await?;
let url = dc.api_peer_url.join(endpoint)?;

let mut request = client.request(method, url).headers(headers);
let mut url = dc.api_peer_url.join(endpoint)?;

// NOTE: We don't use reqwest's `.query` because it doesn't support list query parameters
if let Some(q) = query {
request = request.query(q);
url.set_query(Some(&serde_html_form::to_string(q)?));
}

let mut request = client.request(method, url).headers(headers);

if let Some(b) = body {
request = request.json(b);
}

let res = request.send().await?;
rivet_api_util::parse_response::<T>(res).await
let res = request
.send()
.await
.context("failed sending request to remote dc")?;
rivet_api_util::parse_response::<T>(res)
.await
.context("failed parsing response from remote dc")
}

/// Generic function to fanout requests to all datacenters and aggregate results
Expand Down
1 change: 0 additions & 1 deletion packages/common/types/src/datacenters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ use utoipa::ToSchema;
pub struct Datacenter {
pub datacenter_label: u16,
pub name: String,
pub url: String,
}
1 change: 0 additions & 1 deletion packages/core/api-public/src/datacenters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub async fn list(ctx: ApiCtx, _path: (), _query: ()) -> Result<ListResponse> {
.map(|dc| Datacenter {
datacenter_label: dc.datacenter_label,
name: dc.name.clone(),
url: dc.guard_url.to_string(),
})
.collect(),
pagination: Pagination { cursor: None },
Expand Down
22 changes: 14 additions & 8 deletions packages/services/epoxy/src/workflows/coordinator/reconfigure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,25 @@ pub async fn health_check_new_replicas(
async move {
tracing::info!(?replica_id, "sending health check to replica");

let from_replica_id = ctx.config().epoxy_replica_id();
let request = protocol::Request {
from_replica_id: ctx.config().epoxy_replica_id(),
from_replica_id,
to_replica_id: replica_id,
kind: protocol::RequestKind::HealthCheckRequest,
};

crate::http_client::send_message_to_address(
replica.api_peer_url.clone(),
replica_id,
request,
)
.await
.with_context(|| format!("health check failed for replica {}", replica_id))?;
// Call directly instead of sending request for same replica
if from_replica_id == replica_id {
tracing::info!(?replica_id, "skipping health check to self");
} else {
crate::http_client::send_message_to_address(
replica.api_peer_url.clone(),
replica_id,
request,
)
.await
.with_context(|| format!("health check failed for replica {}", replica_id))?;
}

tracing::info!(?replica_id, "health check successful");
Ok(())
Expand Down
Loading