Skip to content

Commit 35f8f61

Browse files
authored
chore!: Upgrade to kube 3.0.1 and k8s-openapi 0.27.0 (#1138)
* chore!: Upgrade to kube 3.0.0 and k8s-openapi 0.27.0 * Update to kube 3.0.1 * Bump kube * Improve comment * Allow https://github.com/kube-rs/kube-rs Git repo * revert minor change * Update deny.toml
1 parent eace189 commit 35f8f61

22 files changed

Lines changed: 1400 additions & 544 deletions

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ product-config = { git = "https://github.com/stackabletech/product-config.git",
1414
arc-swap = "1.7.0"
1515
async-trait = "0.1.89"
1616
axum = { version = "0.8.1", features = ["http2"] }
17-
chrono = { version = "0.4.38", default-features = false }
1817
clap = { version = "4.5.17", features = ["derive", "cargo", "env"] }
1918
const_format = "0.2.33"
2019
const-oid = { version = "0.9.6", features = ["db"] }
@@ -30,17 +29,17 @@ futures-util = "0.3.30"
3029
http = "1.3.1"
3130
indexmap = "2.5.0"
3231
indoc = "2.0.6"
32+
jiff = "0.2.18"
3333
insta = { version = "1.40", features = ["glob"] }
3434
hyper = { version = "1.4.1", features = ["full"] }
3535
hyper-util = "0.1.8"
3636
itertools = "0.14.0"
3737
json-patch = "4.0.0"
38-
# k8s-openapi 0.26.1 doesn't play well with our kube version: https://github.com/kube-rs/kube/issues/1869
39-
k8s-openapi = { version = "=0.26.0", default-features = false, features = ["schemars", "v1_34"] }
38+
k8s-openapi = { version = "0.27.0", default-features = false, features = ["schemars", "v1_35"] }
4039
# We use rustls instead of openssl for easier portability, e.g. so that we can build stackablectl without the need to vendor (build from source) openssl
4140
# We use ring instead of aws-lc-rs, as this currently fails to build in "make run-dev"
42-
# We pin the kube version, as we use a patch for 2.0.1
43-
kube = { git = "https://github.com/stackabletech/kube-rs", branch = "2.0.1-fix-schema-hoisting", version = "=2.0.1", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "admission", "rustls-tls", "ring"] }
41+
# We need a few schema fixes in kube, that went into main, but are not released yet
42+
kube = { git = "https://github.com/kube-rs/kube-rs", rev = "fe69cc486ff8e62a7da61d64ec3ebbd9e64c43b5", version = "=3.0.1", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "admission", "rustls-tls", "ring"] }
4443
opentelemetry = "0.31.0"
4544
opentelemetry_sdk = { version = "0.31.0", features = ["rt-tokio"] }
4645
opentelemetry-appender-tracing = "0.31.0"

crates/stackable-operator/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ webhook = ["dep:stackable-webhook"]
2121
[dependencies]
2222
stackable-certs = { path = "../stackable-certs", optional = true }
2323
stackable-operator-derive = { path = "../stackable-operator-derive" }
24-
stackable-shared = { path = "../stackable-shared", features = ["chrono", "time"] }
24+
stackable-shared = { path = "../stackable-shared", features = ["time", "jiff"] }
2525
stackable-telemetry = { path = "../stackable-telemetry", optional = true, features = ["clap"] }
2626
stackable-versioned = { path = "../stackable-versioned", optional = true }
2727
stackable-webhook = { path = "../stackable-webhook", optional = true }
2828

29-
chrono.workspace = true
3029
clap.workspace = true
3130
const_format.workspace = true
3231
delegate.workspace = true
@@ -36,6 +35,7 @@ educe.workspace = true
3635
futures.workspace = true
3736
http.workspace = true
3837
indexmap.workspace = true
38+
jiff.workspace = true
3939
json-patch.workspace = true
4040
k8s-openapi.workspace = true
4141
kube.workspace = true

crates/stackable-operator/crds/AuthenticationClass.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ spec:
246246
intended to be used (via the `.well-known` discovery).
247247
enum:
248248
- Keycloak
249+
- null
249250
nullable: true
250251
type: string
251252
rootPath:

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 784 additions & 136 deletions
Large diffs are not rendered by default.

crates/stackable-operator/src/builder/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use chrono::Utc;
21
use k8s_openapi::{
32
api::core::v1::{Event, EventSource, ObjectReference},
43
apimachinery::pkg::apis::meta::v1::{MicroTime, ObjectMeta, Time},
4+
jiff::Timestamp,
55
};
66
use kube::{Resource, ResourceExt};
77

@@ -91,7 +91,7 @@ impl EventBuilder {
9191
}
9292

