Skip to content

Commit 63bfa8a

Browse files
build(deps)!: bump the kube group with 4 updates (#366)
Updates the requirements on [kube-client](https://github.com/kube-rs/kube), [kube-core](https://github.com/kube-rs/kube), [kube-runtime](https://github.com/kube-rs/kube) and [kube](https://github.com/kube-rs/kube) to permit the latest version. Updates `kube-client` to 0.98.0 - [Release notes](https://github.com/kube-rs/kube/releases) - [Changelog](https://github.com/kube-rs/kube/blob/main/CHANGELOG.md) - [Commits](kube-rs/kube@0.98.0...0.98.0) Updates `kube-core` to 0.99.0 - [Release notes](https://github.com/kube-rs/kube/releases) - [Changelog](https://github.com/kube-rs/kube/blob/main/CHANGELOG.md) - [Commits](kube-rs/kube@0.98.0...0.99.0) Updates `kube-runtime` to 0.98.0 - [Release notes](https://github.com/kube-rs/kube/releases) - [Changelog](https://github.com/kube-rs/kube/blob/main/CHANGELOG.md) - [Commits](kube-rs/kube@0.98.0...0.98.0) Updates `kube` to 0.98.0 - [Release notes](https://github.com/kube-rs/kube/releases) - [Changelog](https://github.com/kube-rs/kube/blob/main/CHANGELOG.md) - [Commits](kube-rs/kube@0.98.0...0.98.0) --- updated-dependencies: - dependency-name: kube-client dependency-type: direct:production dependency-group: kube - dependency-name: kube-core dependency-type: direct:production dependency-group: kube - dependency-name: kube-runtime dependency-type: direct:production dependency-group: kube - dependency-name: kube dependency-type: direct:production dependency-group: kube ... --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Oliver Gould <[email protected]>
1 parent 9e79571 commit 63bfa8a

File tree

8 files changed

+58
-38
lines changed

8 files changed

+58
-38
lines changed

Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ hyper-util = { version = "0.1", default-features = false }
2222

2323
k8s-openapi = { version = "0.24", default-features = false }
2424

25-
kube-client = { version = "0.98", default-features = false }
26-
kube-core = { version = "0.98", default-features = false }
27-
kube-runtime = { version = "0.98", default-features = false }
28-
kube = { version = "0.98", default-features = false }
25+
kube-client = { version = "0.99", default-features = false }
26+
kube-core = { version = "0.99", default-features = false }
27+
kube-runtime = { version = "0.99", default-features = false }
28+
kube = { version = "0.99", default-features = false }
2929

3030
prometheus-client = { version = "0.23.0", default-features = false }
3131

3232
tokio = { version = "1.17.0", default-features = false }
33+
tokio-rustls = { version = "0.26.1", default-features = false }

deny.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
db-path = "~/.cargo/advisory-db"
33
db-urls = ["https://github.com/rustsec/advisory-db"]
44
ignore = [
5-
# kube-runtime uses backoff uses instant which is unmaintained.
6-
"RUSTSEC-2024-0384",
75
]
86

97
[licenses]
@@ -13,6 +11,7 @@ allow = [
1311
"BSD-3-Clause",
1412
"ISC",
1513
"MIT",
14+
"OpenSSL",
1615
"Unicode-3.0",
1716
"Zlib",
1817
]

examples/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ release = false
1111

1212
[features]
1313
default = ["rustls-tls"]
14-
rustls-tls = ["kubert/rustls-tls"]
14+
rustls-tls = ["kubert/rustls-tls-aws-lc-rs"]
1515
openssl-tls = ["kubert/openssl-tls", "dep:openssl"]
1616

1717
[dependencies.kubert]
@@ -53,7 +53,7 @@ features = ["latest"]
5353

5454
[dev-dependencies.kube]
5555
workspace = true
56-
features = ["client", "derive", "rustls-tls", "runtime"]
56+
features = ["client", "derive", "runtime"]
5757

5858
[dev-dependencies.tokio]
5959
workspace = true

kubert/Cargo.toml

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kubert"
3-
version = "0.23.1"
3+
version = "0.24.0"
44
edition = "2021"
55
license = "Apache-2.0"
66
description = "Kubernetes runtime helpers. Based on kube-rs."
@@ -15,6 +15,18 @@ rustls-tls = [
1515
"dep:tokio-rustls",
1616
"kube-client?/rustls-tls",
1717
]
18+
rustls-tls-aws-lc-rs = [
19+
"rustls-tls",
20+
"tokio-rustls/aws-lc-rs",
21+
"kube-client?/aws-lc-rs",
22+
"kube-client?/rustls-tls",
23+
]
24+
rustls-tls-ring = [
25+
"rustls-tls",
26+
"tokio-rustls/ring",
27+
"kube-client?/ring",
28+
"kube-client?/rustls-tls",
29+
]
1830
openssl-tls = [
1931
"dep:hyper-openssl",
2032
"dep:once_cell",
@@ -76,7 +88,7 @@ initialized = [
7688
"tokio/sync",
7789
]
7890
lease = [
79-
"dep:backoff",
91+
"dep:backon",
8092
"dep:chrono",
8193
"dep:futures-util",
8294
"dep:hyper",
@@ -183,7 +195,7 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
183195

184196
[dependencies]
185197
ahash = { version = "0.8", optional = true }
186-
backoff = { version = "0.4", features = ["tokio"], optional = true }
198+
backon = { version = "1", optional = true, features = ["tokio-sleep"] }
187199
bytes = { version = "1", optional = true }
188200
drain = { version = "0.2.1", optional = true, default-features = false }
189201
chrono = { version = "0.4", optional = true, default-features = false }
@@ -204,7 +216,7 @@ serde_json = { version = "1", optional = true }
204216
sha2 = { version = "0.10", optional = true }
205217
thiserror = { version = "2", optional = true }
206218
tokio = { workspace = true, optional = false, default-features = false }
207-
tokio-rustls = { version = "0.26.1", optional = true, default-features = false }
219+
tokio-rustls = { workspace = true, optional = true }
208220
tokio-openssl = { version = "0.6.3", optional = true }
209221
tokio-util = { version = "0.7", optional = true, default-features = false }
210222
tower-http = { version = "0.6.0", optional = true, default-features = false }
@@ -253,6 +265,7 @@ features = ["rt"]
253265
# === Dev ===
254266

255267
[dev-dependencies]
268+
tokio-rustls = { workspace = true, features = ["aws-lc-rs"] }
256269
kube = { workspace = true, features = ["runtime"] }
257270
rcgen = { version = "0.13.0" }
258271
tempfile = "3.8"

kubert/src/lease.rs

+18-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//! [`LeaseManager`] interacts with a [`coordv1::Lease`] resource to ensure that
88
//! only a single claimant owns the lease at a time.
99
10-
use futures_util::TryFutureExt;
1110
use k8s_openapi::{api::coordination::v1 as coordv1, apimachinery::pkg::apis::meta::v1 as metav1};
1211
use std::{borrow::Cow, sync::Arc};
1312
use tokio::time::{self, Duration};
@@ -161,7 +160,7 @@ impl Claim {
161160
impl LeaseManager {
162161
pub(crate) const DEFAULT_FIELD_MANAGER: &'static str = "kubert";
163162
const DEFAULT_MIN_BACKOFF: Duration = Duration::from_millis(5);
164-
const DEFAULT_BACKOFF_JITTER: f64 = 0.5; // up to 50% of the backoff duration
163+
const DEFAULT_BACKOFF_JITTER: f32 = 0.5; // up to 50% of the backoff duration
165164
const API_TIMEOUT: Duration = Duration::from_secs(10);
166165

167166
/// Initialize a lease's state from the Kubernetes API.
@@ -371,10 +370,12 @@ impl LeaseManager {
371370
let claimant = claimant.to_string();
372371
let mut claim = self.ensure_claimed(&claimant, &params).await?;
373372
let (tx, rx) = tokio::sync::watch::channel(claim.clone());
374-
let mut new_backoff = backoff::ExponentialBackoffBuilder::default();
373+
374+
use backon::Retryable;
375+
let new_backoff = backon::ExponentialBuilder::default();
375376
new_backoff
376-
.with_initial_interval(Self::DEFAULT_MIN_BACKOFF)
377-
.with_randomization_factor(Self::DEFAULT_BACKOFF_JITTER);
377+
.with_min_delay(Self::DEFAULT_MIN_BACKOFF)
378+
.with_factor(Self::DEFAULT_BACKOFF_JITTER);
378379

379380
let task = tokio::spawn(async move {
380381
loop {
@@ -395,31 +396,22 @@ impl LeaseManager {
395396
}
396397

397398
// Update the claim and broadcast it to all receivers.
398-
let backoff = new_backoff.with_max_interval(grace).build();
399-
claim = backoff::future::retry(backoff, || {
400-
self.ensure_claimed(&claimant, &params).map_err(|err| match err {
401-
err @ Error::Api(kube_client::Error::Auth(_))
402-
| err @ Error::Api(kube_client::Error::Discovery(_))
403-
| err @ Error::Api(kube_client::Error::BuildRequest(_)) => {
404-
backoff::Error::Permanent(err)
405-
},
406-
err @ Error::Api(kube_client::Error::InferConfig(_)) => {
399+
let backoff = new_backoff.with_max_delay(grace);
400+
claim = (|| async { self.ensure_claimed(&claimant, &params).await })
401+
.retry(backoff)
402+
.when(|err| match err {
403+
Error::Api(kube_client::Error::Auth(_))
404+
| Error::Api(kube_client::Error::Discovery(_))
405+
| Error::Api(kube_client::Error::BuildRequest(_)) => false,
406+
Error::Api(kube_client::Error::InferConfig(_)) => {
407407
debug_assert!(false, "InferConfig errors should only be returned when constructing a new client");
408-
backoff::Error::Permanent(err)
408+
false
409409
},
410410
// Retry any other API request errors.
411-
err => {
412-
tracing::debug!(error = %err, "Error claiming lease, retrying...");
413-
backoff::Error::Transient {
414-
err,
415-
// Allow the backoff implementation to select how
416-
// long to wait before retrying.
417-
retry_after: None,
418-
}
419-
}
411+
_ => true,
420412
})
421-
})
422-
.await?;
413+
.notify(|error, sleep| tracing::debug!(%error, ?sleep, "Error claiming lease, retrying..."))
414+
.await?;
423415
if tx.send(claim.clone()).is_err() {
424416
// All receivers have been dropped.
425417
break;

kubert/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ pub mod requeue;
119119
#[cfg_attr(docsrs, doc(cfg(feature = "runtime")))]
120120
pub mod runtime;
121121

122+
#[cfg(feature = "rustls-tls")]
123+
pub use tokio_rustls::rustls;
124+
122125
#[cfg(feature = "server")]
123126
#[cfg_attr(docsrs, doc(cfg(feature = "server")))]
124127
pub mod server;

kubert/src/server/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ fn gen_keys() -> (TempDir, TlsPaths) {
3333
#[cfg(feature = "rustls-tls")]
3434
#[tokio::test]
3535
async fn load_tls_rustls() {
36+
tokio_rustls::rustls::crypto::aws_lc_rs::default_provider()
37+
.install_default()
38+
.expect("installing aws-lc-rs provider must succeed");
3639
let (_tempdir, TlsPaths { key, certs }) = gen_keys();
3740
match super::tls_rustls::load_tls(&key, &certs).await {
3841
Ok(_) => println!("load_tls: success!"),

kubert/src/server/tls_rustls.rs

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ pub(in crate::server) async fn load_tls(
1313
pk: &TlsKeyPath,
1414
crts: &TlsCertPath,
1515
) -> Result<TlsAcceptor, Error> {
16+
if tokio_rustls::rustls::crypto::CryptoProvider::get_default().is_none() {
17+
// The only error here is if it's been initialized in between: we can ignore it
18+
// since our semantic is only to set the default value if it does not exist.
19+
#[cfg(feature = "rustls-tls-aws-lc-rs")]
20+
let _ = tokio_rustls::rustls::crypto::aws_lc_rs::default_provider().install_default();
21+
#[cfg(feature = "rustls-tls-ring")]
22+
let _ = tokio_rustls::rustls::crypto::ring::default_provider().install_default();
23+
}
24+
1625
let key = load_private_key(pk).await.map_err(Error::TlsKeyReadError)?;
1726
let certs = load_certs(crts).await.map_err(Error::TlsCertsReadError)?;
1827
let mut cfg = rustls::ServerConfig::builder()

0 commit comments

Comments
 (0)