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 : /// Hadron: Optional flag to indicate whether the node is starting with an empty local disk.
26 : /// Will be set to true if the node couldn't find any local tenant data on startup, could be
27 : /// due to the node starting for the first time or due to a local SSD failure/disk wipe event.
28 : /// The flag may be used by the storage controller to update its observed state of the world
29 : /// to make sure that it sends explicit location_config calls to the node following the
30 : /// re-attach request.
31 : pub empty_local_disk: Option<bool>,
32 : }
33 :
34 0 : #[derive(Serialize, Deserialize, Debug)]
35 : pub struct ReAttachResponseTenant {
36 : pub id: TenantShardId,
37 : /// Mandatory if LocationConfigMode is None or set to an Attached* mode
38 : pub r#gen: Option<u32>,
39 : pub mode: LocationConfigMode,
40 : pub stripe_size: ShardStripeSize,
41 : }
42 0 : #[derive(Serialize, Deserialize)]
43 : pub struct ReAttachResponse {
44 : pub tenants: Vec<ReAttachResponseTenant>,
45 : }
46 :
47 0 : #[derive(Serialize, Deserialize)]
48 : pub struct ValidateRequestTenant {
49 : pub id: TenantShardId,
50 : pub r#gen: u32,
51 : }
52 :
53 0 : #[derive(Serialize, Deserialize)]
54 : pub struct ValidateRequest {
55 : pub tenants: Vec<ValidateRequestTenant>,
56 : }
57 :
58 0 : #[derive(Serialize, Deserialize)]
59 : pub struct ValidateResponse {
60 : pub tenants: Vec<ValidateResponseTenant>,
61 : }
62 :
63 0 : #[derive(Serialize, Deserialize)]
64 : pub struct ValidateResponseTenant {
65 : pub id: TenantShardId,
66 : pub valid: bool,
67 : }
68 :
69 0 : #[derive(Serialize, Deserialize)]
70 : pub struct TimelineImportStatusRequest {
71 : pub tenant_shard_id: TenantShardId,
72 : pub timeline_id: TimelineId,
73 : pub generation: Generation,
74 : }
75 :
76 0 : #[derive(Serialize, Deserialize)]
77 : pub struct PutTimelineImportStatusRequest {
78 : pub tenant_shard_id: TenantShardId,
79 : pub timeline_id: TimelineId,
80 : pub status: ShardImportStatus,
81 : pub generation: Generation,
82 : }
|