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 : fn default_mode() -> LocationConfigMode {
27 0 : LocationConfigMode::AttachedSingle
28 0 : }
29 :
30 0 : #[derive(Serialize, Deserialize, Debug)]
31 : pub struct ReAttachResponseTenant {
32 : pub id: TenantShardId,
33 : /// Mandatory if LocationConfigMode is None or set to an Attached* mode
34 : pub r#gen: Option<u32>,
35 :
36 : /// Default value only for backward compat: this field should be set
37 : #[serde(default = "default_mode")]
38 : pub mode: LocationConfigMode,
39 :
40 : // Default value only for backward compat: this field should be set
41 : #[serde(default = "ShardStripeSize::default")]
42 : pub stripe_size: ShardStripeSize,
43 : }
44 0 : #[derive(Serialize, Deserialize)]
45 : pub struct ReAttachResponse {
46 : pub tenants: Vec<ReAttachResponseTenant>,
47 : }
48 :
49 0 : #[derive(Serialize, Deserialize)]
50 : pub struct ValidateRequestTenant {
51 : pub id: TenantShardId,
52 : pub r#gen: u32,
53 : }
54 :
55 0 : #[derive(Serialize, Deserialize)]
56 : pub struct ValidateRequest {
57 : pub tenants: Vec<ValidateRequestTenant>,
58 : }
59 :
60 0 : #[derive(Serialize, Deserialize)]
61 : pub struct ValidateResponse {
62 : pub tenants: Vec<ValidateResponseTenant>,
63 : }
64 :
65 0 : #[derive(Serialize, Deserialize)]
66 : pub struct ValidateResponseTenant {
67 : pub id: TenantShardId,
68 : pub valid: bool,
69 : }
70 :
71 0 : #[derive(Serialize, Deserialize)]
72 : pub struct TimelineImportStatusRequest {
73 : pub tenant_shard_id: TenantShardId,
74 : pub timeline_id: TimelineId,
75 : pub generation: Generation,
76 : }
77 :
78 0 : #[derive(Serialize, Deserialize)]
79 : pub struct PutTimelineImportStatusRequest {
80 : pub tenant_shard_id: TenantShardId,
81 : pub timeline_id: TimelineId,
82 : pub status: ShardImportStatus,
83 : pub generation: Generation,
84 : }
|