Skip to content

Commit 621ea19

Browse files
authored
build(deps): update linkerd2-proxy-api to v0.15.0 (#3377)
To update to the latest proxy API release, we also update the opaque stack filter types. Signed-off-by: Zahari Dichev <[email protected]>
1 parent ca4612d commit 621ea19

File tree

7 files changed

+80
-82
lines changed

7 files changed

+80
-82
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,8 +2587,9 @@ dependencies = [
25872587

25882588
[[package]]
25892589
name = "linkerd2-proxy-api"
2590-
version = "0.14.0"
2591-
source = "git+https://github.com/linkerd/linkerd2-proxy-api.git?branch=main#6c316cc41a3a0e194a70f22b5698ec21ce245e99"
2590+
version = "0.15.0"
2591+
source = "registry+https://github.com/rust-lang/crates.io-index"
2592+
checksum = "a4682c00263191a5bfa4fbe64f6d80b22ff2b49aaa294da5aac062f5abc6eb9e"
25922593
dependencies = [
25932594
"h2",
25942595
"http",

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ debug = 1
9191
lto = true
9292

9393
[workspace.dependencies]
94-
#linkerd2-proxy-api = "0.14.0"
95-
linkerd2-proxy-api = { git = "https://github.com/linkerd/linkerd2-proxy-api.git", branch = "main" }
94+
linkerd2-proxy-api = "0.15.0"
95+
# linkerd2-proxy-api = { git = "https://github.com/linkerd/linkerd2-proxy-api.git", branch = "main" }

linkerd/app/integration/src/policy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,18 @@ pub fn outbound_default_opaque_route(dst: impl ToString) -> outbound::OpaqueRout
162162
metadata: Some(api::meta::Metadata {
163163
kind: Some(api::meta::metadata::Kind::Default("default".to_string())),
164164
}),
165-
error: None,
166165
rules: vec![outbound::opaque_route::Rule {
167166
backends: Some(opaque_route::Distribution {
168167
kind: Some(distribution::Kind::FirstAvailable(
169168
distribution::FirstAvailable {
170169
backends: vec![opaque_route::RouteBackend {
171170
backend: Some(backend(dst)),
172-
invalid: None,
171+
filters: Vec::new(),
173172
}],
174173
},
175174
)),
176175
}),
176+
filters: Vec::new(),
177177
}],
178178
}
179179
}

linkerd/app/outbound/src/opaq/logical/route/filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ where
1010
let filters: &[opaq::Filter] = &t.param();
1111
if let Some(filter) = filters.iter().next() {
1212
match filter {
13-
opaq::Filter::ForbiddenRoute => {
13+
opaq::Filter::Forbidden => {
1414
return Err(errors::TCPForbiddenRoute.into());
1515
}
1616

17-
opaq::Filter::InvalidBackend(message) => {
17+
opaq::Filter::Invalid(message) => {
1818
return Err(errors::TCPInvalidBackend(message.clone()).into());
1919
}
2020

linkerd/app/outbound/src/tls/logical/route/filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ where
1010
let filters: &[tls::Filter] = &t.param();
1111
if let Some(filter) = filters.iter().next() {
1212
match filter {
13-
tls::Filter::ForbiddenRoute => {
13+
tls::Filter::Forbidden => {
1414
return Err(errors::TLSForbiddenRoute.into());
1515
}
1616

17-
tls::Filter::InvalidBackend(message) => {
17+
tls::Filter::Invalid(message) => {
1818
return Err(errors::TLSInvalidBackend(message.clone()).into());
1919
}
2020

linkerd/proxy/client-policy/src/opaq.rs

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub struct NonIoErrors;
1414

1515
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1616
pub enum Filter {
17-
ForbiddenRoute,
18-
InvalidBackend(std::sync::Arc<str>),
17+
Forbidden,
18+
Invalid(std::sync::Arc<str>),
1919
InternalError(&'static str),
2020
}
2121

@@ -31,15 +31,11 @@ pub(crate) mod proto {
3131
use super::*;
3232
use crate::{
3333
proto::{BackendSet, InvalidBackend, InvalidDistribution, InvalidMeta},
34-
Backend, Meta, RouteBackend, RouteDistribution,
34+
Meta, RouteBackend, RouteDistribution,
3535
};
3636
use linkerd2_proxy_api::outbound::{self, opaque_route};
37-
38-
use once_cell::sync::Lazy;
3937
use std::sync::Arc;
4038

41-
pub(crate) static NO_FILTERS: Lazy<Arc<[Filter]>> = Lazy::new(|| Arc::new([]));
42-
4339
#[derive(Debug, thiserror::Error)]
4440
pub enum InvalidOpaqueRoute {
4541
#[error("invalid route metadata: {0}")]
@@ -48,6 +44,9 @@ pub(crate) mod proto {
4844
#[error("invalid distribution: {0}")]
4945
Distribution(#[from] InvalidDistribution),
5046

47+
#[error("invalid filter: {0}")]
48+
Filter(#[from] InvalidFilter),
49+
5150
/// Note: this restriction may be removed in the future, if a way of
5251
/// actually matching rules for opaque routes is added.
5352
#[error("an opaque route must have exactly one rule, but {0} were provided")]
@@ -65,6 +64,15 @@ pub(crate) mod proto {
6564
Missing(&'static str),
6665
}
6766

67+
#[derive(Debug, thiserror::Error)]
68+
pub enum InvalidFilter {
69+
#[error("invalid route error kind: {0}")]
70+
InvalidRouteErrorKind(i32),
71+
72+
#[error("missing filter kind")]
73+
Missing,
74+
}
75+
6876
pub(crate) fn fill_route_backends(rts: Option<&Route>, set: &mut BackendSet) {
6977
if let Some(Route { policy, .. }) = rts {
7078
policy.distribution.fill_backends(set);
@@ -84,11 +92,7 @@ pub(crate) mod proto {
8492
}
8593

8694
fn try_route(
87-
outbound::OpaqueRoute {
88-
metadata,
89-
rules,
90-
error,
91-
}: outbound::OpaqueRoute,
95+
outbound::OpaqueRoute { metadata, rules }: outbound::OpaqueRoute,
9296
) -> Result<Route, InvalidOpaqueRoute> {
9397
let meta = Arc::new(
9498
metadata
@@ -104,23 +108,22 @@ pub(crate) mod proto {
104108
}
105109

106110
let rule = rules.first().cloned().expect("already checked");
107-
let policy = try_rule(&meta, rule, error)?;
111+
let policy = try_rule(&meta, rule)?;
108112
Ok(Route { policy })
109113
}
110114

111115
fn try_rule(
112116
meta: &Arc<Meta>,
113-
opaque_route::Rule { backends }: opaque_route::Rule,
114-
route_error: Option<opaque_route::RouteError>,
117+
opaque_route::Rule { backends, filters }: opaque_route::Rule,
115118
) -> Result<Policy, InvalidOpaqueRoute> {
116119
let distribution = backends
117120
.ok_or(InvalidOpaqueRoute::Missing("distribution"))?
118121
.try_into()?;
119122

120-
let filters = match route_error {
121-
Some(e) => Arc::new([e.into()]),
122-
None => NO_FILTERS.clone(),
123-
};
123+
let filters = filters
124+
.into_iter()
125+
.map(Filter::try_from)
126+
.collect::<Result<Arc<[_]>, _>>()?;
124127

125128
Ok(Policy {
126129
meta: meta.clone(),
@@ -175,30 +178,24 @@ pub(crate) mod proto {
175178
impl TryFrom<opaque_route::RouteBackend> for RouteBackend<Filter> {
176179
type Error = InvalidBackend;
177180
fn try_from(
178-
opaque_route::RouteBackend { backend, invalid }: opaque_route::RouteBackend,
179-
) -> Result<Self, Self::Error> {
181+
opaque_route::RouteBackend { backend, filters }: opaque_route::RouteBackend,
182+
) -> Result<RouteBackend<Filter>, InvalidBackend> {
180183
let backend = backend.ok_or(InvalidBackend::Missing("backend"))?;
181-
182-
let backend = Backend::try_from(backend)?;
183-
184-
let filters = match invalid {
185-
Some(invalid) => Arc::new([invalid.into()]),
186-
None => NO_FILTERS.clone(),
187-
};
188-
189-
Ok(RouteBackend { filters, backend })
184+
RouteBackend::try_from_proto(backend, filters)
190185
}
191186
}
192187

193-
impl From<opaque_route::RouteError> for Filter {
194-
fn from(_: opaque_route::RouteError) -> Self {
195-
Self::ForbiddenRoute
196-
}
197-
}
188+
impl TryFrom<opaque_route::Filter> for Filter {
189+
type Error = InvalidFilter;
190+
191+
fn try_from(filter: opaque_route::Filter) -> Result<Self, Self::Error> {
192+
use linkerd2_proxy_api::opaque_route::Invalid;
193+
use opaque_route::filter::Kind;
198194

199-
impl From<opaque_route::route_backend::Invalid> for Filter {
200-
fn from(ib: opaque_route::route_backend::Invalid) -> Self {
201-
Self::InvalidBackend(ib.message.into())
195+
match filter.kind.ok_or(InvalidFilter::Missing)? {
196+
Kind::Invalid(Invalid { message }) => Ok(Filter::Invalid(message.into())),
197+
Kind::Forbidden(_) => Ok(Filter::Forbidden),
198+
}
202199
}
203200
}
204201
}

linkerd/proxy/client-policy/src/tls.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub struct Tls {
1212

1313
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1414
pub enum Filter {
15-
ForbiddenRoute,
16-
InvalidBackend(Arc<str>),
15+
Forbidden,
16+
Invalid(Arc<str>),
1717
InternalError(&'static str),
1818
}
1919

@@ -42,16 +42,12 @@ pub(crate) mod proto {
4242
use super::*;
4343
use crate::{
4444
proto::{BackendSet, InvalidBackend, InvalidDistribution, InvalidMeta},
45-
Backend, Meta, RouteBackend, RouteDistribution,
45+
Meta, RouteBackend, RouteDistribution,
4646
};
4747
use linkerd2_proxy_api::outbound::{self, tls_route};
4848
use linkerd_tls_route::sni::proto::InvalidSniMatch;
49-
50-
use once_cell::sync::Lazy;
5149
use std::sync::Arc;
5250

53-
pub(crate) static NO_FILTERS: Lazy<Arc<[Filter]>> = Lazy::new(|| Arc::new([]));
54-
5551
#[derive(Debug, thiserror::Error)]
5652
pub enum InvalidTlsRoute {
5753
#[error("invalid sni match: {0}")]
@@ -63,6 +59,9 @@ pub(crate) mod proto {
6359
#[error("invalid distribution: {0}")]
6460
Distribution(#[from] InvalidDistribution),
6561

62+
#[error("invalid filter: {0}")]
63+
Filter(#[from] InvalidFilter),
64+
6665
/// Note: this restriction may be removed in the future, if a way of
6766
/// actually matching rules for TLS routes is added.
6867
#[error("a TLS route must have exactly one rule, but {0} were provided")]
@@ -75,6 +74,15 @@ pub(crate) mod proto {
7574
Missing(&'static str),
7675
}
7776

77+
#[derive(Debug, thiserror::Error)]
78+
pub enum InvalidFilter {
79+
#[error("invalid route error kind: {0}")]
80+
InvalidRouteErrorKind(i32),
81+
82+
#[error("missing filter kind")]
83+
Missing,
84+
}
85+
7886
impl TryFrom<outbound::proxy_protocol::Tls> for Tls {
7987
type Error = InvalidTlsRoute;
8088
fn try_from(proto: outbound::proxy_protocol::Tls) -> Result<Self, Self::Error> {
@@ -101,7 +109,6 @@ pub(crate) mod proto {
101109
rules,
102110
snis,
103111
metadata,
104-
error,
105112
} = proto;
106113
let meta = Arc::new(
107114
metadata
@@ -123,7 +130,7 @@ pub(crate) mod proto {
123130

124131
let policy = rules
125132
.into_iter()
126-
.map(|rule| try_rule(&meta, rule, error.clone()))
133+
.map(|rule| try_rule(&meta, rule))
127134
.next()
128135
.ok_or(InvalidTlsRoute::OnlyOneRule(0))??;
129136

@@ -132,17 +139,16 @@ pub(crate) mod proto {
132139

133140
fn try_rule(
134141
meta: &Arc<Meta>,
135-
tls_route::Rule { backends }: tls_route::Rule,
136-
route_error: Option<tls_route::RouteError>,
142+
tls_route::Rule { backends, filters }: tls_route::Rule,
137143
) -> Result<Policy, InvalidTlsRoute> {
138144
let distribution = backends
139145
.ok_or(InvalidTlsRoute::Missing("distribution"))?
140146
.try_into()?;
141147

142-
let filters = match route_error {
143-
Some(e) => Arc::new([e.into()]),
144-
None => NO_FILTERS.clone(),
145-
};
148+
let filters = filters
149+
.into_iter()
150+
.map(Filter::try_from)
151+
.collect::<Result<Arc<[_]>, _>>()?;
146152

147153
Ok(Policy {
148154
meta: meta.clone(),
@@ -197,30 +203,24 @@ pub(crate) mod proto {
197203
impl TryFrom<tls_route::RouteBackend> for RouteBackend<Filter> {
198204
type Error = InvalidBackend;
199205
fn try_from(
200-
tls_route::RouteBackend { backend, invalid }: tls_route::RouteBackend,
201-
) -> Result<Self, Self::Error> {
206+
tls_route::RouteBackend { backend, filters }: tls_route::RouteBackend,
207+
) -> Result<RouteBackend<Filter>, InvalidBackend> {
202208
let backend = backend.ok_or(InvalidBackend::Missing("backend"))?;
203-
204-
let backend = Backend::try_from(backend)?;
205-
206-
let filters = match invalid {
207-
Some(invalid) => Arc::new([invalid.into()]),
208-
None => NO_FILTERS.clone(),
209-
};
210-
211-
Ok(RouteBackend { filters, backend })
209+
RouteBackend::try_from_proto(backend, filters)
212210
}
213211
}
214212

215-
impl From<tls_route::RouteError> for Filter {
216-
fn from(_: tls_route::RouteError) -> Self {
217-
Self::ForbiddenRoute
218-
}
219-
}
213+
impl TryFrom<tls_route::Filter> for Filter {
214+
type Error = InvalidFilter;
215+
216+
fn try_from(filter: tls_route::Filter) -> Result<Self, Self::Error> {
217+
use linkerd2_proxy_api::opaque_route::Invalid;
218+
use tls_route::filter::Kind;
220219

221-
impl From<tls_route::route_backend::Invalid> for Filter {
222-
fn from(ib: tls_route::route_backend::Invalid) -> Self {
223-
Self::InvalidBackend(ib.message.into())
220+
match filter.kind.ok_or(InvalidFilter::Missing)? {
221+
Kind::Invalid(Invalid { message }) => Ok(Filter::Invalid(message.into())),
222+
Kind::Forbidden(_) => Ok(Filter::Forbidden),
223+
}
224224
}
225225
}
226226
}

0 commit comments

Comments
 (0)