Skip to content

Commit

Permalink
Return status code 409 is do_snapshot is already in progress (#1096)
Browse files Browse the repository at this point in the history
Co-authored-by: ayushis <[email protected]>
  • Loading branch information
ayushisingh29 and ayushis authored May 20, 2024
1 parent df30219 commit fee4ddf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit fee4ddf

Please sign in to comment.