Skip to content

Commit adf7562

Browse files
Merge branch 'main' into propagate-delete-shared-stream
2 parents 61a9766 + 07b7891 commit adf7562

File tree

18 files changed

+200
-102
lines changed

18 files changed

+200
-102
lines changed

.github/workflows/clippy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
- uses: dtolnay/rust-toolchain@nightly
1515
with:
1616
components: clippy
17-
- uses: clechasseur/rs-clippy-check@v3
17+
- uses: clechasseur/rs-clippy-check@v4
1818
with:
1919
args: --workspace

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ assert-json-diff = "2.0.2"
3737
async-broadcast = "0.7.0"
3838
async-stream = "0.3.5"
3939
async-trait = "0.1.64"
40-
backoff = "0.4.0"
40+
backon = "1.3"
4141
base64 = "0.22.1"
4242
bytes = "1.1.0"
4343
chrono = { version = "0.4.34", default-features = false }
@@ -68,9 +68,8 @@ pem = "3.0.1"
6868
pin-project = "1.0.4"
6969
proc-macro2 = "1.0.29"
7070
quote = "1.0.10"
71-
rand = "0.8.3"
71+
rand = "0.9.0"
7272
rustls = { version = "0.23.16", default-features = false }
73-
rustls-pemfile = "2.0.0"
7473
schemars = "0.8.6"
7574
secrecy = "0.10.2"
7675
serde = "1.0.130"

deny.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,17 @@ name = "thiserror-impl"
9797
name = "security-framework"
9898
[[bans.skip]]
9999
name = "core-foundation"
100+
101+
# currently tungstenite hasn't upgraded rand to 0.9 yet, all these are related
102+
[[bans.skip]]
103+
name = "rand"
104+
[[bans.skip]]
105+
name = "rand_core"
106+
[[bans.skip]]
107+
name = "rand_chacha"
108+
[[bans.skip]]
109+
name = "getrandom"
110+
[[bans.skip]]
111+
name = "wasi"
112+
[[bans.skip]]
113+
name = "zerocopy"

examples/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ latest = ["k8s-openapi/latest"]
2424
[dev-dependencies]
2525
tokio-util.workspace = true
2626
assert-json-diff.workspace = true
27-
garde = { version = "0.21.0", default-features = false, features = ["derive"] }
27+
garde = { version = "0.22.0", default-features = false, features = ["derive"] }
2828
anyhow.workspace = true
2929
futures = { workspace = true, features = ["async-await"] }
3030
jsonpath-rust.workspace = true
@@ -52,7 +52,7 @@ tower-http = { workspace = true, features = ["trace", "decompression-gzip"] }
5252
hyper = { workspace = true, features = ["client", "http1"] }
5353
hyper-util = { workspace = true, features = ["client-legacy", "http1", "tokio"] }
5454
thiserror.workspace = true
55-
backoff.workspace = true
55+
backon.workspace = true
5656
clap = { version = "4.0", default-features = false, features = ["std", "cargo", "derive"] }
5757
edit = "0.1.3"
5858
tokio-stream = { version = "0.1.9", features = ["net"] }

