Skip to content

Commit

Permalink
test: test dst_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-personio committed Sep 14, 2023
1 parent f8be66a commit a97d650
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions linkerd/app/integration/src/tests/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@ mod outbound_dst_labels {
let (
Fixture {
client,
metrics: _metrics,
metrics,
proxy: _proxy,
_profile,
dst_tx,
labels: _labels,
labels,
..
},
addr,
Expand All @@ -647,6 +647,18 @@ mod outbound_dst_labels {

info!("client.get(/)");
assert_eq!(client.get("/").await, "hello");

let labels = labels
.label("dst_addr_label", "foo")
.label("dst_set_label", "bar");

for &metric in &[
"request_total",
"response_total",
"response_latency_ms_count",
] {
labels.metric(metric).assert_in(&metrics).await;
}
}
}

Expand Down
10 changes: 8 additions & 2 deletions linkerd/app/outbound/src/http/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,24 @@ where
T: svc::Param<Option<http::uri::Authority>>,
{
fn param(&self) -> OutboundEndpointLabels {
let arc_labels = self.metadata.labels();

Check failure on line 345 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / clippy

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `std::sync::Arc<std::collections::BTreeMap<std::string::String, std::string::String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `std::collections::BTreeMap<std::string::String, std::string::String>`

Check failure on line 345 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / docs

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 345 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (amd64, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 345 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (arm64, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 345 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (arm, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`
// self.metadata.labels() could return Err in some cases
// if that case the dst_labels won't carry any value
let mut dst_labels = match Arc::try_unwrap(self.metadata.labels()) {
let mut dst_labels = match Arc::try_unwrap(arc_labels) {

Check failure on line 348 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / clippy

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `std::sync::Arc<std::collections::BTreeMap<std::string::String, std::string::String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `std::collections::BTreeMap<std::string::String, std::string::String>`

Check failure on line 348 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / docs

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 348 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (amd64, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 348 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (arm64, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 348 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (arm, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`
Ok(result) => result,
Err(_e) => BTreeMap::new(),
};

dst_labels.remove("pod");
dst_labels.remove("pod_template_hash");

let label_iterator = match dst_labels.is_empty() {
true => dst_labels.iter(),
false => arc_labels.iter()

Check failure on line 358 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / clippy

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `std::sync::Arc<std::collections::BTreeMap<std::string::String, std::string::String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `std::collections::BTreeMap<std::string::String, std::string::String>`

Check failure on line 358 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / docs

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 358 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (amd64, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 358 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (arm64, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`

Check failure on line 358 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / package (arm, gnu)

error[E0382]: borrow of moved value: `arc_labels` --> linkerd/app/outbound/src/http/concrete.rs:358:22 | 345 | let arc_labels = self.metadata.labels(); | ---------- move occurs because `arc_labels` has type `Arc<BTreeMap<String, String>>`, which does not implement the `Copy` trait ... 348 | let mut dst_labels = match Arc::try_unwrap(arc_labels) { | ---------- value moved here ... 358 | false => arc_labels.iter() | ^^^^^^^^^^^^^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `BTreeMap<String, String>`
};

OutboundEndpointLabels {
labels: prefix_labels("dst", dst_labels.iter()),
labels: prefix_labels("dst", label_iterator),
server_id: self.param(),
}
}
Expand Down

0 comments on commit a97d650

Please sign in to comment.