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::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 0 : #[derive(Serialize, Deserialize)]
41 : pub struct ReAttachResponse {
42 : pub tenants: Vec<ReAttachResponseTenant>,
43 : }
44 :
45 0 : #[derive(Serialize, Deserialize)]
46 : pub struct ValidateRequestTenant {
47 : pub id: TenantShardId,
48 : pub r#gen: u32,
49 : }
50 :
51 0 : #[derive(Serialize, Deserialize)]
52 : pub struct ValidateRequest {
53 : pub tenants: Vec<ValidateRequestTenant>,
54 : }
55 :
56 0 : #[derive(Serialize, Deserialize)]
57 : pub struct ValidateResponse {
58 : pub tenants: Vec<ValidateResponseTenant>,
59 : }
60 :
61 0 : #[derive(Serialize, Deserialize)]
62 : pub struct ValidateResponseTenant {
63 : pub id: TenantShardId,
64 : pub valid: bool,
65 : }
66 :
67 0 : #[derive(Serialize, Deserialize)]
68 : pub struct TimelineImportStatusRequest {
69 : pub tenant_shard_id: TenantShardId,
70 : pub timeline_id: TimelineId,
71 : pub generation: Generation,
72 : }
73 :
74 0 : #[derive(Serialize, Deserialize)]
75 : pub struct PutTimelineImportStatusRequest {
76 : pub tenant_shard_id: TenantShardId,
77 : pub timeline_id: TimelineId,
78 : pub status: ShardImportStatus,
79 : pub generation: Generation,
80 : }
|