From e0cd0fac0db23b8a0cbf8d1c5c005af18aaca023 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 4 Jan 2024 17:51:31 +0000 Subject: [PATCH] control_plane: selectively pass through timeline create errors --- control_plane/attachment_service/src/service.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/control_plane/attachment_service/src/service.rs b/control_plane/attachment_service/src/service.rs index 5cf9aeb6fe..d59b8e339a 100644 --- a/control_plane/attachment_service/src/service.rs +++ b/control_plane/attachment_service/src/service.rs @@ -10,6 +10,7 @@ use control_plane::attachment_service::{ TenantCreateResponseShard, TenantLocateResponse, TenantLocateResponseShard, TenantShardMigrateRequest, TenantShardMigrateResponse, }; +use hyper::StatusCode; use pageserver_api::{ control_api::{ ReAttachRequest, ReAttachResponse, ReAttachResponseTenant, ValidateRequest, @@ -443,7 +444,17 @@ impl Service { let shard_timeline_info = client .timeline_create(tenant_shard_id, &create_req) .await - .map_err(|e| ApiError::Conflict(format!("Failed to create timeline: {e}")))?; + .map_err(|e| match e { + mgmt_api::Error::ApiError(status, msg) + if status == StatusCode::INTERNAL_SERVER_ERROR + || status == StatusCode::NOT_ACCEPTABLE => + { + // TODO: handle more error codes, e.g. 503 should be passed through. Make a general wrapper + // for pass-through API calls. + ApiError::InternalServerError(anyhow::anyhow!(msg)) + } + _ => ApiError::Conflict(format!("Failed to create timeline: {e}")), + })?; if timeline_info.is_none() { // If the caller specified an ancestor but no ancestor LSN, we are responsible for