From 228096241ef9eddf62514a7c7bb89c92a5be026e Mon Sep 17 00:00:00 2001 From: rorosen <76747196+rorosen@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:20:02 +0200 Subject: [PATCH] upgrade to hashbrown 0.15.0 (#1599) Hashbrown 0.15.0 has reworked the entry API which requires the use of a raw entry builder to replace keys. Signed-off-by: Robert Rose --- Cargo.toml | 2 +- deny.toml | 6 ++---- kube-runtime/src/scheduler.rs | 16 ++++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 19257d409..ecb28891d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ educe = { version = "0.6.0", default-features = false } either = "1.6.1" form_urlencoded = "1.2.0" futures = { version = "0.3.17", default-features = false } -hashbrown = "0.14.0" +hashbrown = "0.15.0" home = "0.5.4" http = "1.1.0" http-body = "1.0.0" diff --git a/deny.toml b/deny.toml index 0e5655f50..8c1aa1545 100644 --- a/deny.toml +++ b/deny.toml @@ -31,6 +31,8 @@ allow = [ # Pulled in via aws_lc_rs when using rustls-tls and aws-lc-rs features # https://openssl-library.org/source/license/index.html "OpenSSL", + # Pulled in via hashbrown through its foldhash dependency + "Zlib", ] exceptions = [ @@ -64,10 +66,6 @@ multiple-versions = "deny" [[bans.skip]] name = "rustls-native-certs" -[[bans.skip]] -# blocked on us swapping out serde_yaml -name = "hashbrown" - [[bans.skip]] # base64 did some annoying breaking changes name = "base64" diff --git a/kube-runtime/src/scheduler.rs b/kube-runtime/src/scheduler.rs index 1c391a136..a00435f2c 100644 --- a/kube-runtime/src/scheduler.rs +++ b/kube-runtime/src/scheduler.rs @@ -1,7 +1,7 @@ //! Delays and deduplicates [`Stream`](futures::stream::Stream) items use futures::{stream::Fuse, Stream, StreamExt}; -use hashbrown::{hash_map::Entry, HashMap}; +use hashbrown::{hash_map::RawEntryMut, HashMap}; use pin_project::pin_project; use std::{ collections::HashSet, @@ -78,24 +78,24 @@ impl SchedulerProj<'_, T, R> { .run_at .checked_add(*self.debounce) .unwrap_or_else(far_future); - match self.scheduled.entry(request.message) { + match self.scheduled.raw_entry_mut().from_key(&request.message) { // If new request is supposed to be earlier than the current entry's scheduled // time (for eg: the new request is user triggered and the current entry is the // reconciler's usual retry), then give priority to the new request. - Entry::Occupied(mut old_entry) if old_entry.get().run_at >= request.run_at => { + RawEntryMut::Occupied(mut old_entry) if old_entry.get().run_at >= request.run_at => { // Old entry will run after the new request, so replace it.. let entry = old_entry.get_mut(); self.queue.reset_at(&entry.queue_key, next_time); entry.run_at = next_time; - old_entry.replace_key(); + old_entry.insert_key(request.message); } - Entry::Occupied(_old_entry) => { + RawEntryMut::Occupied(_old_entry) => { // Old entry will run before the new request, so ignore the new request.. } - Entry::Vacant(entry) => { + RawEntryMut::Vacant(entry) => { // No old entry, we're free to go! - let message = entry.key().clone(); - entry.insert(ScheduledEntry { + let message = request.message.clone(); + entry.insert(request.message, ScheduledEntry { run_at: next_time, queue_key: self.queue.insert_at(message, next_time), });