Skip to content

Commit

Permalink
fix(JenkinsService): separate Spinnaker*Exceptions to handle retryabl…
Browse files Browse the repository at this point in the history
…e conditions
  • Loading branch information
SheetalAtre committed Sep 15, 2023
1 parent fb2cbdb commit 520be8a
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ public JenkinsService(
.ignoreException(
(e) -> {
if (e instanceof SpinnakerHttpException) {
SpinnakerServerException re = (SpinnakerServerException) e;
return re instanceof SpinnakerHttpException
&& ((SpinnakerHttpException) re).getResponseCode() == 404;
return e instanceof SpinnakerHttpException
&& ((SpinnakerHttpException) e).getResponseCode() == 404;
}
return false;
})
Expand Down Expand Up @@ -336,15 +335,17 @@ private Response getPropertyFile(String jobName, Integer buildNumber, String fil
try {
return jenkinsClient.getPropertyFile(encode(jobName), buildNumber, fileName);
} catch (SpinnakerHttpException e) {
// retry on network issue, 404 and 5XX
if (e instanceof SpinnakerNetworkException
|| (e instanceof SpinnakerHttpException
&& (((SpinnakerHttpException) e).getResponseCode() == 404
|| ((SpinnakerHttpException) e).getResponseCode() >= 500))) {
throw e;
if (e.getResponseCode() == 404 || e.getResponseCode() >= 500) {
throw e; // retry on 404 and 5XX
}
SpinnakerException ex = new SpinnakerException(e);
ex.setRetryable(false);
ex.setRetryable(false); // disable retry
throw ex;
} catch (SpinnakerNetworkException e) {
throw e; // retry on network issue
} catch (SpinnakerServerException e) {
SpinnakerException ex = new SpinnakerException(e);
ex.setRetryable(false); // disable retry
throw ex;
}
},
Expand Down

0 comments on commit 520be8a

Please sign in to comment.