9393
pub fn build(&self) -> Event {
94-
let time = Utc::now();
94+
let time = Timestamp::now();
9595

9696
let source = Some(EventSource {
9797
component: self.reporting_component.clone(),

crates/stackable-operator/src/cluster_resources.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use k8s_openapi::{
2222
},
2323
apimachinery::pkg::apis::meta::v1::{LabelSelector, LabelSelectorRequirement},
2424
};
25-
use kube::{Resource, ResourceExt, core::ErrorResponse};
25+
use kube::{Resource, ResourceExt};
2626
use serde::{Serialize, de::DeserializeOwned};
2727
use snafu::{OptionExt, ResultExt, Snafu};
2828
use strum::Display;
@@ -744,8 +744,8 @@ impl<'a> ClusterResources<'a> {
744744
Ok(())
745745
}
746746
Err(crate::client::Error::ListResources {
747-
source: kube::Error::Api(ErrorResponse { code: 403, .. }),
748-
}) => {
747+
source: kube::Error::Api(s),
748+
}) if s.is_forbidden() => {
749749
debug!(
750750
"Skipping deletion of orphaned {} because the operator is not allowed to list \
751751
them and is therefore probably not in charge of them.",

crates/stackable-operator/src/eos/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use chrono::{DateTime, Utc};
21
use futures::FutureExt;
2+
use jiff::{self, Zoned};
33
use snafu::{ResultExt, Snafu};
44
use stackable_shared::time::Duration;
55
use tokio::select;
@@ -65,12 +65,12 @@ pub enum EndOfSupportCheckMode {
6565
#[derive(Debug, Snafu)]
6666
pub enum Error {
6767
#[snafu(display("failed to parse built-time"))]
68-
ParseBuiltTime { source: chrono::ParseError },
68+
ParseBuiltTime { source: k8s_openapi::jiff::Error },
6969
}
7070

7171
pub struct EndOfSupportChecker {
72-
built_datetime: DateTime<Utc>,
73-
eos_datetime: DateTime<Utc>,
72+
built_datetime: Zoned,
73+
eos_datetime: Zoned,
7474
interval: Duration,
7575
disabled: bool,
7676
}
@@ -94,15 +94,13 @@ impl EndOfSupportChecker {
9494
// Parse the built-time from the RFC2822-encoded string when this is compiled as a release
9595
// build. If this is a debug/dev build, use the current datetime instead.
9696
let built_datetime = if cfg!(debug_assertions) {
97-
Utc::now()
97+
Zoned::now()
9898
} else {
99-
DateTime::parse_from_rfc2822(built_time)
100-
.context(ParseBuiltTimeSnafu)?
101-
.to_utc()
99+
jiff::fmt::rfc2822::parse(built_time).context(ParseBuiltTimeSnafu)?
102100
};
103101

104102
// Add the support duration to the built date. This marks the end-of-support date.
105-
let eos_datetime = built_datetime + *support_duration;
103+
let eos_datetime = &built_datetime + *support_duration;
106104

107105
Ok(Self {
108106
built_datetime,
@@ -144,12 +142,13 @@ impl EndOfSupportChecker {
144142

145143
// The first tick ticks immediately.
146144
_ = interval.tick() => {
147-
let now = Utc::now();
145+
let now = Zoned::now();
148146

149147
tracing::info_span!(
150148
"checking end-of-support state",
151149
eos.interval = self.interval.to_string(),
152-
eos.now = now.to_rfc3339(),
150+
eos.now = jiff::fmt::rfc2822::to_string(&now)
151+
.expect("Zoned::now() can always be serialized using rfc2822::to_string"),
153152
);
154153

155154
// Continue the loop and wait for the next tick to run the
@@ -166,9 +165,10 @@ impl EndOfSupportChecker {
166165

167166
/// Emits the end-of-support warning.
168167
#[instrument(level = Level::DEBUG, skip(self))]
169-
fn emit_warning(&self, now: DateTime<Utc>) {
170-
let built_datetime = self.built_datetime.to_rfc3339();
171-
let build_age = Duration::try_from(now - self.built_datetime)
168+
fn emit_warning(&self, now: Zoned) {
169+
let built_datetime = jiff::fmt::rfc2822::to_string(&self.built_datetime)
170+
.expect("The build datetime can always be serialized using rfc2822::to_string");
171+
let build_age = Duration::try_from(&now - &self.built_datetime)
172172
.expect("time delta of now and built datetime must not be less than 0")
173173
.to_string();
174174

crates/stackable-operator/src/status/condition/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ pub mod deployment;
33
pub mod operations;
44
pub mod statefulset;
55

6-
use chrono::Utc;
7-
use k8s_openapi::apimachinery::pkg::apis::meta::v1::Time;
6+
use k8s_openapi::{apimachinery::pkg::apis::meta::v1::Time, jiff::Timestamp};
87
use schemars::{self, JsonSchema};
98
use serde::{Deserialize, Serialize};
109
use strum::EnumCount;
@@ -345,7 +344,7 @@ fn update_timestamps(
345344
// sanity check
346345
assert_eq!(old_condition.type_, new_condition.type_);
347346

348-
let now = Time(Utc::now());
347+
let now = Time(Timestamp::now());
349348
// No change in status -> keep "last_transition_time"
350349
if old_condition.status == new_condition.status {
351350
ClusterCondition {

crates/stackable-shared/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ edition.workspace = true
77
repository.workspace = true
88

99
[features]
10-
full = ["chrono", "time"]
10+
full = ["jiff", "time"]
1111
default = ["time"]
1212

13-
chrono = ["dep:chrono"]
13+
jiff = ["dep:jiff"]
1414
time = ["dep:time"]
1515

1616
[dependencies]
17-
chrono = { workspace = true, optional = true }
17+
jiff = { workspace = true, optional = true }
1818
k8s-openapi.workspace = true
1919
kube.workspace = true
2020
schemars.workspace = true

0 commit comments

Comments
 (0)