Fix passing a target service to start in /v1/apps/:appId/start, and getting the containerId

We weren't passing a "target" to serviceAction, which made the start action fail.
Plus we need to get the container again after starting to get the latest containerId.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2018-03-09 14:41:19 -08:00
parent f4e07e3ce8
commit 79b4d39acd

View File

@ -127,7 +127,17 @@ createApplicationManagerRouter = (applications) ->
if app.services.length > 1 if app.services.length > 1
return res.status(400).send('Some v1 endpoints are only allowed on single-container apps') return res.status(400).send('Some v1 endpoints are only allowed on single-container apps')
applications.setTargetVolatileForService(service.imageId, running: action != 'stop') applications.setTargetVolatileForService(service.imageId, running: action != 'stop')
applications.executeStepAction(serviceAction(action, service.serviceId, service), { force }) applications.executeStepAction(serviceAction(action, service.serviceId, service, service), { force })
.then ->
if action == 'stop'
return service
# We refresh the container id in case we were starting an app with no container yet
applications.getCurrentApp(appId)
.then (app) ->
service = app?.services?[0]
if !service?
return res.status(400).send('App not found after running action')
return service
.then (service) -> .then (service) ->
res.status(200).json({ containerId: service.containerId }) res.status(200).json({ containerId: service.containerId })
.catch (err) -> .catch (err) ->