forked from the-distro/ofborg
Merge pull request #456 from NixOS/retryon-bad-creds
Retry on bad creds
This commit is contained in:
commit
284a7bfeaa
|
@ -71,23 +71,20 @@ impl<'a> CommitStatus<'a> {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CommitStatusError {
|
pub enum CommitStatusError {
|
||||||
|
ExpiredCreds(hubcaps::Error),
|
||||||
MissingSHA(hubcaps::Error),
|
MissingSHA(hubcaps::Error),
|
||||||
Error(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 {
|
impl From<hubcaps::Error> for CommitStatusError {
|
||||||
fn from(e: hubcaps::Error) -> CommitStatusError {
|
fn from(e: hubcaps::Error) -> CommitStatusError {
|
||||||
use hyper::status::StatusCode;
|
use hyper::status::StatusCode;
|
||||||
match e.kind() {
|
match e.kind() {
|
||||||
|
hubcaps::ErrorKind::Fault { code, error }
|
||||||
|
if code == &StatusCode::Unauthorized && error.message == "Bad credentials" =>
|
||||||
|
{
|
||||||
|
CommitStatusError::ExpiredCreds(e)
|
||||||
|
}
|
||||||
hubcaps::ErrorKind::Fault { code, error }
|
hubcaps::ErrorKind::Fault { code, error }
|
||||||
if code == &StatusCode::UnprocessableEntity
|
if code == &StatusCode::UnprocessableEntity
|
||||||
&& error.message.starts_with("No commit found for SHA:") =>
|
&& error.message.starts_with("No commit found for SHA:") =>
|
||||||
|
|
|
@ -20,6 +20,10 @@ impl EvaluationJob {
|
||||||
pub struct Actions {}
|
pub struct Actions {}
|
||||||
|
|
||||||
impl 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 {
|
pub fn skip(&mut self, _job: &EvaluationJob) -> worker::Actions {
|
||||||
vec![worker::Action::Ack]
|
vec![worker::Action::Ack]
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,13 +226,19 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
||||||
|
|
||||||
self.actions().skip(&self.job)
|
self.actions().skip(&self.job)
|
||||||
}
|
}
|
||||||
Err(Err(cswerr)) if !cswerr.is_internal_error() => {
|
Err(Err(CommitStatusError::ExpiredCreds(e))) => {
|
||||||
error!("Ignorable error writing commit status: {:?}", cswerr);
|
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)
|
self.actions().skip(&self.job)
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(Err(cswerr)) => {
|
Err(Err(CommitStatusError::Error(cswerr))) => {
|
||||||
error!(
|
error!(
|
||||||
"Internal error writing commit status: {:?}, marking internal error",
|
"Internal error writing commit status: {:?}, marking internal error",
|
||||||
cswerr
|
cswerr
|
||||||
|
|
Loading…
Reference in a new issue