diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c779094d..41473c67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: '0' CARGO_PROFILE_DEV_DEBUG: '0' - RUST_TOOLCHAIN_VERSION: "1.79.0" + RUST_TOOLCHAIN_VERSION: "1.80.0" RUSTFLAGS: "-D warnings" RUSTDOCFLAGS: "-D warnings" RUST_LOG: "info" diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d076224..211d43ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Changed + +- Replace `lazy_static` with `std::cell::LazyCell` ([#604]). + +[#604]: https://github.com/stackabletech/druid-operator/pull/604 + ## [24.7.0] - 2024-07-24 ### Added @@ -94,7 +100,7 @@ All notable changes to this project will be documented in this file. ### Changed -- Operator-rs: `0.42.2` -> `0.44.0` ([#452]). +- Operator-rs: `0.42.2` -> `0.44.0` ([#434], [#452]). - Use 0.0.0-dev product images for tests and examples ([#435]) - Use testing-tools 0.2.0 ([#435]) - Tls tests now run on OpenShift ([#445]) diff --git a/Cargo.lock b/Cargo.lock index d92f89e3..88bf7125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2138,7 +2138,6 @@ name = "stackable-druid-crd" version = "0.0.0-dev" dependencies = [ "indoc", - "lazy_static", "product-config", "rstest", "semver", @@ -2162,7 +2161,6 @@ dependencies = [ "fnv", "futures 0.3.30", "indoc", - "lazy_static", "openssl", "pin-project", "product-config", diff --git a/Cargo.nix b/Cargo.nix index 54f5151d..297dc5b0 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -6589,10 +6589,6 @@ rec { name = "indoc"; packageId = "indoc"; } - { - name = "lazy_static"; - packageId = "lazy_static"; - } { name = "product-config"; packageId = "product-config"; @@ -6686,10 +6682,6 @@ rec { name = "indoc"; packageId = "indoc"; } - { - name = "lazy_static"; - packageId = "lazy_static"; - } { name = "openssl"; packageId = "openssl"; diff --git a/Cargo.toml b/Cargo.toml index 3f63a1e6..8a83ae37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ clap = "4.5" fnv = "1.0" futures = { version = "0.3", features = ["compat"] } indoc = "2.0" -lazy_static = "1.5" openssl = "0.10" product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" } pin-project = "1.1" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index eb024560..c0731f2e 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ # DO NOT EDIT, this file is generated by operator-templating [toolchain] -channel = "1.79.0" +channel = "1.80.0" diff --git a/rust/crd/Cargo.toml b/rust/crd/Cargo.toml index 2923cba0..2e2aa3aa 100644 --- a/rust/crd/Cargo.toml +++ b/rust/crd/Cargo.toml @@ -18,7 +18,6 @@ stackable-operator.workspace = true strum.workspace = true tracing.workspace = true snafu.workspace = true -lazy_static.workspace = true [dev-dependencies] rstest.workspace = true diff --git a/rust/crd/src/memory.rs b/rust/crd/src/memory.rs index b2568972..b4fb005c 100644 --- a/rust/crd/src/memory.rs +++ b/rust/crd/src/memory.rs @@ -1,11 +1,11 @@ -use lazy_static::lazy_static; +use std::{collections::BTreeMap, sync::LazyLock}; + use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ commons::resources::{NoRuntimeLimits, Resources}, cpu::CpuQuantity, memory::{BinaryMultiple, MemoryQuantity}, }; -use std::collections::BTreeMap; use crate::{ storage::HistoricalStorage, PROCESSING_BUFFER_SIZE_BYTES, PROCESSING_NUM_MERGE_BUFFERS, @@ -13,12 +13,14 @@ use crate::{ }; static MIN_HEAP_RATIO: f32 = 0.75; -lazy_static! { - pub static ref RESERVED_OS_MEMORY: MemoryQuantity = MemoryQuantity::from_mebi(300.); - /// Max size for direct access buffers. This is defined in Druid to be 2GB: - /// https://druid.apache.org/docs/latest/configuration/index.html#processing-1 - static ref MAX_DIRECT_BUFFER_SIZE: MemoryQuantity = MemoryQuantity::from_gibi(2.); -} + +pub static RESERVED_OS_MEMORY: LazyLock = + LazyLock::new(|| MemoryQuantity::from_mebi(300.)); + +/// Max size for direct access buffers. This is defined in Druid to be 2GB: +/// +pub static MAX_DIRECT_BUFFER_SIZE: LazyLock = + LazyLock::new(|| MemoryQuantity::from_gibi(2.)); #[derive(Snafu, Debug)] pub enum Error { @@ -41,7 +43,7 @@ pub enum Error { /// [Druid Configuration Reference](https://druid.apache.org/docs/latest/configuration/index.html) /// for additional information. /// Also have a look at the documentation for -/// [Basic Cluster Tuning](). +/// [Basic Cluster Tuning](https://druid.apache.org/docs/latest/operations/basic-cluster-tuning.html). pub struct HistoricalDerivedSettings { total_memory: MemoryQuantity, cpu_millis: CpuQuantity, diff --git a/rust/crd/src/resource.rs b/rust/crd/src/resource.rs index 60cd8b4a..70826aa7 100644 --- a/rust/crd/src/resource.rs +++ b/rust/crd/src/resource.rs @@ -1,9 +1,9 @@ use std::collections::BTreeMap; +use std::sync::LazyLock; use crate::memory::{HistoricalDerivedSettings, RESERVED_OS_MEMORY}; use crate::storage::{self, default_free_percentage_empty_dir_fragment}; use crate::{DruidRole, PATH_SEGMENT_CACHE, PROP_SEGMENT_CACHE_LOCATIONS}; -use lazy_static::lazy_static; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::memory::MemoryQuantity; use stackable_operator::{ @@ -150,70 +150,75 @@ impl RoleResource { } } -lazy_static! { - pub static ref MIDDLE_MANAGER_RESOURCES: ResourcesFragment = - ResourcesFragment { - cpu: CpuLimitsFragment { - min: Some(Quantity("300m".to_owned())), - max: Some(Quantity("1200m".to_owned())), - }, - memory: MemoryLimitsFragment { - limit: Some(Quantity("1Gi".to_owned())), - runtime_limits: NoRuntimeLimitsFragment {}, - }, - storage: storage::DruidStorageFragment {}, - }; - pub static ref BROKER_RESOURCES: ResourcesFragment = - ResourcesFragment { - cpu: CpuLimitsFragment { - min: Some(Quantity("300m".to_owned())), - max: Some(Quantity("1200m".to_owned())), - }, - memory: MemoryLimitsFragment { - limit: Some(Quantity("1500Mi".to_owned())), - runtime_limits: NoRuntimeLimitsFragment {}, - }, - storage: storage::DruidStorageFragment {}, - }; - pub static ref HISTORICAL_RESOURCES: ResourcesFragment = - ResourcesFragment { - cpu: CpuLimitsFragment { - min: Some(Quantity("300m".to_owned())), - max: Some(Quantity("1200m".to_owned())), - }, - memory: MemoryLimitsFragment { - limit: Some(Quantity("1500Mi".to_owned())), - runtime_limits: NoRuntimeLimitsFragment {}, - }, - storage: storage::HistoricalStorageFragment { - segment_cache: default_free_percentage_empty_dir_fragment(), - }, - }; - pub static ref COORDINATOR_RESOURCES: ResourcesFragment = - ResourcesFragment { - cpu: CpuLimitsFragment { - min: Some(Quantity("100m".to_owned())), - max: Some(Quantity("400m".to_owned())), - }, - memory: MemoryLimitsFragment { - limit: Some(Quantity("512Mi".to_owned())), - runtime_limits: NoRuntimeLimitsFragment {}, - }, - storage: storage::DruidStorageFragment {}, - }; - pub static ref ROUTER_RESOURCES: ResourcesFragment = - ResourcesFragment { - cpu: CpuLimitsFragment { - min: Some(Quantity("100m".to_owned())), - max: Some(Quantity("400m".to_owned())), - }, - memory: MemoryLimitsFragment { - limit: Some(Quantity("512Mi".to_owned())), - runtime_limits: NoRuntimeLimitsFragment {}, - }, - storage: storage::DruidStorageFragment {}, - }; -} +pub static MIDDLE_MANAGER_RESOURCES: LazyLock< + ResourcesFragment, +> = LazyLock::new(|| ResourcesFragment { + cpu: CpuLimitsFragment { + min: Some(Quantity("300m".to_owned())), + max: Some(Quantity("1200m".to_owned())), + }, + memory: MemoryLimitsFragment { + limit: Some(Quantity("1Gi".to_owned())), + runtime_limits: NoRuntimeLimitsFragment {}, + }, + storage: storage::DruidStorageFragment {}, +}); + +pub static BROKER_RESOURCES: LazyLock> = + LazyLock::new(|| ResourcesFragment { + cpu: CpuLimitsFragment { + min: Some(Quantity("300m".to_owned())), + max: Some(Quantity("1200m".to_owned())), + }, + memory: MemoryLimitsFragment { + limit: Some(Quantity("1500Mi".to_owned())), + runtime_limits: NoRuntimeLimitsFragment {}, + }, + storage: storage::DruidStorageFragment {}, + }); + +pub static HISTORICAL_RESOURCES: LazyLock< + ResourcesFragment, +> = LazyLock::new(|| ResourcesFragment { + cpu: CpuLimitsFragment { + min: Some(Quantity("300m".to_owned())), + max: Some(Quantity("1200m".to_owned())), + }, + memory: MemoryLimitsFragment { + limit: Some(Quantity("1500Mi".to_owned())), + runtime_limits: NoRuntimeLimitsFragment {}, + }, + storage: storage::HistoricalStorageFragment { + segment_cache: default_free_percentage_empty_dir_fragment(), + }, +}); + +pub static COORDINATOR_RESOURCES: LazyLock< + ResourcesFragment, +> = LazyLock::new(|| ResourcesFragment { + cpu: CpuLimitsFragment { + min: Some(Quantity("100m".to_owned())), + max: Some(Quantity("400m".to_owned())), + }, + memory: MemoryLimitsFragment { + limit: Some(Quantity("512Mi".to_owned())), + runtime_limits: NoRuntimeLimitsFragment {}, + }, + storage: storage::DruidStorageFragment {}, +}); + +pub static ROUTER_RESOURCES: LazyLock> = + LazyLock::new(|| ResourcesFragment { + cpu: CpuLimitsFragment { + min: Some(Quantity("100m".to_owned())), + max: Some(Quantity("400m".to_owned())), + }, + memory: MemoryLimitsFragment { + limit: Some(Quantity("512Mi".to_owned())), + runtime_limits: NoRuntimeLimitsFragment {}, + }, + storage: storage::DruidStorageFragment {}, + }); #[cfg(test)] mod test { diff --git a/rust/crd/src/security.rs b/rust/crd/src/security.rs index 07360dec..1a25e077 100644 --- a/rust/crd/src/security.rs +++ b/rust/crd/src/security.rs @@ -119,10 +119,12 @@ impl DruidTlsSecurity { } /// Check if TLS encryption is enabled. This could be due to: + /// /// - A provided server `SecretClass` /// - A provided client `AuthenticationClass` using tls - /// This affects init container commands, Druid configuration, volume mounts and - /// the Druid client port + /// + /// This affects init container commands, Druid configuration, volume mounts + /// and the Druid client port pub fn tls_enabled(&self) -> bool { // TODO: This must be adapted if other authentication methods are supported and require TLS self.auth_classes.tls_authentication_enabled() diff --git a/rust/operator-binary/Cargo.toml b/rust/operator-binary/Cargo.toml index da1751c1..c24b1d2e 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -27,7 +27,6 @@ product-config.workspace = true strum.workspace = true tokio.workspace = true tracing.workspace = true -lazy_static.workspace = true [build-dependencies] built.workspace = true diff --git a/rust/operator-binary/src/druid_controller.rs b/rust/operator-binary/src/druid_controller.rs index d7589b91..ecf4e4d6 100644 --- a/rust/operator-binary/src/druid_controller.rs +++ b/rust/operator-binary/src/druid_controller.rs @@ -851,7 +851,7 @@ fn build_rolegroup_services( Ok(Service { metadata: ObjectMetaBuilder::new() .name_and_namespace(druid) - .name(&rolegroup.object_name()) + .name(rolegroup.object_name()) .ownerreference_from_resource(druid, None, Some(true)) .context(ObjectMissingMetadataForOwnerRefSnafu)? .with_recommended_labels(build_recommended_labels( @@ -1129,7 +1129,7 @@ fn build_rolegroup_statefulset( Ok(StatefulSet { metadata: ObjectMetaBuilder::new() .name_and_namespace(druid) - .name(&rolegroup_ref.object_name()) + .name(rolegroup_ref.object_name()) .ownerreference_from_resource(druid, None, Some(true)) .context(ObjectMissingMetadataForOwnerRefSnafu)? .with_recommended_labels(build_recommended_labels(