diff --git a/pageserver/src/http/openapi_spec.yml b/pageserver/src/http/openapi_spec.yml index 408d066fb4..02569a3778 100644 --- a/pageserver/src/http/openapi_spec.yml +++ b/pageserver/src/http/openapi_spec.yml @@ -113,6 +113,7 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" + /v1/tenant/{tenant_id}/timeline/{timeline_id}: parameters: - name: tenant_id @@ -242,25 +243,6 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" - /v1/tenant/{tenant_id}/timeline/{timeline_id}/attach: - parameters: - - name: tenant_id - in: path - required: true - schema: - type: string - format: hex - - name: timeline_id - in: path - required: true - schema: - type: string - format: hex - post: - description: Deprecated - responses: - "410": - description: GONE /v1/tenant/{tenant_id}/attach: parameters: @@ -327,10 +309,35 @@ paths: type: string format: hex post: - description: Deprecated + description: Deprecated, use DELETE /v1/tenant/{tenant_id}/timeline/{timeline_id} instead + deprecated: true responses: - "410": - description: GONE + "200": + description: Ok + "400": + description: Error when no tenant id found in path or no timeline id + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "401": + description: Unauthorized Error + content: + application/json: + schema: + $ref: "#/components/schemas/UnauthorizedError" + "403": + description: Forbidden Error + content: + application/json: + schema: + $ref: "#/components/schemas/ForbiddenError" + "500": + description: Generic operation error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" /v1/tenant/{tenant_id}/detach: parameters: diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 2cf5e7a828..236415cf58 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -242,10 +242,6 @@ async fn wal_receiver_get_handler(request: Request) -> Result) -> Result, ApiError> { - json_response(StatusCode::GONE, ()) -} - // TODO makes sense to provide tenant config right away the same way as it handled in tenant_create async fn tenant_attach_handler(request: Request) -> Result, ApiError> { let tenant_id: ZTenantId = parse_request_param(&request, "tenant_id")?; @@ -605,17 +601,14 @@ pub fn make_router( "/v1/tenant/:tenant_id/timeline/:timeline_id", timeline_delete_handler, ) - .get( - "/v1/tenant/:tenant_id/timeline/:timeline_id/wal_receiver", - wal_receiver_get_handler, - ) - .post( - "/v1/tenant/:tenant_id/timeline/:timeline_id/attach", - timeline_attach_handler, - ) + // for backward compatibility .post( "/v1/tenant/:tenant_id/timeline/:timeline_id/detach", timeline_delete_handler, ) + .get( + "/v1/tenant/:tenant_id/timeline/:timeline_id/wal_receiver", + wal_receiver_get_handler, + ) .any(handler_404)) } diff --git a/pageserver/src/layered_repository.rs b/pageserver/src/layered_repository.rs index a1870703f4..55f01ee962 100644 --- a/pageserver/src/layered_repository.rs +++ b/pageserver/src/layered_repository.rs @@ -408,20 +408,19 @@ impl Repository for LayeredRepository { Ok(()) } - // in order to be retriable detach needs to be idempotent fn delete_timeline(&self, timeline_id: ZTimelineId) -> anyhow::Result<()> { // in order to be retriable detach needs to be idempotent + // (or at least to a point that each time the detach is called it can make progress) let mut timelines = self.timelines.lock().unwrap(); // Ensure that there are no child timelines **attached to that pageserver**, - // because detach removes files, which will brake child branches - let num_children = timelines + // because detach removes files, which will break child branches + let children_exist = timelines .iter() - .filter(|(_, entry)| entry.ancestor_timeline_id() == Some(timeline_id)) - .count(); + .any(|(_, entry)| entry.ancestor_timeline_id() == Some(timeline_id)); ensure!( - num_children == 0, + !children_exist, "Cannot detach timeline which has child timelines" ); let timeline_entry = match timelines.entry(timeline_id) { diff --git a/pageserver/src/storage_sync/download.rs b/pageserver/src/storage_sync/download.rs index d023a8ef52..0f2bdd3bcb 100644 --- a/pageserver/src/storage_sync/download.rs +++ b/pageserver/src/storage_sync/download.rs @@ -119,14 +119,12 @@ where }); } - let index_parts = download_index_parts(conf, storage, sync_ids) + download_index_parts(conf, storage, sync_ids) .await .remove(&tenant_id) .ok_or(anyhow::anyhow!( "Missing tenant index parts. This is a bug." - ))?; - - Ok(index_parts) + )) } /// Retrieves index data from the remote storage for a given timeline.