diff --git a/.github/workflows/reconciler-test.yml b/.github/workflows/reconciler-test.yml index 12cd43e77..cccab8584 100644 --- a/.github/workflows/reconciler-test.yml +++ b/.github/workflows/reconciler-test.yml @@ -94,7 +94,7 @@ jobs: helm install --namespace=traefik-v2 --values ./tests/traefik-values.yaml traefik traefik/traefik # Install the CoreDB operator - cargo install --version 2023.2.15 coredb-cli + cargo install --version 2023.3.6 coredb-cli coredb-cli install kubectl get crds diff --git a/reconciler/README.md b/reconciler/README.md index 20dfcac64..2b6cc5cde 100644 --- a/reconciler/README.md +++ b/reconciler/README.md @@ -1,6 +1,5 @@ # Reconciler - The reconciler is responsible for creating, updating, deleting database instances (custom resource) on a kubernetes cluster. It runs in each data plane and performs these actions based on messages written to a queue in the control plane. Upon connecting to this queue, it will continuously poll for new messages posted by the `cp-service` component. diff --git a/reconciler/src/coredb_crd.rs b/reconciler/src/coredb_crd.rs index 778a0fb7e..a877a0a85 100644 --- a/reconciler/src/coredb_crd.rs +++ b/reconciler/src/coredb_crd.rs @@ -1,9 +1,10 @@ // WARNING: generated by kopium - manual changes will be overwritten // kopium command: kopium coredbs.coredb.io -// kopium version: 0.14.0 +// kopium version: 0.15.0 use kube::CustomResource; use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; #[derive(CustomResource, Serialize, Deserialize, Clone, Debug)] #[kube( @@ -16,22 +17,50 @@ use serde::{Deserialize, Serialize}; #[kube(status = "CoreDBStatus")] #[kube(schema = "disabled")] pub struct CoreDBSpec { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub extensions: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub image: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub port: Option, #[serde( default, skip_serializing_if = "Option::is_none", - rename = "enabledExtensions" + rename = "postgresExporterEnabled" )] - pub enabled_extensions: Option>, + pub postgres_exporter_enabled: Option, + #[serde( + default, + skip_serializing_if = "Option::is_none", + rename = "postgresExporterImage" + )] + pub postgres_exporter_image: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - pub image: Option, + pub replicas: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - pub port: Option, + pub resources: Option, #[serde(default, skip_serializing_if = "Option::is_none")] - pub replicas: Option, + pub storage: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub uid: Option, } +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct CoreDBExtensions { + pub enabled: bool, + pub name: String, + pub schema: String, + pub version: String, +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct CoreDBResources { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub limits: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub requests: Option>, +} + #[derive(Serialize, Deserialize, Clone, Debug)] pub struct CoreDBStatus { pub running: bool, diff --git a/reconciler/src/lib.rs b/reconciler/src/lib.rs index 024d3275d..816256d06 100644 --- a/reconciler/src/lib.rs +++ b/reconciler/src/lib.rs @@ -33,7 +33,7 @@ pub async fn generate_spec(event_body: &types::EventBody) -> Value { }, "spec": { "replicas": 1, - "enabledExtensions": event_body.extensions + "extensions": event_body.extensions, }, }); spec diff --git a/reconciler/src/main.rs b/reconciler/src/main.rs index 7129402b2..873ef9096 100644 --- a/reconciler/src/main.rs +++ b/reconciler/src/main.rs @@ -121,10 +121,10 @@ async fn run() -> Result<(), Box> { let msg_id = queue.send(&data_plane_events_queue, &msg).await?; info!("msg_id: {:?}", msg_id); } - None | _ => warn!("action was not in expected format"), + _ => warn!("action was not in expected format"), } - // TODO(ianstanton) This is here as an example for now. We want to use + // TODO (ianstanton) This is here as an example for now. We want to use // this to ensure a PostgresCluster exists before we attempt to delete it. // Get all existing PostgresClusters let vec = get_all(client.clone(), "default".to_owned()); diff --git a/reconciler/src/types.rs b/reconciler/src/types.rs index 85c75c0d5..e85448e35 100644 --- a/reconciler/src/types.rs +++ b/reconciler/src/types.rs @@ -9,6 +9,12 @@ pub struct CRUDevent { pub body: EventBody, } +pub enum UpdateEvent { + ToggleExtension, + UpdateInfra, + InstallExtension, +} + #[derive(Debug, Deserialize, Serialize)] pub struct EventBody { pub resource_type: String, @@ -16,7 +22,7 @@ pub struct EventBody { pub storage: Option, pub memory: Option, pub cpu: Option, - pub extensions: Option>, + pub extensions: Option>, } /// message returned to control plane @@ -39,3 +45,22 @@ pub enum Status { Up, Deleted, } + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +pub struct Extension { + pub name: String, + pub version: String, + pub enabled: bool, + pub schema: String, +} + +impl Default for Extension { + fn default() -> Self { + Extension { + name: "pg_stat_statements".to_owned(), + version: "1.9".to_owned(), + enabled: true, + schema: "postgres".to_owned(), + } + } +} diff --git a/reconciler/tests/integration_tests.rs b/reconciler/tests/integration_tests.rs index 9476adbdb..9c810d8fc 100644 --- a/reconciler/tests/integration_tests.rs +++ b/reconciler/tests/integration_tests.rs @@ -45,7 +45,7 @@ mod test { "storage": "1Gi", "resource_name": name, "resource_type": "CoreDB", - "enabled_extensions": ["postgis"], + "extensions": [{"name": "postgis", "enabled": true, "version": "1.1.1", "schema": "public"}], }, "data_plane_id": "org_02s3owPQskuGXHE8vYsGSY", "event_id": "coredb-poc1.org_02s3owPQskuGXHE8vYsGSY.CoreDB.inst_02s4UKVbRy34SAYVSwZq2H",