Skip to content

Commit 32ced51

Browse files
committed
chore!: Upgrade to kube 3.0.0 and k8s-openapi 0.27.0
1 parent 356fb71 commit 32ced51

22 files changed

+1159
-464
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 4 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"
4241
# 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"] }
42+
kube = { version = "3.0.0", 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: 786 additions & 136 deletions
Large diffs are not rendered by default.

crates/stackable-operator/crds/ListenerClass.yaml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,35 @@ spec:
7777
description: Annotations that should be added to the Service object.
7878
type: object
7979
serviceExternalTrafficPolicy:
80+
anyOf:
81+
- description: |-
82+
Service Internal Traffic Policy enables internal traffic restrictions to only route internal
83+
traffic to endpoints within the node the traffic originated from. The "internal" traffic
84+
here refers to traffic originated from Pods in the current cluster. This can help to reduce
85+
costs and improve performance. See [Kubernetes docs][k8s-docs].
86+
87+
[k8s-docs]: https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
88+
enum:
89+
- Cluster
90+
- Local
91+
type: string
92+
- enum:
93+
- null
94+
nullable: true
8095
description: |-
81-
Service Internal Traffic Policy enables internal traffic restrictions to only route internal
82-
traffic to endpoints within the node the traffic originated from. The "internal" traffic
83-
here refers to traffic originated from Pods in the current cluster. This can help to reduce
84-
costs and improve performance. See [Kubernetes docs][k8s-docs].
96+
`externalTrafficPolicy` that should be set on the created Service objects.
8597
86-
[k8s-docs]: https://kubernetes.io/docs/concepts/services-networking/service-traffic-policy/
87-
enum:
88-
- Cluster
89-
- Local
90-
nullable: true
91-
type: string
98+
It is a Kubernetes feature that controls how external traffic is routed to a Kubernetes
99+
Service.
100+
101+
* `Cluster`: Kubernetes default. Traffic is routed to any node in the Kubernetes cluster that
102+
has a pod running the service.
103+
* `Local`: Traffic is only routed to pods running on the same node as the Service.
104+
105+
The `Local` mode has better performance as it avoids a network hop, but requires a more
106+
sophisticated LoadBalancer, that respects what Pods run on which nodes and routes traffic only
107+
to these nodes accordingly. Some cloud providers or bare metal installations do not implement
108+
some of the required features.
92109
serviceType:
93110
description: The method used to access the services.
94111
enum:

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: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use chrono::{DateTime, Utc};
1+
use jiff::{self, Zoned};
22
use snafu::{ResultExt, Snafu};
33
use stackable_shared::time::Duration;
44
use tracing::{Level, instrument};
@@ -63,12 +63,12 @@ pub enum EndOfSupportCheckMode {
6363
#[derive(Debug, Snafu)]
6464
pub enum Error {
6565
#[snafu(display("failed to parse built-time"))]
66-
ParseBuiltTime { source: chrono::ParseError },
66+
ParseBuiltTime { source: k8s_openapi::jiff::Error },
6767
}
6868

6969
pub struct EndOfSupportChecker {
70-
built_datetime: DateTime<Utc>,
71-
eos_datetime: DateTime<Utc>,
70+
built_datetime: Zoned,
71+
eos_datetime: Zoned,
7272
interval: Duration,
7373
disabled: bool,
7474
}
@@ -92,15 +92,13 @@ impl EndOfSupportChecker {
9292
// Parse the built-time from the RFC2822-encoded string when this is compiled as a release
9393
// build. If this is a debug/dev build, use the current datetime instead.
9494
let built_datetime = if cfg!(debug_assertions) {
95-
Utc::now()
95+
Zoned::now()
9696
} else {
97-
DateTime::parse_from_rfc2822(built_time)
98-
.context(ParseBuiltTimeSnafu)?
99-
.to_utc()
97+
jiff::fmt::rfc2822::parse(built_time).context(ParseBuiltTimeSnafu)?
10098
};
10199

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

105103
Ok(Self {
106104
built_datetime,
@@ -127,12 +125,13 @@ impl EndOfSupportChecker {
127125
// TODO: Add way to stop from the outside
128126
// The first tick ticks immediately.
129127
interval.tick().await;
130-
let now = Utc::now();
128+
let now = Zoned::now();
131129

132130
tracing::info_span!(
133131
"checking end-of-support state",
134132
eos.interval = self.interval.to_string(),
135-
eos.now = now.to_rfc3339(),
133+
eos.now = jiff::fmt::rfc2822::to_string(&now)
134+
.expect("Zoned::now() can always be serialized using rfc2822::to_string"),
136135
);
137136

138137
// Continue the loop and wait for the next tick to run the check again.
@@ -146,18 +145,19 @@ impl EndOfSupportChecker {
146145

147146
/// Emits the end-of-support warning.
148147
#[instrument(level = Level::DEBUG, skip(self))]
149-
fn emit_warning(&self, now: DateTime<Utc>) {
150-
let built_datetime = self.built_datetime.to_rfc3339();
151-
let build_age = Duration::try_from(now - self.built_datetime)
148+
fn emit_warning(&self, now: Zoned) {
149+
let built_datetime = jiff::fmt::rfc2822::to_string(&self.built_datetime)
150+
.expect("The build datetime can always be serialized using rfc2822::to_string");
151+
let build_age = Duration::try_from(&now - &self.built_datetime)
152152
.expect("time delta of now and built datetime must not be less than 0")
153153
.to_string();
154154

155155
tracing::warn!(
156156
eos.built.datetime = built_datetime,
157-
eos.build.age = build_age,
157+
eos.build.age = %build_age,
158158
"This operator version was built on {built_datetime} ({build_age} ago) and may have reached end-of-support. \
159-
Running unsupported versions may contain security vulnerabilities. \
160-
Please upgrade to a supported version as soon as possible."
159+
Running unsupported versions may contain security vulnerabilities. \
160+
Please upgrade to a supported version as soon as possible."
161161
);
162162
}
163163
}

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 {

0 commit comments

Comments
 (0)