Skip to content

Commit f74dc5d

Browse files
authored
Merge pull request #89 from delphi-hub/bugfix/stopPausedInstances
Trying to stop a paused instance now yields 400 Bad Request
2 parents 1d3812f + 41873bf commit f74dc5d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/scala/de/upb/cs/swt/delphi/instanceregistry/RequestHandler.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
504504
handleDeregister(id)
505505
OperationResult.Ok
506506
}
507-
} else {
507+
} else if(instanceDao.getInstance(id).get.instanceState != InstanceState.Paused){
508508
log.info(s"Handling /stop for instance with id $id...")
509509

510510
val instance = instanceDao.getInstance(id).get
@@ -531,6 +531,9 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
531531
}
532532

533533
OperationResult.Ok
534+
} else {
535+
log.warning(s"Cannot stop paused docker container for instance with id $id")
536+
OperationResult.InvalidStateForOperation
534537
}
535538
}
536539

src/main/scala/de/upb/cs/swt/delphi/instanceregistry/connection/Server.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ class Server (handler: RequestHandler) extends HttpApp
470470
case handler.OperationResult.InvalidTypeForOperation =>
471471
log.warning(s"Cannot stop id $id, this component type cannot be stopped.")
472472
complete{HttpResponse(StatusCodes.BadRequest, entity = s"Cannot stop instance of this type.")}
473+
case handler.OperationResult.InvalidStateForOperation =>
474+
log.warning(s"Cannot stop id $id, the associated container is paused.")
475+
complete{HttpResponse(StatusCodes.BadRequest, entity = s"Cannot stop instance while it is paused.")}
473476
case handler.OperationResult.Ok =>
474477
complete{HttpResponse(StatusCodes.Accepted, entity = "Operation accepted.")}
475478
case r =>

0 commit comments

Comments
 (0)