Skip to content

Commit 0d226cb

Browse files
committed
specify target service hostname instead of address for waypoint destination
1 parent 8fda410 commit 0d226cb

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/proxy/outbound.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ impl OutboundConnection {
475475
// bytes without trying to interpret it.
476476
//
477477
// NOTE: when connecting through an E/W gateway, regardless of whether there is
478-
// a waypoint or not, we always use service hostname and the service port. It's
479-
// somewhat different from how regular HBONE works, so I'm calling it out here.
478+
// a waypoint or not, we always use service hostname and the service port.
479+
// This is also the case for service-addressed waypoint traffic (see build_request).
480480
async fn build_request_through_gateway(
481481
&self,
482482
source: Arc<Workload>,
@@ -578,7 +578,10 @@ impl OutboundConnection {
578578
return Ok(Request {
579579
protocol: OutboundProtocol::HBONE,
580580
source: source_workload,
581-
hbone_target_destination: Some(HboneAddress::SocketAddr(target)),
581+
hbone_target_destination: Some(HboneAddress::SvcHostname(
582+
target_service.hostname.clone(),
583+
target.port(),
584+
)),
582585
actual_destination_workload: Some(waypoint.workload),
583586
intended_destination_service: Some(ServiceDescription::from(&*target_service)),
584587
actual_destination,
@@ -1515,6 +1518,7 @@ mod tests {
15151518
"127.0.0.1",
15161519
"127.0.0.3:80",
15171520
XdsAddressType::Service(XdsService {
1521+
hostname: "example.com".to_string(),
15181522
addresses: vec![XdsNetworkAddress {
15191523
network: "".to_string(),
15201524
address: vec![127, 0, 0, 3],
@@ -1534,10 +1538,10 @@ mod tests {
15341538
}),
15351539
..Default::default()
15361540
}),
1537-
// Should use the waypoint
1541+
// Should use the waypoint with service hostname as authority
15381542
Some(ExpectedRequest {
15391543
protocol: OutboundProtocol::HBONE,
1540-
hbone_destination: "127.0.0.3:80",
1544+
hbone_destination: "example.com:80",
15411545
destination: "127.0.0.10:15008",
15421546
}),
15431547
)
@@ -1912,7 +1916,7 @@ mod tests {
19121916
Some(ExpectedRequest {
19131917
protocol: OutboundProtocol::HBONE,
19141918
destination: "127.0.0.10:15008",
1915-
hbone_destination: "1.2.3.4:80",
1919+
hbone_destination: "example.com:80",
19161920
}),
19171921
)
19181922
.await;

tests/namespaced.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ mod namespaced {
447447

448448
let sent = format!("{REQ_SIZE}");
449449
let recv = format!("{HBONE_REQ_SIZE}");
450-
let hbone_addr = format!("{TEST_VIP}:80");
450+
let hbone_addr = "service.default.svc.cluster.local:80";
451451
let dst_addr = format!("{waypoint_ip}:15008");
452452
let want = HashMap::from([
453453
("scope", "access"),
454454
("src.workload", "client"),
455455
("dst.workload", "waypoint"),
456-
("dst.hbone_addr", &hbone_addr),
456+
("dst.hbone_addr", hbone_addr),
457457
("dst.addr", &dst_addr),
458458
("bytes_sent", &sent),
459459
("bytes_recv", &recv),

0 commit comments

Comments
 (0)