Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/tower-runtime/src/auto_cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mod tests {
}

async fn status(&self) -> Result<Status, Error> {
Ok(*self.status.lock().await)
Ok(self.status.lock().await.clone())
}
}

Expand Down
14 changes: 11 additions & 3 deletions crates/tower-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,26 @@ pub struct Output {
pub line: String,
}

#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub enum Status {
None,
Running,
Exited,
Crashed { code: i32 },
Crashed {
code: i32,
},
/// A platform-level failure (not the user's app). For example, pod scheduling
/// failures, image pull errors, or other infrastructure issues.
Failed {
error_code: Option<String>,
error_message: Option<String>,
},
}

impl Status {
/// Returns true if this status represents a terminal state (run is finished)
pub fn is_terminal(&self) -> bool {
matches!(self, Status::Exited | Status::Crashed { .. })
matches!(self, Status::Exited | Status::Crashed { .. } | Status::Failed { .. })
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/tower-runtime/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl App for LocalApp {
async fn status(&self) -> Result<Status, Error> {
let mut status = self.status.lock().await;

if let Some(status) = *status {
if let Some(status) = status.clone() {
Ok(status)
} else {
let mut waiter = self.waiter.lock().await;
Expand All @@ -384,7 +384,7 @@ impl App for LocalApp {
Ok(Status::Exited)
} else {
let next_status = Status::Crashed { code: t };
*status = Some(next_status);
*status = Some(next_status.clone());
Ok(next_status)
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/tower-runtime/tests/local_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,8 @@ async fn test_abort_on_dependency_installation_failure() {
Status::None => {
panic!("App should have a status");
}
Status::Failed { .. } => {
panic!("App should have crashed, not failed with a platform error");
}
}
}
Loading