Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e65a24aa89ed^
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3dc749821107
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 7, 2020

  1. Copy the full SHA
    e65a24a View commit details
  2. Copy the full SHA
    3dc7498 View commit details
Showing with 20 additions and 13 deletions.
  1. +6 −9 ofborg/src/commitstatus.rs
  2. +4 −0 ofborg/src/message/evaluationjob.rs
  3. +10 −4 ofborg/src/tasks/evaluate.rs
15 changes: 6 additions & 9 deletions ofborg/src/commitstatus.rs
Original file line number Diff line number Diff line change
@@ -71,23 +71,20 @@ impl<'a> CommitStatus<'a> {

#[derive(Debug)]
pub enum CommitStatusError {
ExpiredCreds(hubcaps::Error),
MissingSHA(hubcaps::Error),
Error(hubcaps::Error),
}

impl CommitStatusError {
pub fn is_internal_error(&self) -> bool {
match self {
CommitStatusError::MissingSHA(_) => false,
CommitStatusError::Error(_) => true,
}
}
}

impl From<hubcaps::Error> for CommitStatusError {
fn from(e: hubcaps::Error) -> CommitStatusError {
use hyper::status::StatusCode;
match e.kind() {
hubcaps::ErrorKind::Fault { code, error }
if code == &StatusCode::Unauthorized && error.message == "Bad credentials" =>
{
CommitStatusError::ExpiredCreds(e)
}
hubcaps::ErrorKind::Fault { code, error }
if code == &StatusCode::UnprocessableEntity
&& error.message.starts_with("No commit found for SHA:") =>
4 changes: 4 additions & 0 deletions ofborg/src/message/evaluationjob.rs
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ impl EvaluationJob {
pub struct Actions {}

impl Actions {
pub fn retry_later(&mut self, _job: &EvaluationJob) -> worker::Actions {
vec![worker::Action::NackRequeue]
}

pub fn skip(&mut self, _job: &EvaluationJob) -> worker::Actions {
vec![worker::Action::Ack]
}
14 changes: 10 additions & 4 deletions ofborg/src/tasks/evaluate.rs
Original file line number Diff line number Diff line change
@@ -226,13 +226,19 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {

self.actions().skip(&self.job)
}
Err(Err(cswerr)) if !cswerr.is_internal_error() => {
error!("Ignorable error writing commit status: {:?}", cswerr);

Err(Err(CommitStatusError::ExpiredCreds(e))) => {
error!("Failed writing commit status: creds expired: {:?}", e);
self.actions().retry_later(&self.job)
}
Err(Err(CommitStatusError::MissingSHA(e))) => {
error!(
"Failed writing commit status: commit sha was force-pushed away: {:?}",
e
);
self.actions().skip(&self.job)
}

Err(Err(cswerr)) => {
Err(Err(CommitStatusError::Error(cswerr))) => {
error!(
"Internal error writing commit status: {:?}, marking internal error",
cswerr