Skip to content

Commit 3e0b88b

Browse files
NathanFlurryMasterPtato
authored andcommitted
fix(pegboard): continue exporting metrics even if fetching actor fails
1 parent 4527a1a commit 3e0b88b

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

packages/edge/api/actor/src/assert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub async fn actor_for_env(
1616
.op(pegboard::ops::actor::get::Input {
1717
actor_ids: vec![actor_id],
1818
endpoint_type,
19+
allow_errors: false,
1920
})
2021
.await?;
2122
let actor = unwrap_with!(actors_res.actors.into_iter().next(), ACTOR_NOT_FOUND);

packages/edge/api/actor/src/route/actors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async fn get_inner(
5656
.op(pegboard::ops::actor::get::Input {
5757
actor_ids: vec![actor_id],
5858
endpoint_type: query.endpoint_type.map(ApiInto::api_into),
59+
allow_errors: false,
5960
})
6061
.await?;
6162
let actor = unwrap_with!(actors_res.actors.first(), ACTOR_NOT_FOUND);
@@ -255,6 +256,7 @@ pub async fn create(
255256
.op(pegboard::ops::actor::get::Input {
256257
actor_ids: vec![actor_id],
257258
endpoint_type: query.endpoint_type.map(ApiInto::api_into),
259+
allow_errors: false,
258260
})
259261
.await?;
260262
let actor = unwrap_with!(actors_res.actors.first(), ACTOR_NOT_FOUND);
@@ -584,6 +586,7 @@ async fn list_actors_inner(
584586
.global_endpoint_type
585587
.endpoint_type
586588
.map(ApiInto::api_into),
589+
allow_errors: false,
587590
})
588591
.await?;
589592
actors_res.actors.sort_by_key(|x| -x.create_ts);

packages/edge/services/pegboard/src/ops/actor/get.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub struct Input {
7272
/// If the datacenter has a parent hostname, will use hostname endpoint. Otherwise, will use
7373
/// path endpoint.
7474
pub endpoint_type: Option<crate::types::EndpointType>,
75+
76+
pub allow_errors: bool,
7577
}
7678

7779
#[derive(Debug)]
@@ -192,6 +194,17 @@ pub async fn pegboard_actor_get(ctx: &OperationCtx, input: &Input) -> GlobalResu
192194
}))
193195
})
194196
.buffer_unordered(1024)
197+
.map(|x| match x {
198+
Ok(x) => Ok(x),
199+
Err(err) => {
200+
if input.allow_errors {
201+
tracing::warn!(?err, "failed to fetch actor");
202+
Ok(None)
203+
} else {
204+
Err(err)
205+
}
206+
}
207+
})
195208
.try_filter_map(|x| std::future::ready(Ok(x)))
196209
.try_collect::<Vec<_>>()
197210
.await?;

packages/edge/services/pegboard/standalone/usage-metrics-publish/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub async fn run_from_env(
7575
.op(pegboard::ops::actor::get::Input {
7676
actor_ids,
7777
endpoint_type: None,
78+
allow_errors: true,
7879
})
7980
.await?;
8081

0 commit comments

Comments
 (0)