evaluate: handle evaluation errors, and posting errors while posting eval errors better
This commit is contained in:
parent
00478e9dee
commit
a1e8dcc1e5
1 changed files with 35 additions and 40 deletions
|
@ -202,52 +202,47 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worker_actions(&mut self) -> worker::Actions {
|
fn worker_actions(&mut self) -> worker::Actions {
|
||||||
let eval_result = self.evaluate_job();
|
let eval_result = self.evaluate_job().map_err(|eval_error| match eval_error {
|
||||||
if let Ok(actions) = eval_result {
|
// Handle error cases which expect us to post statuses
|
||||||
return actions;
|
// to github. Convert Eval Errors in to Result<_, CommitStatusWrite>
|
||||||
}
|
EvalWorkerError::EvalError(eval::Error::Fail(msg)) => {
|
||||||
let eval_result =
|
self.update_status(msg, None, hubcaps::statuses::State::Failure)
|
||||||
eval_result.expect_err("We have an OK, but just checked for an Ok before");
|
}
|
||||||
|
EvalWorkerError::EvalError(eval::Error::FailWithGist(msg, filename, content)) => self
|
||||||
|
.update_status(
|
||||||
|
msg,
|
||||||
|
self.make_gist(&filename, Some("".to_owned()), content),
|
||||||
|
hubcaps::statuses::State::Failure,
|
||||||
|
),
|
||||||
|
EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => Err(e),
|
||||||
|
EvalWorkerError::CommitStatusWrite(e) => Err(e),
|
||||||
|
});
|
||||||
|
|
||||||
match eval_result {
|
match eval_result {
|
||||||
EvalWorkerError::CommitStatusWrite(e)
|
Ok(eval_actions) => eval_actions,
|
||||||
| EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => {
|
Err(Ok(())) => {
|
||||||
if e.is_internal_error() {
|
// There was an error during eval, but we successfully
|
||||||
error!(
|
// updated the PR.
|
||||||
"Internal error writing commit status: {:?}, marking internal error",
|
|
||||||
e
|
self.actions().skip(&self.job)
|
||||||
);
|
|
||||||
let issue_ref = self.repo.issue(self.job.pr.number);
|
|
||||||
update_labels(&issue_ref, &[String::from("ofborg-internal-error")], &[]);
|
|
||||||
} else {
|
|
||||||
error!(
|
|
||||||
"Ignorable error writing commit status: {:?}, marking internal error",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EvalWorkerError::EvalError(eval::Error::Fail(msg)) => {
|
Err(Err(cswerr)) if !cswerr.is_internal_error() => {
|
||||||
self.update_status(msg.clone(), None, hubcaps::statuses::State::Failure)
|
error!("Ignorable error writing commit status: {:?}", cswerr);
|
||||||
.unwrap_or_else(|e| {
|
|
||||||
panic!("Failed to set plain status: {}; e: {:?}", msg, e);
|
self.actions().skip(&self.job)
|
||||||
});
|
|
||||||
}
|
}
|
||||||
EvalWorkerError::EvalError(eval::Error::FailWithGist(msg, filename, content)) => {
|
|
||||||
self.update_status(
|
Err(Err(cswerr)) => {
|
||||||
msg.clone(),
|
error!(
|
||||||
self.make_gist(&filename, Some("".to_owned()), content.clone()),
|
"Internal error writing commit status: {:?}, marking internal error",
|
||||||
hubcaps::statuses::State::Failure,
|
cswerr
|
||||||
)
|
);
|
||||||
.unwrap_or_else(|e| {
|
let issue_ref = self.repo.issue(self.job.pr.number);
|
||||||
panic!(
|
update_labels(&issue_ref, &[String::from("ofborg-internal-error")], &[]);
|
||||||
"Failed to set status with a gist: {}, {}, {}; e: {:?}",
|
|
||||||
msg, filename, content, e
|
self.actions().skip(&self.job)
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.actions().skip(&self.job)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn evaluate_job(&mut self) -> Result<worker::Actions, EvalWorkerError> {
|
fn evaluate_job(&mut self) -> Result<worker::Actions, EvalWorkerError> {
|
||||||
|
|
Loading…
Reference in a new issue