From a92fc6b52494247eb2d7d688dd638f265190258f Mon Sep 17 00:00:00 2001 From: Rob Zienert Date: Wed, 10 Jun 2020 10:51:39 -0700 Subject: [PATCH] fix(resilience4j): Circuit breaker ignores 404s from Jenkins (#777) --- .../igor/jenkins/service/JenkinsService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java index e4c8880ed..c06bb8f80 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java @@ -45,6 +45,7 @@ import com.netflix.spinnaker.kork.exceptions.SpinnakerException; import com.netflix.spinnaker.kork.web.exceptions.NotFoundException; import io.github.resilience4j.circuitbreaker.CircuitBreaker; +import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry; import java.io.InputStream; import java.time.Duration; @@ -83,7 +84,20 @@ public JenkinsService( this.jenkinsClient = jenkinsClient; this.csrf = csrf; this.permissions = permissions; - this.circuitBreaker = circuitBreakerRegistry.circuitBreaker("jenkins-" + jenkinsHostId); + this.circuitBreaker = + circuitBreakerRegistry.circuitBreaker( + "jenkins-" + jenkinsHostId, + CircuitBreakerConfig.custom() + .ignoreException( + (e) -> { + if (e instanceof RetrofitError) { + RetrofitError re = (RetrofitError) e; + return re.getKind() == RetrofitError.Kind.HTTP + && re.getResponse().getStatus() == 404; + } + return false; + }) + .build()); } @Override