kube-client/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ categories = ["web-programming::http-client", "network-programming", "api-bindin
1313

1414
[features]
1515
default = ["client"]
16-
rustls-tls = ["rustls", "rustls-pemfile", "hyper-rustls", "hyper-http-proxy?/rustls-tls-native-roots"]
16+
rustls-tls = ["rustls", "hyper-rustls", "hyper-http-proxy?/rustls-tls-native-roots"]
1717
webpki-roots = ["hyper-rustls/webpki-roots"]
1818
aws-lc-rs = ["rustls?/aws-lc-rs"]
1919
openssl-tls = ["openssl", "hyper-openssl"]
20-
ws = ["client", "tokio-tungstenite", "rand", "kube-core/ws", "tokio/macros"]
20+
ws = ["client", "tokio-tungstenite", "kube-core/ws", "tokio/macros"]
2121
kubelet-debug = ["ws", "kube-core/kubelet-debug"]
2222
oauth = ["client", "tame-oauth"]
2323
oidc = ["client", "form_urlencoded"]
@@ -57,7 +57,6 @@ futures = { workspace = true, optional = true, features = ["std"] }
5757
pem = { workspace = true, optional = true }
5858
openssl = { workspace = true, optional = true }
5959
rustls = { workspace = true, optional = true }
60-
rustls-pemfile = { workspace = true, optional = true }
6160
bytes = { workspace = true, optional = true }
6261
tokio = { workspace = true, features = ["time", "signal", "sync"], optional = true }
6362
kube-core = { path = "../kube-core", version = "=0.98.0" }
@@ -73,7 +72,6 @@ tower = { workspace = true, features = ["buffer", "filter", "util"], optional =
7372
tower-http = { workspace = true, features = ["auth", "map-response-body", "trace"], optional = true }
7473
hyper-timeout = { workspace = true, optional = true }
7574
tame-oauth = { workspace = true, features = ["gcp"], optional = true }
76-
rand = { workspace = true, optional = true }
7775
secrecy = { workspace = true }
7876
tracing = { workspace = true, features = ["log"], optional = true }
7977
hyper-openssl = { workspace = true, features = ["client-legacy"], optional = true }

kube-client/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl Client {
206206
http::header::SEC_WEBSOCKET_VERSION,
207207
HeaderValue::from_static("13"),
208208
);
209-
let key = upgrade::sec_websocket_key();
209+
let key = tokio_tungstenite::tungstenite::handshake::client::generate_key();
210210
parts.headers.insert(
211211
http::header::SEC_WEBSOCKET_KEY,
212212
key.parse().expect("valid header value"),

kube-client/src/client/tls.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod rustls_tls {
1414
pub enum Error {
1515
/// Identity PEM is invalid
1616
#[error("identity PEM is invalid: {0}")]
17-
InvalidIdentityPem(#[source] std::io::Error),
17+
InvalidIdentityPem(#[source] rustls::pki_types::pem::Error),
1818

1919
/// Identity PEM is missing a private key: the key must be PKCS8 or RSA/PKCS1
2020
#[error("identity PEM is missing a private key: the key must be PKCS8 or RSA/PKCS1")]
@@ -96,22 +96,19 @@ pub mod rustls_tls {
9696
}
9797

9898
fn client_auth(data: &[u8]) -> Result<(Vec<CertificateDer<'static>>, PrivateKeyDer<'static>), Error> {
99-
use rustls_pemfile::Item;
99+
use rustls::pki_types::pem::{self, SectionKind};
100100

101101
let mut cert_chain = Vec::new();
102102
let mut pkcs8_key = None;
103103
let mut pkcs1_key = None;
104104
let mut sec1_key = None;
105105
let mut reader = std::io::Cursor::new(data);
106-
for item in rustls_pemfile::read_all(&mut reader)
107-
.collect::<Result<Vec<_>, _>>()
108-
.map_err(Error::InvalidIdentityPem)?
109-
{
110-
match item {
111-
Item::X509Certificate(cert) => cert_chain.push(cert),
112-
Item::Pkcs8Key(key) => pkcs8_key = Some(PrivateKeyDer::Pkcs8(key)),
113-
Item::Pkcs1Key(key) => pkcs1_key = Some(PrivateKeyDer::from(key)),
114-
Item::Sec1Key(key) => sec1_key = Some(PrivateKeyDer::from(key)),
106+
while let Some((kind, der)) = pem::from_buf(&mut reader).map_err(Error::InvalidIdentityPem)? {
107+
match kind {
108+
SectionKind::Certificate => cert_chain.push(der.into()),
109+
SectionKind::PrivateKey => pkcs8_key = Some(PrivateKeyDer::Pkcs8(der.into())),
110+
SectionKind::RsaPrivateKey => pkcs1_key = Some(PrivateKeyDer::Pkcs1(der.into())),
111+
SectionKind::EcPrivateKey => sec1_key = Some(PrivateKeyDer::Sec1(der.into())),
115112
_ => return Err(Error::UnknownPrivateKeyFormat),
116113
}
117114
}

kube-client/src/client/upgrade.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,3 @@ pub fn verify_response(res: &Response<Body>, key: &str) -> Result<(), UpgradeCon
8686

8787
Ok(())
8888
}
89-
90-
/// Generate a random key for the `Sec-WebSocket-Key` header.
91-
/// This must be nonce consisting of a randomly selected 16-byte value in base64.
92-
pub fn sec_websocket_key() -> String {
93-
use base64::Engine;
94-
let r: [u8; 16] = rand::random();
95-
base64::engine::general_purpose::STANDARD.encode(r)
96-
}

kube-runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ json-patch.workspace = true
4343
jsonptr.workspace = true
4444
serde_json.workspace = true
4545
thiserror.workspace = true
46-
backoff.workspace = true
46+
backon.workspace = true
4747
async-trait.workspace = true
4848
hashbrown.workspace = true
4949
k8s-openapi.workspace = true

kube-runtime/src/controller/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ use crate::{
88
ObjectRef,
99
},
1010
scheduler::{debounced_scheduler, ScheduleRequest},
11-
utils::{trystream_try_via, CancelableJoinHandle, KubeRuntimeStreamExt, StreamBackoff, WatchStreamExt},
11+
utils::{
12+
trystream_try_via, Backoff, CancelableJoinHandle, KubeRuntimeStreamExt, StreamBackoff, WatchStreamExt,
13+
},
1214
watcher::{self, metadata_watcher, watcher, DefaultBackoff},
1315
};
14-
use backoff::backoff::Backoff;
1516
use educe::Educe;
1617
use futures::{
1718
channel,
@@ -915,7 +916,7 @@ where
915916
/// The [`default_backoff`](crate::watcher::default_backoff) follows client-go conventions,
916917
/// but can be overridden by calling this method.
917918
#[must_use]
918-
pub fn trigger_backoff(mut self, backoff: impl Backoff + Send + 'static) -> Self {
919+
pub fn trigger_backoff(mut self, backoff: impl Backoff + 'static) -> Self {
919920
self.trigger_backoff = Box::new(backoff);
920921
self
921922
}

0 commit comments

Comments
 (0)