refactor: needlessly fallible

DeleteTenantFlow::should_resume_deletion -- unsure why it originally
left like this, probably an oversight I had while reviewing.
This commit is contained in:
Joonas Koivunen
2023-11-27 11:42:28 +00:00
parent b80b9e1c4c
commit f8536c741f
2 changed files with 12 additions and 29 deletions

View File

@@ -618,21 +618,12 @@ impl Tenant {
// Remote preload is complete.
drop(remote_load_completion);
let pending_deletion = {
match DeleteTenantFlow::should_resume_deletion(
conf,
preload.as_ref().map(|p| p.deleting).unwrap_or(false),
&tenant_clone,
)
.await
{
Ok(should_resume_deletion) => should_resume_deletion,
Err(err) => {
make_broken(&tenant_clone, anyhow::anyhow!(err));
return Ok(());
}
}
};
let pending_deletion = DeleteTenantFlow::should_resume_deletion(
conf,
preload.as_ref().map(|p| p.deleting).unwrap_or(false),
&tenant_clone,
)
.await;
info!("pending_deletion {}", pending_deletion.is_some());

View File

@@ -361,25 +361,17 @@ impl DeleteTenantFlow {
conf: &'static PageServerConf,
remote_mark_exists: bool,
tenant: &Tenant,
) -> Result<Option<DeletionGuard>, DeleteTenantError> {
let acquire = |t: &Tenant| {
) -> Option<DeletionGuard> {
let tenant_id = tenant.tenant_id;
if remote_mark_exists || conf.tenant_deleted_mark_file_path(&tenant_id).exists() {
Some(
Arc::clone(&t.delete_progress)
Arc::clone(&tenant.delete_progress)
.try_lock_owned()
.expect("we're the only owner during init"),
)
};
if remote_mark_exists {
return Ok(acquire(tenant));
}
let tenant_id = tenant.tenant_id;
// Check local mark first, if its there there is no need to go to s3 to check whether remote one exists.
if conf.tenant_deleted_mark_file_path(&tenant_id).exists() {
Ok(acquire(tenant))
} else {
Ok(None)
None
}
}