From e7ec82cc08d5903498448be200fca184720c29a7 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Mon, 10 Feb 2025 11:26:22 -0600 Subject: [PATCH] Move control plane spec response code to proper location Per the comment, this code is indeed not related to the compute_ctl HTTP API. Signed-off-by: Tristan Partin --- compute_tools/src/spec.rs | 20 +++++++++++++++++++- libs/compute_api/src/responses.rs | 22 +--------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/compute_tools/src/spec.rs b/compute_tools/src/spec.rs index 37d5d3a1a6..c0ccf6376a 100644 --- a/compute_tools/src/spec.rs +++ b/compute_tools/src/spec.rs @@ -1,6 +1,7 @@ use anyhow::{anyhow, bail, Result}; use postgres::Client; use reqwest::StatusCode; +use serde::Deserialize; use std::fs::File; use std::path::Path; use tracing::{error, info, instrument, warn}; @@ -11,9 +12,26 @@ use crate::migration::MigrationRunner; use crate::params::PG_HBA_ALL_MD5; use crate::pg_helpers::*; -use compute_api::responses::{ControlPlaneComputeStatus, ControlPlaneSpecResponse}; use compute_api::spec::ComputeSpec; +/// Response of the `/computes/{compute_id}/spec` control-plane API. +#[derive(Deserialize, Debug)] +pub struct ControlPlaneSpecResponse { + pub spec: Option, + pub status: ControlPlaneComputeStatus, +} + +#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum ControlPlaneComputeStatus { + // Compute is known to control-plane, but it's not + // yet attached to any timeline / endpoint. + Empty, + // Compute is attached to some timeline / endpoint and + // should be able to start with provided spec. + Attached, +} + // Do control plane request and return response if any. In case of error it // returns a bool flag indicating whether it makes sense to retry the request // and a string with error message. diff --git a/libs/compute_api/src/responses.rs b/libs/compute_api/src/responses.rs index 5286e0e61d..fe8d3b062d 100644 --- a/libs/compute_api/src/responses.rs +++ b/libs/compute_api/src/responses.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize, Serializer}; use crate::{ privilege::Privilege, - spec::{ComputeSpec, Database, ExtVersion, PgIdent, Role}, + spec::{Database, ExtVersion, PgIdent, Role}, }; #[derive(Serialize, Debug, Deserialize)] @@ -135,26 +135,6 @@ pub struct CatalogObjects { pub databases: Vec, } -/// Response of the `/computes/{compute_id}/spec` control-plane API. -/// This is not actually a compute API response, so consider moving -/// to a different place. -#[derive(Deserialize, Debug)] -pub struct ControlPlaneSpecResponse { - pub spec: Option, - pub status: ControlPlaneComputeStatus, -} - -#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -pub enum ControlPlaneComputeStatus { - // Compute is known to control-plane, but it's not - // yet attached to any timeline / endpoint. - Empty, - // Compute is attached to some timeline / endpoint and - // should be able to start with provided spec. - Attached, -} - #[derive(Clone, Debug, Default, Serialize)] pub struct InstalledExtension { pub extname: String,