diff --git a/tembo-operator/Cargo.lock b/tembo-operator/Cargo.lock index 87b97ec1c..f74c5fbee 100644 --- a/tembo-operator/Cargo.lock +++ b/tembo-operator/Cargo.lock @@ -95,16 +95,16 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b02303ce8d4e8be5b855af6cf3c3a08f3eff26880faad82bab679c22d3650cb5" +checksum = "7ca2549781d8dd6d75c40cf6b6051260a2cc2f3c62343d761a969a0640646894" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", "futures-util", - "mio 0.8.11", + "mio", "socket2", "tokio", "tracing", @@ -209,7 +209,7 @@ dependencies = [ "getrandom", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -457,9 +457,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "bytestring" @@ -472,9 +472,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" dependencies = [ "jobserver", "libc", @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "controller" -version = "0.49.6" +version = "0.50.0" dependencies = [ "actix-web", "anyhow", @@ -792,9 +792,9 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -1573,18 +1573,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.0.1" @@ -1593,6 +1581,7 @@ checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ "hermit-abi", "libc", + "log", "wasi", "windows-sys 0.52.0", ] @@ -1641,9 +1630,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "memchr", ] @@ -1891,11 +1880,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy 0.6.6", + "zerocopy", ] [[package]] @@ -2079,9 +2068,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2349,9 +2338,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "indexmap 2.3.0", "itoa", @@ -2518,14 +2507,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2613,7 +2603,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.1", + "mio", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -3193,6 +3183,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -3324,34 +3323,14 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "zerocopy" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" -dependencies = [ - "byteorder", - "zerocopy-derive 0.6.6", -] - [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", + "byteorder", + "zerocopy-derive", ] [[package]] @@ -3382,18 +3361,18 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "7.2.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa556e971e7b568dc775c136fc9de8c779b1c2fc3a63defaafadffdbd3181afa" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/tembo-operator/Cargo.toml b/tembo-operator/Cargo.toml index 8686f35b3..367a22518 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.49.6" +version = "0.50.0" edition = "2021" default-run = "controller" license = "Apache-2.0" diff --git a/tembo-operator/src/cloudnativepg/cnpg.rs b/tembo-operator/src/cloudnativepg/cnpg.rs index e5012abc9..7e7b99a0e 100644 --- a/tembo-operator/src/cloudnativepg/cnpg.rs +++ b/tembo-operator/src/cloudnativepg/cnpg.rs @@ -26,8 +26,9 @@ use crate::{ ClusterBackupVolumeSnapshotOnlineConfiguration, ClusterBackupVolumeSnapshotSnapshotOwnerReference, ClusterBootstrap, ClusterBootstrapInitdb, ClusterBootstrapRecovery, - ClusterBootstrapRecoveryRecoveryTarget, ClusterCertificates, ClusterExternalClusters, - ClusterExternalClustersBarmanObjectStore, + ClusterBootstrapRecoveryRecoveryTarget, ClusterBootstrapRecoveryVolumeSnapshots, + ClusterBootstrapRecoveryVolumeSnapshotsStorage, ClusterCertificates, + ClusterExternalClusters, ClusterExternalClustersBarmanObjectStore, ClusterExternalClustersBarmanObjectStoreS3Credentials, ClusterExternalClustersBarmanObjectStoreS3CredentialsAccessKeyId, ClusterExternalClustersBarmanObjectStoreS3CredentialsRegion, @@ -45,6 +46,7 @@ use crate::{ ClusterServiceAccountTemplate, ClusterServiceAccountTemplateMetadata, ClusterSpec, ClusterStorage, ClusterSuperuserSecret, }, + cnpg_backups::create_backup_if_needed, cnpg_utils::{ get_pooler_instances, is_image_updated, patch_cluster, restart_and_wait_for_restart, }, @@ -64,6 +66,7 @@ use crate::{ is_postgres_ready, postgres_exporter::EXPORTER_CONFIGMAP_PREFIX, psql::PsqlOutput, + snapshots::volumesnapshots::reconcile_volume_snapshot_restore, trunk::extensions_that_require_load, Context, }; @@ -496,7 +499,7 @@ fn cnpg_cluster_bootstrap(cdb: &CoreDB, restore: bool) -> ClusterBootstrap { } }), // TODO: reenable this once we have a work around for snapshots - // volume_snapshots: cnpg_cluster_bootstrap_recovery_volume_snapshots(cdb), + volume_snapshots: cnpg_cluster_bootstrap_recovery_volume_snapshots(cdb), ..ClusterBootstrapRecovery::default() }), ..ClusterBootstrap::default() @@ -512,25 +515,25 @@ fn cnpg_cluster_bootstrap(cdb: &CoreDB, restore: bool) -> ClusterBootstrap { } // TODO: reenable this once we have a work around for snapshots -// fn cnpg_cluster_bootstrap_recovery_volume_snapshots( -// _cdb: &CoreDB, -// ) -> Option { -// if let Some(restore) = &cdb.spec.restore { -// if restore.volume_snapshot == Some(true) { -// return Some(ClusterBootstrapRecoveryVolumeSnapshots { -// storage: ClusterBootstrapRecoveryVolumeSnapshotsStorage { -// // todo: Work on getting this from the VolumeSnapshot we created -// // during the restore process -// name: format!("{}-restore-vs", cdb.name_any()), -// kind: "VolumeSnapshot".to_string(), -// api_group: Some("snapshot.storage.k8s.io".to_string()), -// }, -// ..ClusterBootstrapRecoveryVolumeSnapshots::default() -// }); -// } -// } -// None -// } +fn cnpg_cluster_bootstrap_recovery_volume_snapshots( + cdb: &CoreDB, +) -> Option { + if let Some(restore) = &cdb.spec.restore { + if restore.volume_snapshot == Some(true) { + return Some(ClusterBootstrapRecoveryVolumeSnapshots { + storage: ClusterBootstrapRecoveryVolumeSnapshotsStorage { + // todo: Work on getting this from the VolumeSnapshot we created + // during the restore process + name: format!("{}-restore-vs", cdb.name_any()), + kind: "VolumeSnapshot".to_string(), + api_group: Some("snapshot.storage.k8s.io".to_string()), + }, + ..ClusterBootstrapRecoveryVolumeSnapshots::default() + }); + } + } + None +} // Get PGConfig from CoreDB and convert it to a postgres_parameters and shared_preload_libraries fn cnpg_postgres_config( @@ -1003,12 +1006,12 @@ pub async fn reconcile_cnpg(cdb: &CoreDB, ctx: Arc) -> Result<(), Actio // If we are restoring and have volume snapshots enabled, make sure we setup // the VolumeSnapshotContent and VolumeSnapshot so that the Cluster will have // something to restore from. - // if let Some(restore) = &cdb.spec.restore { - // if restore.volume_snapshot == Some(true) { - // debug!("Reconciling VolumeSnapshotContent and VolumeSnapshot for restore"); - // reconcile_volume_snapshot_restore(cdb, ctx.clone()).await?; - // } - // } + if let Some(restore) = &cdb.spec.restore { + if restore.volume_snapshot == Some(true) { + debug!("Reconciling VolumeSnapshotContent and VolumeSnapshot for restore"); + reconcile_volume_snapshot_restore(cdb, ctx.clone()).await?; + } + } debug!("Generating CNPG spec"); let mut cluster = cnpg_cluster_from_cdb(cdb, Some(pods_to_fence), requires_load); @@ -1145,9 +1148,9 @@ pub async fn reconcile_cnpg(cdb: &CoreDB, ctx: Arc) -> Result<(), Actio } // TODO: Add back support for using VolumeSnapshots - // if let Ok(cluster) = maybe_cluster { - // create_backup_if_needed(cdb, &ctx, &cluster).await?; - // } + if let Ok(cluster) = maybe_cluster { + create_backup_if_needed(cdb, &ctx, &cluster).await?; + } // For manual changes conflicting with the operator, we have .force() // diff --git a/tembo-operator/src/cloudnativepg/mod.rs b/tembo-operator/src/cloudnativepg/mod.rs index 263a15b32..8449d59e1 100644 --- a/tembo-operator/src/cloudnativepg/mod.rs +++ b/tembo-operator/src/cloudnativepg/mod.rs @@ -1,8 +1,8 @@ +pub(crate) mod archive; pub mod backups; pub mod clusters; pub(crate) mod cnpg; -// pub(crate) mod cnpg_backups; -pub(crate) mod archive; +pub(crate) mod cnpg_backups; pub mod cnpg_utils; pub mod hibernate; pub(crate) mod placement;