Skip to content

Commit

Permalink
Merge branch 'main' into otel_attr
Browse files Browse the repository at this point in the history
  • Loading branch information
sfleen authored Jan 31, 2025
2 parents 331f711 + 63dce67 commit aa1a3dd
Show file tree
Hide file tree
Showing 21 changed files with 993 additions and 654 deletions.
183 changes: 132 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ skip = [
# Some dependencies still use indexmap v1.
{ name = "indexmap", version = "1" },
{ name = "hashbrown", version = "0.12" },

]
skip-tree = [
# thiserror v2 is still propagating through the ecosystem
{ name = "thiserror", version = "1" },
# rand 0.9 is still propagating through the ecosystem
{ name = "rand", version = "0.8" },
]

[sources]
Expand Down
2 changes: 1 addition & 1 deletion linkerd/distribute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
ahash = "0.8"
linkerd-stack = { path = "../stack" }
parking_lot = "0.12"
rand = { version = "0.8", features = ["small_rng"] }
rand = { version = "0.9", features = ["small_rng"] }
tokio = { version = "1", features = ["macros"] }
tracing = "0.1"

Expand Down
2 changes: 1 addition & 1 deletion linkerd/distribute/src/keys.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ahash::{HashMap, HashMapExt};
use rand::{
distributions::{WeightedError, WeightedIndex},
distr::weighted::{Error as WeightedError, WeightedIndex},
prelude::Distribution as _,
Rng,
};
Expand Down
3 changes: 1 addition & 2 deletions linkerd/distribute/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
WeightedServiceKeys,
};
use ahash::AHashSet;
use rand::distributions::WeightedError;
use std::{fmt::Debug, hash::Hash, sync::Arc};

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -73,7 +72,7 @@ impl<K> Distribution<K> {

pub fn random_available<T: IntoIterator<Item = (K, u32)>>(
iter: T,
) -> Result<Self, WeightedError> {
) -> Result<Self, rand::distr::weighted::Error> {
let weighted_keys = WeightedServiceKeys::new(
iter.into_iter()
.map(|(key, weight)| WeightedKey { key, weight }),
Expand Down
6 changes: 3 additions & 3 deletions linkerd/distribute/src/service/random.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{keys::KeyId, WeightedServiceKeys};
use ahash::HashMap;
use linkerd_stack::{NewService, Service};
use rand::{distributions::WeightedError, rngs::SmallRng, SeedableRng};
use rand::{distr::weighted, rngs::SmallRng, SeedableRng};
use std::{
hash::Hash,
sync::Arc,
Expand All @@ -21,7 +21,7 @@ pub(crate) struct RandomAvailableSelection<K, S> {
}

fn new_rng() -> SmallRng {
SmallRng::from_rng(rand::thread_rng()).expect("RNG must initialize")
SmallRng::from_rng(&mut rand::rng())
}

impl<K, S> RandomAvailableSelection<K, S> {
Expand Down Expand Up @@ -92,7 +92,7 @@ where
// to `poll_ready` can try this backend again.
match selector.disable_backend(id) {
Ok(()) => {}
Err(WeightedError::AllWeightsZero) => {
Err(weighted::Error::InsufficientNonZero) => {
// There are no backends remaining.
break;
}
Expand Down
2 changes: 1 addition & 1 deletion linkerd/exp-backoff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false

[dependencies]
futures = { version = "0.3", default-features = false }
rand = { version = "0.8", features = ["small_rng"] }
rand = { version = "0.9", features = ["small_rng"] }
thiserror = "2"
tokio = { version = "1", features = ["time"] }
pin-project = "1"
Expand Down
8 changes: 4 additions & 4 deletions linkerd/exp-backoff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use futures::Stream;
use pin_project::pin_project;
use rand::{rngs::SmallRng, thread_rng, SeedableRng};
use rand::{rngs::SmallRng, SeedableRng};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
Expand Down Expand Up @@ -74,7 +74,7 @@ impl ExponentialBackoff {
pub fn stream(&self) -> ExponentialBackoffStream {
ExponentialBackoffStream {
backoff: *self,
rng: SmallRng::from_rng(&mut thread_rng()).expect("RNG must be valid"),
rng: SmallRng::from_rng(&mut rand::rng()),
iterations: 0,
sleeping: false,
sleep: Box::pin(time::sleep(time::Duration::from_secs(0))),
Expand Down Expand Up @@ -103,7 +103,7 @@ impl ExponentialBackoff {
if self.jitter == 0.0 {
time::Duration::default()
} else {
let jitter_factor = rng.gen::<f64>();
let jitter_factor = rng.random::<f64>();
debug_assert!(
jitter_factor > 0.0,
"rng returns values between 0.0 and 1.0"
Expand Down Expand Up @@ -212,7 +212,7 @@ mod tests {
Ok(backoff) => backoff,
};

let j = backoff.jitter(base, &mut rand::thread_rng());
let j = backoff.jitter(base, &mut rand::rng());
if jitter == 0.0 || base_ms == 0 || max_ms == base_ms {
TestResult::from_bool(j == time::Duration::default())
} else {
Expand Down
Loading

0 comments on commit aa1a3dd

Please sign in to comment.