Skip to content

Commit

Permalink
The purge and abort segment REST endpoints are actions, not idempoten…
Browse files Browse the repository at this point in the history
…t reads, so should be POST instead of GET method requests.
  • Loading branch information
michaelsembwever committed May 21, 2019
1 parent acddf28 commit 65909e3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/docs/content/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ This operation expects that a call was previously made to `/login` and that the
* Returns the list of segments of the repair run.


* **GET /repair_run/{id}/segments/abort/{segment_id}**
* **POST /repair_run/{id}/segments/abort/{segment_id}**
* Expected query parameters: *None*
* Aborts a running segment and puts it back in NOT_STARTED state. The segment will be processed again later during the lifetime of the repair run.

Expand Down
2 changes: 1 addition & 1 deletion src/packaging/bin/spreaper
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ class ReaperCLI(object):
extra_arguments=_arguments_for_abort_segment
)
printq("# Aborting a segment with run id: {0} and segment id {1}".format(args.run_id, args.segment_id))
reaper.get("repair_run/{0}/segments/abort/{1}".format(args.run_id, args.segment_id))
reaper.post("repair_run/{0}/segments/abort/{1}".format(args.run_id, args.segment_id))
printq("# Segment '{0}' aborted".format(args.segment_id))

def start_schedule(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public Response getRepairRunSegments(@PathParam("id") UUID repairRunId) {
/**
* @return Aborts a running segment.
*/
@GET
@POST
@Path("/{id}/segments/abort/{segment_id}")
public Response getRepairRunSegments(
@PathParam("id") UUID repairRunId, @PathParam("segment_id") UUID segmentId) {
Expand Down Expand Up @@ -769,7 +769,7 @@ public Response deleteRepairRun(
return Response.status(Response.Status.NOT_FOUND).entity("Repair run %s" + runId + " not found").build();
}

@GET
@POST
@Path("/purge")
public Response purgeRepairRuns() throws ReaperException {
int purgedRepairs = PurgeService.create(context).purgeDatabase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ public void reseting_one_segment_sets_its_state_to_not_started() throws Throwabl
await().with().pollInterval(1, SECONDS).atMost(2, MINUTES).until(
() -> {
Response abort = runner.callReaper(
"GET", // TODO – this should be a POST
"POST",
"/repair_run/"
+ testContext.getCurrentRepairId()
+ "/segments/abort/"
Expand Down
2 changes: 1 addition & 1 deletion src/ui/app/jsx/segment-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const Segment = React.createClass({
this.props.notify("Aborting segment " + this.props.segment.id, "warning", this.props.segment.id);
$.ajax({
url: this.props.urlPrefix + '/repair_run/' + encodeURIComponent(this.props.segment.runId) + '/segments/abort/' + encodeURIComponent(this.props.segment.id),
method: 'GET',
method: 'POST',
component: this,
success: function(data) {
this.component.props.notify("Successfully aborted segment " + this.component.props.segment.id, "success", this.component.props.segment.id)
Expand Down

0 comments on commit 65909e3

Please sign in to comment.