Skip to content

Commit 76d9695

Browse files
authored
chore(deps): upgrade to tower 0.5 (#3744)
* chore(deps)!: upgrade to tower 0.5 this commit updates our tower dependency from 0.4 to 0.5. note that this commit does not affect the `tower-service` and `tower-layer` crates, reëxported by `tower` itself. the `Service<T>` trait and the closely related `Layer<S>` trait have not been changed. the `tower` crate's utilities have changed in various ways, some of particular note for the linkerd2 proxy. see these items, excerpted from the tower changelog: - **retry**: **Breaking Change** `retry::Policy::retry` now accepts `&mut Req` and `&mut Res` instead of the previous mutable versions. This increases the flexibility of the retry policy. To update, update your method signature to include `mut` for both parameters. ([tower-rs/tower#584]) - **retry**: **Breaking Change** Change Policy to accept &mut self ([tower-rs/tower#681]) - **retry**: **Breaking Change** `Budget` is now a trait. This allows end-users to implement their own budget and bucket implementations. ([tower-rs/tower#703]) - **util**: **Breaking Change** `Either::A` and `Either::B` have been renamed `Either::Left` and `Either::Right`, respectively. ([tower-rs/tower#637]) - **util**: **Breaking Change** `Either` now requires its two services to have the same error type. ([tower-rs/tower#637]) - **util**: **Breaking Change** `Either` no longer implemenmts `Future`. ([tower-rs/tower#637]) - **buffer**: **Breaking Change** `Buffer<S, Request>` is now generic over `Buffer<Request, S::Future>.` ([tower-rs/tower#654]) see: * <tower-rs/tower#584> * <tower-rs/tower#681> * <tower-rs/tower#703> * <tower-rs/tower#637> * <tower-rs/tower#654> the `Either` trait bounds are particularly impactful for us. because this runs counter to how we treat errors (skewing towards boxed errors, in general), we temporarily vendor a version of `Either` from the 0.4 release, whose variants have been renamed to match the 0.5 interface. updating to box the inner `A` and `B` services' errors, so we satiate the new `A::Error = B::Error` bounds, can be addressed as a follow-on. that's intentionally left as a separate change, due to the net size of our patchset between this branch and #3504. * <tower-rs/tower@v0.4.x...master> * <https://github.com/tower-rs/tower/blob/master/tower/CHANGELOG.md> this work is based upon #3504. for more information, see: * linkerd/linkerd2#8733 * #3504 Signed-off-by: katelyn martin <[email protected]> X-Ref: tower-rs/tower#815 X-Ref: tower-rs/tower#817 X-Ref: tower-rs/tower#818 X-Ref: tower-rs/tower#819 * fix(stack/loadshed): update test affected by tower-rs/tower#635 this commit updates a test that was affected by breaking changes in tower's `Buffer` middleware. see this excerpt from the description of that change: > I had to change some of the integration tests slightly as part of this > change. This is because the buffer implementation using semaphore > permits is _very subtly_ different from one using a bounded channel. In > the `Semaphore`-based implementation, a semaphore permit is stored in > the `Message` struct sent over the channel. This is so that the capacity > is used as long as the message is in flight. However, when the worker > task is processing a message that's been recieved from the channel, > the permit is still not dropped. Essentially, the one message actively > held by the worker task _also_ occupies one "slot" of capacity, so the > actual channel capacity is one less than the value passed to the > constructor, _once the first request has been sent to the worker_. The > bounded MPSC changed this behavior so that capacity is only occupied > while a request is actually in the channel, which broke some tests > that relied on the old (and technically wrong) behavior. bear particular attention to this: > The bounded MPSC changed this behavior so that capacity is only > occupied while a request is actually in the channel, which broke some > tests that relied on the old (and technically wrong) behavior. that pr adds an additional message to the channel in tests exercising the laod-shedding behavior, on account of the previous (incorrect) behavior. https://github.com/tower-rs/tower/pull/635/files#r797108274 this commit performs the same change for our corresponding test, adding an additional `ready()` call before we hit the buffer's limit. Signed-off-by: katelyn martin <[email protected]> * review: use vendored `Either` for consistency #3744 (comment) Signed-off-by: katelyn martin <[email protected]> --------- Signed-off-by: katelyn martin <[email protected]>
1 parent bab2442 commit 76d9695

File tree

23 files changed

+261
-136
lines changed

23 files changed

+261
-136
lines changed

Cargo.lock

+38-34
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ dependencies = [
10441044
"pin-project",
10451045
"tokio",
10461046
"tokio-test",
1047-
"tower 0.4.13",
1047+
"tower 0.5.2",
10481048
]
10491049

10501050
[[package]]
@@ -1438,7 +1438,7 @@ dependencies = [
14381438
"tokio",
14391439
"tokio-stream",
14401440
"tonic",
1441-
"tower 0.4.13",
1441+
"tower 0.5.2",
14421442
"tracing",
14431443
]
14441444

@@ -1461,7 +1461,7 @@ dependencies = [
14611461
"serde_json",
14621462
"thiserror 2.0.12",
14631463
"tokio",
1464-
"tower 0.4.13",
1464+
"tower 0.5.2",
14651465
"tracing",
14661466
]
14671467

@@ -1530,7 +1530,7 @@ dependencies = [
15301530
"tokio",
15311531
"tokio-stream",
15321532
"tonic",
1533-
"tower 0.4.13",
1533+
"tower 0.5.2",
15341534
"tracing",
15351535
]
15361536

@@ -1551,7 +1551,7 @@ dependencies = [
15511551
"tokio",
15521552
"tokio-test",
15531553
"tonic",
1554-
"tower 0.4.13",
1554+
"tower 0.5.2",
15551555
"tower-test",
15561556
"tracing",
15571557
]
@@ -1590,7 +1590,7 @@ dependencies = [
15901590
"tokio",
15911591
"tokio-test",
15921592
"tonic",
1593-
"tower 0.4.13",
1593+
"tower 0.5.2",
15941594
"tracing",
15951595
]
15961596

@@ -1626,7 +1626,7 @@ dependencies = [
16261626
"tokio-rustls",
16271627
"tokio-stream",
16281628
"tonic",
1629-
"tower 0.4.13",
1629+
"tower 0.5.2",
16301630
"tracing",
16311631
"tracing-subscriber",
16321632
]
@@ -1674,7 +1674,7 @@ dependencies = [
16741674
"tokio-rustls",
16751675
"tokio-test",
16761676
"tonic",
1677-
"tower 0.4.13",
1677+
"tower 0.5.2",
16781678
"tower-test",
16791679
"tracing",
16801680
]
@@ -1703,7 +1703,7 @@ dependencies = [
17031703
"tokio-stream",
17041704
"tokio-test",
17051705
"tonic",
1706-
"tower 0.4.13",
1706+
"tower 0.5.2",
17071707
"tracing",
17081708
"tracing-subscriber",
17091709
]
@@ -1880,7 +1880,7 @@ dependencies = [
18801880
"http",
18811881
"linkerd-stack",
18821882
"pin-project",
1883-
"tower 0.4.13",
1883+
"tower 0.5.2",
18841884
]
18851885

18861886
[[package]]
@@ -1899,7 +1899,7 @@ dependencies = [
18991899
"parking_lot",
19001900
"pin-project",
19011901
"tokio",
1902-
"tower 0.4.13",
1902+
"tower 0.5.2",
19031903
"tracing",
19041904
]
19051905

@@ -1909,7 +1909,7 @@ version = "0.1.0"
19091909
dependencies = [
19101910
"http",
19111911
"linkerd-stack",
1912-
"tower 0.4.13",
1912+
"tower 0.5.2",
19131913
"tracing",
19141914
]
19151915

@@ -1940,7 +1940,7 @@ dependencies = [
19401940
"http-body",
19411941
"linkerd-stack",
19421942
"pin-project",
1943-
"tower 0.4.13",
1943+
"tower 0.5.2",
19441944
]
19451945

19461946
[[package]]
@@ -1964,7 +1964,7 @@ dependencies = [
19641964
"pin-project",
19651965
"thiserror 2.0.12",
19661966
"tokio",
1967-
"tower 0.4.13",
1967+
"tower 0.5.2",
19681968
"tracing",
19691969
]
19701970

@@ -2018,7 +2018,7 @@ dependencies = [
20182018
"pin-project",
20192019
"thiserror 2.0.12",
20202020
"tokio",
2021-
"tower 0.4.13",
2021+
"tower 0.5.2",
20222022
"tracing",
20232023
"try-lock",
20242024
]
@@ -2054,7 +2054,7 @@ dependencies = [
20542054
"linkerd-tracing",
20552055
"parking_lot",
20562056
"tokio",
2057-
"tower 0.4.13",
2057+
"tower 0.5.2",
20582058
"tracing",
20592059
]
20602060

@@ -2257,7 +2257,7 @@ dependencies = [
22572257
"rand 0.9.0",
22582258
"tokio",
22592259
"tokio-test",
2260-
"tower 0.4.13",
2260+
"tower 0.5.2",
22612261
"tower-test",
22622262
"tracing",
22632263
]
@@ -2281,7 +2281,7 @@ dependencies = [
22812281
"pin-project",
22822282
"prost 0.13.5",
22832283
"tonic",
2284-
"tower 0.4.13",
2284+
"tower 0.5.2",
22852285
"tracing",
22862286
]
22872287

@@ -2299,7 +2299,7 @@ dependencies = [
22992299
"linkerd-stack",
23002300
"rand 0.9.0",
23012301
"tokio",
2302-
"tower 0.4.13",
2302+
"tower 0.5.2",
23032303
"tracing",
23042304
]
23052305

@@ -2364,7 +2364,7 @@ version = "0.1.0"
23642364
dependencies = [
23652365
"futures",
23662366
"linkerd-error",
2367-
"tower 0.4.13",
2367+
"tower 0.5.2",
23682368
]
23692369

23702370
[[package]]
@@ -2379,7 +2379,7 @@ dependencies = [
23792379
"linkerd-stack",
23802380
"tokio",
23812381
"tokio-stream",
2382-
"tower 0.4.13",
2382+
"tower 0.5.2",
23832383
"tracing",
23842384
]
23852385

@@ -2422,7 +2422,7 @@ dependencies = [
24222422
"thiserror 2.0.12",
24232423
"tokio",
24242424
"tokio-test",
2425-
"tower 0.4.13",
2425+
"tower 0.5.2",
24262426
"tower-test",
24272427
"tracing",
24282428
"try-lock",
@@ -2457,7 +2457,7 @@ dependencies = [
24572457
"linkerd-proxy-core",
24582458
"pin-project",
24592459
"thiserror 2.0.12",
2460-
"tower 0.4.13",
2460+
"tower 0.5.2",
24612461
"tracing",
24622462
]
24632463

@@ -2496,7 +2496,7 @@ dependencies = [
24962496
"tokio",
24972497
"tokio-test",
24982498
"tonic",
2499-
"tower 0.4.13",
2499+
"tower 0.5.2",
25002500
"tracing",
25012501
"x509-parser",
25022502
]
@@ -2528,7 +2528,7 @@ dependencies = [
25282528
"thiserror 2.0.12",
25292529
"tokio",
25302530
"tonic",
2531-
"tower 0.4.13",
2531+
"tower 0.5.2",
25322532
"tracing",
25332533
]
25342534

@@ -2544,7 +2544,7 @@ dependencies = [
25442544
"pin-project",
25452545
"rand 0.9.0",
25462546
"tokio",
2547-
"tower 0.4.13",
2547+
"tower 0.5.2",
25482548
]
25492549

25502550
[[package]]
@@ -2575,7 +2575,7 @@ dependencies = [
25752575
"tokio",
25762576
"tokio-stream",
25772577
"tokio-test",
2578-
"tower 0.4.13",
2578+
"tower 0.5.2",
25792579
"tower-test",
25802580
"tracing",
25812581
]
@@ -2587,7 +2587,7 @@ dependencies = [
25872587
"futures",
25882588
"linkerd-error",
25892589
"linkerd-stack",
2590-
"tower 0.4.13",
2590+
"tower 0.5.2",
25912591
"tracing",
25922592
]
25932593

@@ -2629,7 +2629,7 @@ dependencies = [
26292629
"tokio",
26302630
"tokio-stream",
26312631
"tonic",
2632-
"tower 0.4.13",
2632+
"tower 0.5.2",
26332633
"tracing",
26342634
]
26352635

@@ -2654,7 +2654,7 @@ dependencies = [
26542654
"tokio",
26552655
"tokio-test",
26562656
"tokio-util",
2657-
"tower 0.4.13",
2657+
"tower 0.5.2",
26582658
"tower-test",
26592659
"tracing",
26602660
]
@@ -2667,7 +2667,7 @@ dependencies = [
26672667
"parking_lot",
26682668
"tokio",
26692669
"tokio-test",
2670-
"tower 0.4.13",
2670+
"tower 0.5.2",
26712671
"tower-test",
26722672
]
26732673

@@ -2678,7 +2678,7 @@ dependencies = [
26782678
"futures",
26792679
"linkerd-error",
26802680
"linkerd-stack",
2681-
"tower 0.4.13",
2681+
"tower 0.5.2",
26822682
"tracing",
26832683
]
26842684

@@ -2699,7 +2699,7 @@ dependencies = [
26992699
"pin-project",
27002700
"thiserror 2.0.12",
27012701
"tokio",
2702-
"tower 0.4.13",
2702+
"tower 0.5.2",
27032703
"tracing",
27042704
"untrusted",
27052705
]
@@ -2765,7 +2765,7 @@ dependencies = [
27652765
"linkerd-stack",
27662766
"rand 0.8.5",
27672767
"thiserror 1.0.69",
2768-
"tower 0.4.13",
2768+
"tower 0.5.2",
27692769
"tracing",
27702770
]
27712771

@@ -4282,10 +4282,14 @@ checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
42824282
dependencies = [
42834283
"futures-core",
42844284
"futures-util",
4285+
"indexmap 2.8.0",
42854286
"pin-project-lite",
42864287
"sync_wrapper",
4288+
"tokio",
4289+
"tokio-util",
42874290
"tower-layer",
42884291
"tower-service",
4292+
"tracing",
42894293
]
42904294

42914295
[[package]]

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ tokio-rustls = { version = "0.26", default-features = false, features = [
122122
] }
123123
tonic = { version = "0.12", default-features = false }
124124
tonic-build = { version = "0.12", default-features = false }
125-
tower = { version = "0.4", default-features = false }
125+
tower = { version = "0.5", default-features = false }
126126
tower-service = { version = "0.3" }
127127
tower-test = { version = "0.4" }
128128

linkerd/app/gateway/src/server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ impl Gateway {
6464
SessionProtocol::Http1 => http::Variant::Http1,
6565
SessionProtocol::Http2 => http::Variant::H2,
6666
};
67-
return Ok(svc::Either::A(Http { parent, version }));
67+
return Ok(svc::Either::Left(Http { parent, version }));
6868
}
6969

70-
Ok(svc::Either::B(Opaq(parent)))
70+
Ok(svc::Either::Right(Opaq(parent)))
7171
},
7272
opaq,
7373
)

linkerd/app/inbound/src/accept.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ impl<N> Inbound<N> {
5353
move |t: T| -> Result<_, Error> {
5454
let addr: OrigDstAddr = t.param();
5555
if addr.port() == proxy_port {
56-
return Ok(svc::Either::B(t));
56+
return Ok(svc::Either::Right(t));
5757
}
5858

5959
let policy = policies.get_policy(addr);
6060
tracing::debug!(policy = ?&*policy.borrow(), "Accepted");
61-
Ok(svc::Either::A(Accept {
61+
Ok(svc::Either::Left(Accept {
6262
client_addr: t.param(),
6363
orig_dst_addr: addr,
6464
policy,

0 commit comments

Comments
 (0)