Auto-merge for PR #579 via VersionBot

Some fixes for the supervisor API
This commit is contained in:
resin-io-versionbot[bot] 2018-03-13 14:14:55 +00:00 committed by GitHub
commit 7df07482d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -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! automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/). 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 ## v7.1.7 - 2018-03-09
* Gosuper: Treat systemd unit states that are not "inactive" or "deactivating" as enabled states #577 [Pablo Carranza Velez] * Gosuper: Treat systemd unit states that are not "inactive" or "deactivating" as enabled states #577 [Pablo Carranza Velez]

View File

@ -1,7 +1,7 @@
{ {
"name": "resin-supervisor", "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.", "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", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -127,9 +127,19 @@ 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 (service) -> .then ->
res.status(200).json({ containerId: service.containerId }) 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) -> .catch (err) ->
res.status(503).send(err?.message or err or 'Unknown error') res.status(503).send(err?.message or err or 'Unknown error')
@ -203,8 +213,8 @@ createApplicationManagerRouter = (applications) ->
return res.status(404).send(errMsg) return res.status(404).send(errMsg)
applications.setTargetVolatileForService(service.imageId, running: action != 'stop') applications.setTargetVolatileForService(service.imageId, running: action != 'stop')
applications.executeStepAction(serviceAction(action, service.serviceId, service, service, { wait: true }), { skipLock: true }) applications.executeStepAction(serviceAction(action, service.serviceId, service, service, { wait: true }), { skipLock: true })
.then -> .then ->
res.status(200).send('OK') res.status(200).send('OK')
.catch (err) -> .catch (err) ->
res.status(503).send(err?.message or err or 'Unknown error') res.status(503).send(err?.message or err or 'Unknown error')