Skip to content

Commit

Permalink
Remove unused errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsp committed Oct 10, 2023
1 parent b3ffd99 commit b36abf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 0 additions & 2 deletions pageserver/src/http/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl From<TenantSlotError> for ApiError {
ApiError::NotFound(anyhow::anyhow!("Tenant {tenant_id} not found").into())
}
e @ AlreadyExists(_, _) => ApiError::Conflict(format!("{e}")),
e @ Conflict(_) => ApiError::Conflict(format!("{e}")),
InProgress => {
ApiError::ResourceUnavailable("Tenant is being modified concurrently".into())
}
Expand Down Expand Up @@ -195,7 +194,6 @@ impl From<TenantMapError> for ApiError {
impl From<TenantStateError> for ApiError {
fn from(tse: TenantStateError) -> ApiError {
match tse {
TenantStateError::NotFound(tid) => ApiError::NotFound(anyhow!("tenant {}", tid).into()),
TenantStateError::NotActive(_) => {
ApiError::ResourceUnavailable("Tenant not yet active".into())
}
Expand Down
20 changes: 13 additions & 7 deletions pageserver/src/tenant/mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,6 @@ pub(crate) async fn delete_timeline(

#[derive(Debug, thiserror::Error)]
pub(crate) enum TenantStateError {
#[error("Tenant {0} not found")]
NotFound(TenantId),
#[error("Tenant {0} is stopping")]
IsStopping(TenantId),
#[error("Tenant {0} is not active")]
Expand Down Expand Up @@ -930,7 +928,12 @@ async fn detach_tenant0(

// Ignored tenants are not present in memory and will bail the removal from memory operation.
// Before returning the error, check for ignored tenant removal case — we only need to clean its local files then.
if detach_ignored && matches!(removal_result, Err(TenantStateError::NotFound(_))) {
if detach_ignored
&& matches!(
removal_result,
Err(TenantStateError::SlotError(TenantSlotError::NotFound(_)))
)
{
let tenant_ignore_mark = conf.tenant_ignore_mark_file_path(&tenant_id);
if tenant_ignore_mark.exists() {
info!("Detaching an ignored tenant");
Expand Down Expand Up @@ -1124,9 +1127,6 @@ pub(crate) enum TenantSlotError {
#[error("tenant {0} already exists, state: {1:?}")]
AlreadyExists(TenantId, TenantState),

#[error("tenant {0} already exists in but is not attached")]
Conflict(TenantId),

// Tried to read a slot that is currently being mutated by another administrative
// operation.
#[error("tenant has a state change in progress, try again later")]
Expand Down Expand Up @@ -1362,7 +1362,13 @@ where
// The SlotGuard allows us to manipulate the Tenant object without fear of some
// concurrent API request doing something else for the same tenant ID.
let attached_tenant = match tenant_slot {
Some(TenantSlot::Attached(t)) => Some(t),
Some(TenantSlot::Attached(t)) => {
if t.current_state() != TenantState::Active {
tenant_guard.upsert(TenantSlot::Attached(t))?;
return Err(TenantStateError::NotActive(tenant_id));
}
Some(t)
}
_ => None,
};

Expand Down

0 comments on commit b36abf8

Please sign in to comment.