Skip to content

Commit a9f1806

Browse files
refactor: Replace lazy_static with std::sync::LazyLock (b04cbc1) (#604)
* Generated commit to update templated files based on rev b04cbc1 in stackabletech/operator-templating repo. Triggered by: Manual run triggered by: Techassi with message [Update Rust toolchain to 1.80.0, part of stackabletech/operator-templating#415] * refactor: Replace lazy_static with std::sync::LazyLock * style: Fix clippy errors * style: Fix rustdoc error * chore: Update Cargo.nix * chore: Update changelog --------- Co-authored-by: Techassi <sascha.lautenschlaeger@stackable.tech>
1 parent 561082d commit a9f1806

File tree

12 files changed

+96
-94
lines changed

12 files changed

+96
-94
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
CARGO_TERM_COLOR: always
2626
CARGO_INCREMENTAL: '0'
2727
CARGO_PROFILE_DEV_DEBUG: '0'
28-
RUST_TOOLCHAIN_VERSION: "1.79.0"
28+
RUST_TOOLCHAIN_VERSION: "1.80.0"
2929
RUSTFLAGS: "-D warnings"
3030
RUSTDOCFLAGS: "-D warnings"
3131
RUST_LOG: "info"

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Replace `lazy_static` with `std::cell::LazyCell` ([#604]).
10+
11+
[#604]: https://github.com/stackabletech/druid-operator/pull/604
12+
713
## [24.7.0] - 2024-07-24
814

915
### Added
@@ -94,7 +100,7 @@ All notable changes to this project will be documented in this file.
94100

95101
### Changed
96102

97-
- Operator-rs: `0.42.2` -> `0.44.0` ([#452]).
103+
- Operator-rs: `0.42.2` -> `0.44.0` ([#434], [#452]).
98104
- Use 0.0.0-dev product images for tests and examples ([#435])
99105
- Use testing-tools 0.2.0 ([#435])
100106
- Tls tests now run on OpenShift ([#445])

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ clap = "4.5"
1616
fnv = "1.0"
1717
futures = { version = "0.3", features = ["compat"] }
1818
indoc = "2.0"
19-
lazy_static = "1.5"
2019
openssl = "0.10"
2120
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2221
pin-project = "1.1"

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# DO NOT EDIT, this file is generated by operator-templating
22
[toolchain]
3-
channel = "1.79.0"
3+
channel = "1.80.0"

rust/crd/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ stackable-operator.workspace = true
1818
strum.workspace = true
1919
tracing.workspace = true
2020
snafu.workspace = true
21-
lazy_static.workspace = true
2221

2322
[dev-dependencies]
2423
rstest.workspace = true

rust/crd/src/memory.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
use lazy_static::lazy_static;
1+
use std::{collections::BTreeMap, sync::LazyLock};
2+
23
use snafu::{OptionExt, ResultExt, Snafu};
34
use stackable_operator::{
45
commons::resources::{NoRuntimeLimits, Resources},
56
cpu::CpuQuantity,
67
memory::{BinaryMultiple, MemoryQuantity},
78
};
8-
use std::collections::BTreeMap;
99

1010
use crate::{
1111
storage::HistoricalStorage, PROCESSING_BUFFER_SIZE_BYTES, PROCESSING_NUM_MERGE_BUFFERS,
1212
PROCESSING_NUM_THREADS,
1313
};
1414

1515
static MIN_HEAP_RATIO: f32 = 0.75;
16-
lazy_static! {
17-
pub static ref RESERVED_OS_MEMORY: MemoryQuantity = MemoryQuantity::from_mebi(300.);
18-
/// Max size for direct access buffers. This is defined in Druid to be 2GB:
19-
/// https://druid.apache.org/docs/latest/configuration/index.html#processing-1
20-
static ref MAX_DIRECT_BUFFER_SIZE: MemoryQuantity = MemoryQuantity::from_gibi(2.);
21-
}
16+
17+
pub static RESERVED_OS_MEMORY: LazyLock<MemoryQuantity> =
18+
LazyLock::new(|| MemoryQuantity::from_mebi(300.));
19+
20+
/// Max size for direct access buffers. This is defined in Druid to be 2GB:
21+
/// <https://druid.apache.org/docs/latest/configuration/index.html#processing-1>
22+
pub static MAX_DIRECT_BUFFER_SIZE: LazyLock<MemoryQuantity> =
23+
LazyLock::new(|| MemoryQuantity::from_gibi(2.));
2224

2325
#[derive(Snafu, Debug)]
2426
pub enum Error {
@@ -41,7 +43,7 @@ pub enum Error {
4143
/// [Druid Configuration Reference](https://druid.apache.org/docs/latest/configuration/index.html)
4244
/// for additional information.
4345
/// Also have a look at the documentation for
44-
/// [Basic Cluster Tuning](<https://druid.apache.org/docs/latest/operations/basic-cluster-tuning.html>).
46+
/// [Basic Cluster Tuning](https://druid.apache.org/docs/latest/operations/basic-cluster-tuning.html).
4547
pub struct HistoricalDerivedSettings {
4648
total_memory: MemoryQuantity,
4749
cpu_millis: CpuQuantity,

rust/crd/src/resource.rs

Lines changed: 70 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::collections::BTreeMap;
2+
use std::sync::LazyLock;
23

34
use crate::memory::{HistoricalDerivedSettings, RESERVED_OS_MEMORY};
45
use crate::storage::{self, default_free_percentage_empty_dir_fragment};
56
use crate::{DruidRole, PATH_SEGMENT_CACHE, PROP_SEGMENT_CACHE_LOCATIONS};
6-
use lazy_static::lazy_static;
77
use snafu::{OptionExt, ResultExt, Snafu};
88
use stackable_operator::memory::MemoryQuantity;
99
use stackable_operator::{
@@ -150,70 +150,75 @@ impl RoleResource {
150150
}
151151
}
152152

153-
lazy_static! {
154-
pub static ref MIDDLE_MANAGER_RESOURCES: ResourcesFragment<storage::DruidStorage, NoRuntimeLimits> =
155-
ResourcesFragment {
156-
cpu: CpuLimitsFragment {
157-
min: Some(Quantity("300m".to_owned())),
158-
max: Some(Quantity("1200m".to_owned())),
159-
},
160-
memory: MemoryLimitsFragment {
161-
limit: Some(Quantity("1Gi".to_owned())),
162-
runtime_limits: NoRuntimeLimitsFragment {},
163-
},
164-
storage: storage::DruidStorageFragment {},
165-
};
166-
pub static ref BROKER_RESOURCES: ResourcesFragment<storage::DruidStorage, NoRuntimeLimits> =
167-
ResourcesFragment {
168-
cpu: CpuLimitsFragment {
169-
min: Some(Quantity("300m".to_owned())),
170-
max: Some(Quantity("1200m".to_owned())),
171-
},
172-
memory: MemoryLimitsFragment {
173-
limit: Some(Quantity("1500Mi".to_owned())),
174-
runtime_limits: NoRuntimeLimitsFragment {},
175-
},
176-
storage: storage::DruidStorageFragment {},
177-
};
178-
pub static ref HISTORICAL_RESOURCES: ResourcesFragment<storage::HistoricalStorage, NoRuntimeLimits> =
179-
ResourcesFragment {
180-
cpu: CpuLimitsFragment {
181-
min: Some(Quantity("300m".to_owned())),
182-
max: Some(Quantity("1200m".to_owned())),
183-
},
184-
memory: MemoryLimitsFragment {
185-
limit: Some(Quantity("1500Mi".to_owned())),
186-
runtime_limits: NoRuntimeLimitsFragment {},
187-
},
188-
storage: storage::HistoricalStorageFragment {
189-
segment_cache: default_free_percentage_empty_dir_fragment(),
190-
},
191-
};
192-
pub static ref COORDINATOR_RESOURCES: ResourcesFragment<storage::DruidStorage, NoRuntimeLimits> =
193-
ResourcesFragment {
194-
cpu: CpuLimitsFragment {
195-
min: Some(Quantity("100m".to_owned())),
196-
max: Some(Quantity("400m".to_owned())),
197-
},
198-
memory: MemoryLimitsFragment {
199-
limit: Some(Quantity("512Mi".to_owned())),
200-
runtime_limits: NoRuntimeLimitsFragment {},
201-
},
202-
storage: storage::DruidStorageFragment {},
203-
};
204-
pub static ref ROUTER_RESOURCES: ResourcesFragment<storage::DruidStorage, NoRuntimeLimits> =
205-
ResourcesFragment {
206-
cpu: CpuLimitsFragment {
207-
min: Some(Quantity("100m".to_owned())),
208-
max: Some(Quantity("400m".to_owned())),
209-
},
210-
memory: MemoryLimitsFragment {
211-
limit: Some(Quantity("512Mi".to_owned())),
212-
runtime_limits: NoRuntimeLimitsFragment {},
213-
},
214-
storage: storage::DruidStorageFragment {},
215-
};
216-
}
153+
pub static MIDDLE_MANAGER_RESOURCES: LazyLock<
154+
ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>,
155+
> = LazyLock::new(|| ResourcesFragment {
156+
cpu: CpuLimitsFragment {
157+
min: Some(Quantity("300m".to_owned())),
158+
max: Some(Quantity("1200m".to_owned())),
159+
},
160+
memory: MemoryLimitsFragment {
161+
limit: Some(Quantity("1Gi".to_owned())),
162+
runtime_limits: NoRuntimeLimitsFragment {},
163+
},
164+
storage: storage::DruidStorageFragment {},
165+
});
166+
167+
pub static BROKER_RESOURCES: LazyLock<ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>> =
168+
LazyLock::new(|| ResourcesFragment {
169+
cpu: CpuLimitsFragment {
170+
min: Some(Quantity("300m".to_owned())),
171+
max: Some(Quantity("1200m".to_owned())),
172+
},
173+
memory: MemoryLimitsFragment {
174+
limit: Some(Quantity("1500Mi".to_owned())),
175+
runtime_limits: NoRuntimeLimitsFragment {},
176+
},
177+
storage: storage::DruidStorageFragment {},
178+
});
179+
180+
pub static HISTORICAL_RESOURCES: LazyLock<
181+
ResourcesFragment<storage::HistoricalStorage, NoRuntimeLimits>,
182+
> = LazyLock::new(|| ResourcesFragment {
183+
cpu: CpuLimitsFragment {
184+
min: Some(Quantity("300m".to_owned())),
185+
max: Some(Quantity("1200m".to_owned())),
186+
},
187+
memory: MemoryLimitsFragment {
188+
limit: Some(Quantity("1500Mi".to_owned())),
189+
runtime_limits: NoRuntimeLimitsFragment {},
190+
},
191+
storage: storage::HistoricalStorageFragment {
192+
segment_cache: default_free_percentage_empty_dir_fragment(),
193+
},
194+
});
195+
196+
pub static COORDINATOR_RESOURCES: LazyLock<
197+
ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>,
198+
> = LazyLock::new(|| ResourcesFragment {
199+
cpu: CpuLimitsFragment {
200+
min: Some(Quantity("100m".to_owned())),
201+
max: Some(Quantity("400m".to_owned())),
202+
},
203+
memory: MemoryLimitsFragment {
204+
limit: Some(Quantity("512Mi".to_owned())),
205+
runtime_limits: NoRuntimeLimitsFragment {},
206+
},
207+
storage: storage::DruidStorageFragment {},
208+
});
209+
210+
pub static ROUTER_RESOURCES: LazyLock<ResourcesFragment<storage::DruidStorage, NoRuntimeLimits>> =
211+
LazyLock::new(|| ResourcesFragment {
212+
cpu: CpuLimitsFragment {
213+
min: Some(Quantity("100m".to_owned())),
214+
max: Some(Quantity("400m".to_owned())),
215+
},
216+
memory: MemoryLimitsFragment {
217+
limit: Some(Quantity("512Mi".to_owned())),
218+
runtime_limits: NoRuntimeLimitsFragment {},
219+
},
220+
storage: storage::DruidStorageFragment {},
221+
});
217222

218223
#[cfg(test)]
219224
mod test {

rust/crd/src/security.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ impl DruidTlsSecurity {
119119
}
120120

121121
/// Check if TLS encryption is enabled. This could be due to:
122+
///
122123
/// - A provided server `SecretClass`
123124
/// - A provided client `AuthenticationClass` using tls
124-
/// This affects init container commands, Druid configuration, volume mounts and
125-
/// the Druid client port
125+
///
126+
/// This affects init container commands, Druid configuration, volume mounts
127+
/// and the Druid client port
126128
pub fn tls_enabled(&self) -> bool {
127129
// TODO: This must be adapted if other authentication methods are supported and require TLS
128130
self.auth_classes.tls_authentication_enabled()

rust/operator-binary/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ product-config.workspace = true
2727
strum.workspace = true
2828
tokio.workspace = true
2929
tracing.workspace = true
30-
lazy_static.workspace = true
3130

3231
[build-dependencies]
3332
built.workspace = true

rust/operator-binary/src/druid_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ fn build_rolegroup_services(
851851
Ok(Service {
852852
metadata: ObjectMetaBuilder::new()
853853
.name_and_namespace(druid)
854-
.name(&rolegroup.object_name())
854+
.name(rolegroup.object_name())
855855
.ownerreference_from_resource(druid, None, Some(true))
856856
.context(ObjectMissingMetadataForOwnerRefSnafu)?
857857
.with_recommended_labels(build_recommended_labels(
@@ -1129,7 +1129,7 @@ fn build_rolegroup_statefulset(
11291129
Ok(StatefulSet {
11301130
metadata: ObjectMetaBuilder::new()
11311131
.name_and_namespace(druid)
1132-
.name(&rolegroup_ref.object_name())
1132+
.name(rolegroup_ref.object_name())
11331133
.ownerreference_from_resource(druid, None, Some(true))
11341134
.context(ObjectMissingMetadataForOwnerRefSnafu)?
11351135
.with_recommended_labels(build_recommended_labels(

0 commit comments

Comments
 (0)