diff --git a/CHANGELOG.md b/CHANGELOG.md index 26add01e..c6a0db28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! This project adheres to [Semantic Versioning](http://semver.org/). +## v7.1.8 - 2018-03-13 + +* Avoid trying to send a response to API calls after we've already sent an error #579 [Pablo Carranza Velez] +* Fix passing a target service to start in /v1/apps/:appId/start, and getting the containerId #579 [Pablo Carranza Velez] + ## v7.1.7 - 2018-03-09 * Gosuper: Treat systemd unit states that are not "inactive" or "deactivating" as enabled states #577 [Pablo Carranza Velez] diff --git a/package.json b/package.json index daf10a26..cf8f8f85 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "resin-supervisor", "description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.", - "version": "7.1.7", + "version": "7.1.8", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/src/application-manager.coffee b/src/application-manager.coffee index f6dfb8d7..539dd33f 100644 --- a/src/application-manager.coffee +++ b/src/application-manager.coffee @@ -127,9 +127,19 @@ createApplicationManagerRouter = (applications) -> if app.services.length > 1 return res.status(400).send('Some v1 endpoints are only allowed on single-container apps') applications.setTargetVolatileForService(service.imageId, running: action != 'stop') - applications.executeStepAction(serviceAction(action, service.serviceId, service), { force }) - .then (service) -> - res.status(200).json({ containerId: service.containerId }) + 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? + throw new Error('App not found after running action') + return service + .then (service) -> + res.status(200).json({ containerId: service.containerId }) .catch (err) -> res.status(503).send(err?.message or err or 'Unknown error') @@ -203,8 +213,8 @@ createApplicationManagerRouter = (applications) -> return res.status(404).send(errMsg) applications.setTargetVolatileForService(service.imageId, running: action != 'stop') applications.executeStepAction(serviceAction(action, service.serviceId, service, service, { wait: true }), { skipLock: true }) - .then -> - res.status(200).send('OK') + .then -> + res.status(200).send('OK') .catch (err) -> res.status(503).send(err?.message or err or 'Unknown error')