Skip to content

Commit a69c3f5

Browse files
committed
mark experiment as failed when an error is encountered
1 parent 58f9dbd commit a69c3f5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/experiments.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ impl Experiment {
227227
)?;
228228
self.started_at = Some(now);
229229
// Check if the old status was "running" and there is no completed date
230-
} else if self.status == Status::Running && self.completed_at.is_none() {
230+
} else if self.status == Status::Running
231+
&& self.completed_at.is_none()
232+
&& status != Status::Failed
233+
{
231234
db.execute(
232235
"UPDATE experiments SET completed_at = ?1 WHERE name = ?2;",
233236
&[&now, &self.name.as_str()],

src/server/routes/agent.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,28 @@ fn endpoint_error(
162162
data: Arc<Data>,
163163
auth: AuthDetails,
164164
) -> Fallible<Response<Body>> {
165-
let ex = Experiment::run_by(&data.db, &Assignee::Agent(auth.name.clone()))?
165+
let mut ex = Experiment::run_by(&data.db, &Assignee::Agent(auth.name.clone()))?
166166
.ok_or_else(|| err_msg("no experiment run by this agent"))?;
167167

168+
ex.set_status(&data.db, Status::Failed)?;
169+
168170
if let Some(ref github_issue) = ex.github_issue {
169171
Message::new()
170172
.line(
171-
"exclamation",
173+
"rotating_light",
172174
format!(
173-
"Experiment **`{}`** running on agent `{}` has encountered an error",
174-
ex.name, auth.name,
175+
"Experiment **`{}`** has encountered an error: {}",
176+
ex.name,
177+
error.get("error").unwrap_or(&String::from("no error")),
175178
),
176179
)
177180
.line(
181+
"hammer_and_wrench",
182+
"If the error is fixed use the `retry` command.",
183+
)
184+
.note(
178185
"sos",
179-
format!("caused by: {}", error.get("error").unwrap(),),
186+
"Can someone from the infra team check in on this? @rust-lang/infra",
180187
)
181188
.send(&github_issue.api_url, &data)?;
182189
}

0 commit comments

Comments
 (0)