diff --git a/priam/src/main/java/com/netflix/priam/backupv2/SnapshotMetaTask.java b/priam/src/main/java/com/netflix/priam/backupv2/SnapshotMetaTask.java index bc05c1874..10afa1cec 100644 --- a/priam/src/main/java/com/netflix/priam/backupv2/SnapshotMetaTask.java +++ b/priam/src/main/java/com/netflix/priam/backupv2/SnapshotMetaTask.java @@ -198,7 +198,7 @@ public void execute() throws Exception { // as this happens on CRON. if (!lock.tryLock()) { logger.warn("SnapshotMetaService is already running! Try again later."); - throw new Exception("SnapshotMetaService already running"); + throw new IllegalStateException("SnapshotMetaService already running"); } // Save start snapshot status diff --git a/priam/src/main/java/com/netflix/priam/resources/BackupServletV2.java b/priam/src/main/java/com/netflix/priam/resources/BackupServletV2.java index 9ac66639e..5813b7599 100644 --- a/priam/src/main/java/com/netflix/priam/resources/BackupServletV2.java +++ b/priam/src/main/java/com/netflix/priam/resources/BackupServletV2.java @@ -83,7 +83,14 @@ public BackupServletV2( @GET @Path("/do_snapshot") public Response backup() throws Exception { - snapshotMetaService.execute(); + try { + snapshotMetaService.execute(); + } catch (Exception e) { + if (e instanceof IllegalStateException) { + return Response.status(409).build(); + } + return Response.serverError().build(); + } return Response.ok(REST_SUCCESS, MediaType.APPLICATION_JSON).build(); }