-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1251 from NASA-AMMOS/feat/cancel-scheduling
Cancel a Scheduling Run
- Loading branch information
Showing
42 changed files
with
691 additions
and
264 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
deployment/hasura/migrations/AerieScheduler/12_notify_cancel_scheduling/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
drop trigger notify_scheduling_workers_cancel on scheduling_request; | ||
drop function notify_scheduling_workers_cancel(); | ||
call migrations.mark_migration_rolled_back('12'); |
17 changes: 17 additions & 0 deletions
17
deployment/hasura/migrations/AerieScheduler/12_notify_cancel_scheduling/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
create function notify_scheduling_workers_cancel() | ||
returns trigger | ||
security definer | ||
language plpgsql as $$ | ||
begin | ||
perform pg_notify('scheduling_cancel', '' || new.specification_id); | ||
return null; | ||
end | ||
$$; | ||
|
||
create trigger notify_scheduling_workers_cancel | ||
after update of canceled on scheduling_request | ||
for each row | ||
when ((old.status != 'success' or old.status != 'failed') and new.canceled) | ||
execute function notify_scheduling_workers_cancel(); | ||
|
||
call migrations.mark_migration_applied('12'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/SchedulingRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package gov.nasa.jpl.aerie.e2e.types; | ||
|
||
import javax.json.JsonObject; | ||
import java.util.Optional; | ||
|
||
public record SchedulingRequest( | ||
int analysisId, | ||
int specificationId, | ||
int specificationRevision, | ||
SchedulingStatus status, | ||
boolean canceled, | ||
Optional<SchedulingReason> reason | ||
) { | ||
public enum SchedulingStatus { pending, incomplete, failed, success } | ||
|
||
public record SchedulingReason( | ||
String type, | ||
String message, | ||
String trace, | ||
JsonObject data | ||
) | ||
{ | ||
public static SchedulingReason fromJSON(JsonObject json) { | ||
return new SchedulingReason( | ||
json.getString("type"), | ||
json.getString("message"), | ||
json.getString("trace"), | ||
json.getJsonObject("data") | ||
); | ||
} | ||
} | ||
|
||
public static SchedulingRequest fromJSON(JsonObject json) { | ||
return new SchedulingRequest( | ||
json.getInt("analysis_id"), | ||
json.getInt("specification_id"), | ||
json.getInt("specification_revision"), | ||
SchedulingStatus.valueOf(json.getString("status")), | ||
json.getBoolean("canceled"), | ||
json.isNull("reason") ? Optional.empty() : Optional.of(SchedulingReason.fromJSON(json.getJsonObject("reason"))) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.