Skip to content

Commit 100bf59

Browse files
MasterPtatoNathanFlurry
authored andcommitted
fix(pegboard): increase signal timeout, add check for actor exit
1 parent 6f7c837 commit 100bf59

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

packages/edge/infra/client/manager/src/actor/mod.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod setup;
2222
/// How often to check for a PID when one is not present and a stop command was received.
2323
const STOP_PID_INTERVAL: Duration = std::time::Duration::from_millis(250);
2424
/// How many times to check for a PID when a stop command was received.
25-
const STOP_PID_RETRIES: usize = 32;
25+
const STOP_PID_RETRIES: usize = 1024;
2626

2727
pub struct Actor {
2828
actor_id: Uuid,
@@ -377,16 +377,31 @@ impl Actor {
377377

378378
// Signal command might be sent before the actor has a runner. This loop waits for the runner to start
379379
let runner_guard = loop {
380-
let runner_guard = self.runner.lock().await;
381-
if runner_guard.is_some() {
382-
break Some(runner_guard);
380+
{
381+
let runner_guard = self.runner.lock().await;
382+
if runner_guard.is_some() {
383+
break Some(runner_guard);
384+
}
383385
}
384386

385-
tracing::warn!(
386-
actor_id=?self.actor_id,
387-
generation=?self.generation,
388-
"waiting for pid to signal actor",
389-
);
387+
if *self.exited.lock().await {
388+
tracing::warn!(
389+
actor_id=?self.actor_id,
390+
generation=?self.generation,
391+
"actor exited before PID was set, ignoring signal",
392+
);
393+
394+
break None;
395+
}
396+
397+
// Progress log
398+
if i % 10 == 0 {
399+
tracing::warn!(
400+
actor_id=?self.actor_id,
401+
generation=?self.generation,
402+
"waiting for PID to signal actor",
403+
);
404+
}
390405

391406
if i > STOP_PID_RETRIES {
392407
tracing::error!(
@@ -396,6 +411,7 @@ impl Actor {
396411

397412
break None;
398413
}
414+
399415
i += 1;
400416

401417
tokio::time::sleep(STOP_PID_INTERVAL).await;

packages/edge/infra/client/manager/src/ctx.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,7 @@ impl Ctx {
412412
protocol::ToClient::PrewarmImage {
413413
image_id,
414414
image_artifact_url_stub,
415-
} => {
416-
let self2 = self.clone();
417-
418-
tokio::spawn(async move {
419-
utils::prewarm_image(&self2, image_id, &image_artifact_url_stub).await
420-
});
421-
}
415+
} => utils::prewarm_image(&self, image_id, &image_artifact_url_stub),
422416
}
423417

424418
Ok(())

packages/edge/infra/client/manager/src/utils/mod.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{
22
hash::{DefaultHasher, Hasher},
33
path::Path,
44
result::Result::{Err, Ok},
5+
sync::Arc,
56
time::{self, Duration},
67
};
78

@@ -395,17 +396,22 @@ pub async fn fetch_image_stream(
395396
bail!("artifact url could not be resolved");
396397
}
397398

398-
pub async fn prewarm_image(ctx: &Ctx, image_id: Uuid, image_artifact_url_stub: &str) {
399+
pub fn prewarm_image(ctx: &Arc<Ctx>, image_id: Uuid, image_artifact_url_stub: &str) {
399400
// Log full URL for prewarm operation
400401
let prewarm_url = format!("{}/{}", image_artifact_url_stub, image_id);
401402
tracing::info!(?image_id, %prewarm_url, "prewarming image");
402403

403-
match fetch_image_stream(ctx, image_id, image_artifact_url_stub, None).await {
404-
Ok(_) => tracing::info!(?image_id, %prewarm_url, "prewarm complete"),
405-
Err(_) => tracing::warn!(
406-
?image_id,
407-
%prewarm_url,
408-
"prewarm failed, artifact url could not be resolved"
409-
),
410-
}
404+
let ctx = ctx.clone();
405+
let image_artifact_url_stub = image_artifact_url_stub.to_string();
406+
407+
tokio::spawn(async move {
408+
match fetch_image_stream(&ctx, image_id, &image_artifact_url_stub, None).await {
409+
Ok(_) => tracing::info!(?image_id, %prewarm_url, "prewarm complete"),
410+
Err(_) => tracing::warn!(
411+
?image_id,
412+
%prewarm_url,
413+
"prewarm failed, artifact url could not be resolved"
414+
),
415+
}
416+
});
411417
}

0 commit comments

Comments
 (0)