Line data Source code
1 : //! Types in this file are for pageserver's upward-facing API calls to the storage controller,
2 : //! required for acquiring and validating tenant generation numbers.
3 : //!
4 : //! See docs/rfcs/025-generation-numbers.md
5 :
6 : use serde::{Deserialize, Serialize};
7 : use utils::generation::Generation;
8 : use utils::id::{NodeId, TimelineId};
9 :
10 : use crate::controller_api::NodeRegisterRequest;
11 : use crate::models::{LocationConfigMode, ShardImportStatus};
12 : use crate::shard::{ShardStripeSize, TenantShardId};
13 :
14 : /// Upcall message sent by the pageserver to the configured `control_plane_api` on
15 : /// startup.
16 0 : #[derive(Serialize, Deserialize)]
17 : pub struct ReAttachRequest {
18 : pub node_id: NodeId,
19 :
20 : /// Optional inline self-registration: this is useful with the storage controller,
21 : /// if the node already has a node_id set.
22 : #[serde(skip_serializing_if = "Option::is_none", default)]
23 : pub register: Option<NodeRegisterRequest>,
24 : }
25 :
26 0 : #[derive(Serialize, Deserialize, Debug)]
27 : pub struct ReAttachResponseTenant {
28 : pub id: TenantShardId,
29 : /// Mandatory if LocationConfigMode is None or set to an Attached* mode
30 : pub r#gen: Option<u32>,
31 : pub mode: LocationConfigMode,
32 : pub stripe_size: ShardStripeSize,
33 : }
34 0 : #[derive(Serialize, Deserialize)]
35 : pub struct ReAttachResponse {
36 : pub tenants: Vec<ReAttachResponseTenant>,
37 : }
38 :
39 0 : #[derive(Serialize, Deserialize)]
40 : pub struct ValidateRequestTenant {
41 : pub id: TenantShardId,
42 : pub r#gen: u32,
43 : }
44 :
45 0 : #[derive(Serialize, Deserialize)]
46 : pub struct ValidateRequest {
47 : pub tenants: Vec<ValidateRequestTenant>,
48 : }
49 :
50 0 : #[derive(Serialize, Deserialize)]
51 : pub struct ValidateResponse {
52 : pub tenants: Vec<ValidateResponseTenant>,
53 : }
54 :
55 0 : #[derive(Serialize, Deserialize)]
56 : pub struct ValidateResponseTenant {
57 : pub id: TenantShardId,
58 : pub valid: bool,
59 : }
60 :
61 0 : #[derive(Serialize, Deserialize)]
62 : pub struct TimelineImportStatusRequest {
63 : pub tenant_shard_id: TenantShardId,
64 : pub timeline_id: TimelineId,
65 : pub generation: Generation,
66 : }
67 :
68 0 : #[derive(Serialize, Deserialize)]
69 : pub struct PutTimelineImportStatusRequest {
70 : pub tenant_shard_id: TenantShardId,
71 : pub timeline_id: TimelineId,
72 : pub status: ShardImportStatus,
73 : pub generation: Generation,
74 : }
|