From e2147456d620d1ae1b5921684e3cff00a5aea17a Mon Sep 17 00:00:00 2001 From: Adam Hendel Date: Mon, 6 May 2024 14:46:42 -0500 Subject: [PATCH 1/3] replace ComputeTemplate with ComputeConstraint --- tembo-operator/Cargo.lock | 25 ++++++++++++++++++++++++- tembo-operator/Cargo.toml | 3 ++- tembo-operator/src/stacks/types.rs | 21 ++++++++++----------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/tembo-operator/Cargo.lock b/tembo-operator/Cargo.lock index 19be54d03..15426fe59 100644 --- a/tembo-operator/Cargo.lock +++ b/tembo-operator/Cargo.lock @@ -494,7 +494,7 @@ dependencies = [ [[package]] name = "controller" -version = "0.45.1" +version = "0.46.0" dependencies = [ "actix-web", "anyhow", @@ -521,6 +521,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", + "strum", "thiserror", "tokio", "tonic", @@ -2420,6 +2421,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.55", +] + [[package]] name = "syn" version = "1.0.109" diff --git a/tembo-operator/Cargo.toml b/tembo-operator/Cargo.toml index ec27a4caa..89a481bf0 100644 --- a/tembo-operator/Cargo.toml +++ b/tembo-operator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "controller" description = "Tembo Operator for Postgres" -version = "0.45.1" +version = "0.46.0" edition = "2021" default-run = "controller" license = "Apache-2.0" @@ -53,6 +53,7 @@ anyhow = "1.0.72" rand = "0.8.5" reqwest = { version = "0.11.20", features = ["json", "trust-dns"] } utoipa = "3.5.0" +strum = { version = "0.26.2", features = ["derive"] } [dev-dependencies] assert-json-diff = "2.0.2" diff --git a/tembo-operator/src/stacks/types.rs b/tembo-operator/src/stacks/types.rs index e89ba3201..b61e35a46 100644 --- a/tembo-operator/src/stacks/types.rs +++ b/tembo-operator/src/stacks/types.rs @@ -15,7 +15,7 @@ use utoipa::ToSchema; #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, ToSchema)] pub struct Stack { pub name: String, - pub compute_templates: Option>, + pub compute_constraints: Option, pub description: Option, /// Organization hosting the Docker images used in this stack /// Default: "tembo" @@ -94,20 +94,19 @@ fn default_storage() -> String { } #[derive(Clone, Debug, Serialize, Deserialize, ToSchema, JsonSchema, PartialEq)] -pub struct ComputeTemplate { - pub cpu: String, - pub memory: String, - pub instance_class: InstanceClass, +pub struct ComputeConstraint { + pub min: Option, + pub max: Option, } -#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, ToSchema)] -pub enum InstanceClass { - #[default] - GeneralPurpose, - MemoryOptimized, - ComputeOptimized, + +#[derive(Clone, Debug, Serialize, Deserialize, ToSchema, JsonSchema, PartialEq)] +pub struct ComputeResource { + pub cpu: Option, + pub memory: Option, } + #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, ToSchema)] pub struct ImagePerPgVersion { #[serde(rename = "14")] From 50e20cae7d23d5e60f818fc9aefb6adc74caa1d8 Mon Sep 17 00:00:00 2001 From: Adam Hendel Date: Mon, 6 May 2024 14:47:51 -0500 Subject: [PATCH 2/3] fmt --- tembo-operator/src/stacks/types.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tembo-operator/src/stacks/types.rs b/tembo-operator/src/stacks/types.rs index b61e35a46..3796d958f 100644 --- a/tembo-operator/src/stacks/types.rs +++ b/tembo-operator/src/stacks/types.rs @@ -99,14 +99,12 @@ pub struct ComputeConstraint { pub max: Option, } - #[derive(Clone, Debug, Serialize, Deserialize, ToSchema, JsonSchema, PartialEq)] pub struct ComputeResource { pub cpu: Option, pub memory: Option, } - #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, ToSchema)] pub struct ImagePerPgVersion { #[serde(rename = "14")] From 16d4e7c123ad618b59838b91472685216beb2242 Mon Sep 17 00:00:00 2001 From: Adam Hendel Date: Mon, 6 May 2024 15:53:45 -0500 Subject: [PATCH 3/3] remove max constraint and add comment --- tembo-operator/src/stacks/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tembo-operator/src/stacks/types.rs b/tembo-operator/src/stacks/types.rs index 3796d958f..2c953bfc0 100644 --- a/tembo-operator/src/stacks/types.rs +++ b/tembo-operator/src/stacks/types.rs @@ -15,6 +15,7 @@ use utoipa::ToSchema; #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, ToSchema)] pub struct Stack { pub name: String, + /// specifies any resource constraints that should be applied to an instance of the Stack pub compute_constraints: Option, pub description: Option, /// Organization hosting the Docker images used in this stack @@ -96,7 +97,6 @@ fn default_storage() -> String { #[derive(Clone, Debug, Serialize, Deserialize, ToSchema, JsonSchema, PartialEq)] pub struct ComputeConstraint { pub min: Option, - pub max: Option, } #[derive(Clone, Debug, Serialize, Deserialize, ToSchema, JsonSchema, PartialEq)]