Shell deletion exception handling
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
1a4e969557
commit
812cf73cb7
@ -26,7 +26,6 @@ public class SchedulerBean {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public static Task<Void> shellRemovalTask() {
|
public static Task<Void> shellRemovalTask() {
|
||||||
|
|
||||||
return Tasks.oneTime("shell-removal")
|
return Tasks.oneTime("shell-removal")
|
||||||
.execute((instance, ctx) -> {
|
.execute((instance, ctx) -> {
|
||||||
System.out.printf("Running container removal task - Instance: %s, ctx: %s\n", instance, ctx);
|
System.out.printf("Running container removal task - Instance: %s, ctx: %s\n", instance, ctx);
|
||||||
|
@ -276,7 +276,19 @@ public class WebApplication {
|
|||||||
|
|
||||||
System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username);
|
System.out.printf("Deletion triggered for ID %s by %s (%s)\n", id, userid, username);
|
||||||
|
|
||||||
Docker.deleteShell(username, id);
|
try {
|
||||||
|
Docker.deleteShell(username, id);
|
||||||
|
String returnmessage = "Ok, deleted the shell with container ID " + id;
|
||||||
|
redirectAttributes.addFlashAttribute("message", returnmessage);
|
||||||
|
} catch (com.github.dockerjava.api.exception.NotFoundException exception) {
|
||||||
|
String returnmessage = "Shell does not exist, maybe it already expired?";
|
||||||
|
redirectAttributes.addFlashAttribute("message", returnmessage);
|
||||||
|
System.out.println(exception);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
String returnmessage = "Error.";
|
||||||
|
redirectAttributes.addFlashAttribute("message", returnmessage);
|
||||||
|
System.out.println(exception);
|
||||||
|
}
|
||||||
|
|
||||||
return("redirect:/portal");
|
return("redirect:/portal");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user