mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 17:32:56 +00:00
Add GetTenantError::NotActivated
This commit is contained in:
@@ -162,6 +162,9 @@ impl From<GetTenantError> for ApiError {
|
||||
e @ GetTenantError::NotLoaded(_, _) => {
|
||||
ApiError::InternalServerError(anyhow::Error::new(e))
|
||||
}
|
||||
e @ GetTenantError::NotActivated(_, _) => {
|
||||
ApiError::InternalServerError(anyhow::Error::new(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1180,6 +1180,9 @@ async fn get_active_tenant_with_timeout(
|
||||
Ok(tenant) => tenant,
|
||||
Err(e @ GetTenantError::NotFound(_)) => return Err(GetActiveTenantError::NotFound(e)),
|
||||
Err(e @ GetTenantError::NotLoaded(_, _)) => return Err(GetActiveTenantError::NotFound(e)),
|
||||
Err(e @ GetTenantError::NotActivated(_, _)) => {
|
||||
return Err(GetActiveTenantError::NotFound(e))
|
||||
}
|
||||
Err(GetTenantError::NotActive(_)) => {
|
||||
unreachable!("we're calling get_tenant with active=false")
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ struct RemoteStartupData {
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub(crate) enum WaitToBecomeActiveError {
|
||||
pub enum WaitToBecomeActiveError {
|
||||
WillNotBecomeActive {
|
||||
tenant_id: TenantId,
|
||||
state: TenantState,
|
||||
|
||||
@@ -22,6 +22,7 @@ use crate::task_mgr::{self, TaskKind};
|
||||
use crate::tenant::config::TenantConfOpt;
|
||||
use crate::tenant::{
|
||||
create_tenant_files, CreateTenantFilesMode, SetStoppingError, Tenant, TenantState,
|
||||
WaitToBecomeActiveError,
|
||||
};
|
||||
use crate::IGNORED_TENANT_FILE_NAME;
|
||||
|
||||
@@ -68,7 +69,7 @@ impl LazyTenantsMap {
|
||||
tenant
|
||||
.wait_to_become_active()
|
||||
.await
|
||||
.map_err(|_| GetTenantError::NotActive(*tenant_id))?;
|
||||
.map_err(|e| GetTenantError::NotActivated(*tenant_id, e))?;
|
||||
}
|
||||
Ok(tenant)
|
||||
}
|
||||
@@ -493,8 +494,10 @@ pub enum GetTenantError {
|
||||
NotFound(TenantId),
|
||||
#[error("Tenant {0} is not active")]
|
||||
NotActive(TenantId),
|
||||
#[error("Tenant {0} can not be loaded")]
|
||||
#[error("Tenant {0} can not be loaded: {1}")]
|
||||
NotLoaded(TenantId, anyhow::Error),
|
||||
#[error("Tenant {0} can not be activated: {1}")]
|
||||
NotActivated(TenantId, WaitToBecomeActiveError),
|
||||
}
|
||||
|
||||
/// Gets the tenant from the in-memory data, erroring if it's absent or is not fitting to the query.
|
||||
|
||||
Reference in New Issue
Block a user