Auto-merge for PR #591 via VersionBot

Force reboots and shutdowns if lock override is enabled
This commit is contained in:
resin-io-versionbot[bot] 2018-03-19 20:12:31 +00:00 committed by GitHub
commit 2dfceaa7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 16 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!
This project adheres to [Semantic Versioning](http://semver.org/).
## v7.1.17 - 2018-03-19
* Document that the update lock can be forced on reboots and shutdowns #591 [Pablo Carranza Velez]
* Force reboots and shutdowns if lock override is enabled #591 [Pablo Carranza Velez]
## v7.1.16 - 2018-03-16
* In /v1/apps/:appId/stop, wait for the service to exit before responding #593 [Pablo Carranza Velez]

View File

@ -108,7 +108,9 @@ $ curl -X POST --header "Content-Type:application/json" \
### POST /v1/reboot
Reboots the device
Reboots the device. This will first try to stop applications, and fail if there is an update lock.
An optional "force" parameter in the body overrides the lock when true (and the lock can also be overridden from
the dashboard).
When successful, responds with 202 accepted and a JSON object:
```json
@ -119,6 +121,9 @@ When successful, responds with 202 accepted and a JSON object:
```
(This is implemented in Go)
#### Request body
Can contain a `force` property, which if set to `true` will cause the update lock to be overridden.
#### Examples:
From the app on the device:
```bash
@ -142,7 +147,9 @@ $ curl -X POST --header "Content-Type:application/json" \
### POST /v1/shutdown
**Dangerous**. Shuts down the device.
**Dangerous**. Shuts down the device. This will first try to stop applications, and fail if there is an update lock.
An optional "force" parameter in the body overrides the lock when true (and the lock can also be overridden from
the dashboard).
When successful, responds with 202 accepted and a JSON object:
```json
@ -153,6 +160,9 @@ When successful, responds with 202 accepted and a JSON object:
```
(This is implemented in Go)
#### Request body
Can contain a `force` property, which if set to `true` will cause the update lock to be overridden.
#### Examples:
From the app on the device:
```bash

View File

@ -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.16",
"version": "7.1.17",
"license": "Apache-2.0",
"repository": {
"type": "git",

View File

@ -45,9 +45,11 @@ createDeviceStateRouter = (deviceState) ->
router.use(bodyParser.urlencoded(extended: true))
router.use(bodyParser.json())
router.post '/v1/reboot', (req, res) ->
force = validation.checkTruthy(req.body.force)
deviceState.executeStepAction({ action: 'reboot' }, { force })
rebootOrShutdown = (req, res, action) ->
deviceState.config.get('lockOverride')
.then (lockOverride) ->
force = validation.checkTruthy(req.body.force) or validation.checkTruthy(lockOverride)
deviceState.executeStepAction({ action }, { force })
.then (response) ->
res.status(202).json(response)
.catch (err) ->
@ -57,17 +59,11 @@ createDeviceStateRouter = (deviceState) ->
status = 500
res.status(status).json({ Data: '', Error: err?.message or err or 'Unknown error' })
router.post '/v1/reboot', (req, res) ->
rebootOrShutdown(req, res, 'reboot')
router.post '/v1/shutdown', (req, res) ->
force = validation.checkTruthy(req.body.force)
deviceState.executeStepAction({ action: 'shutdown' }, { force })
.then (response) ->
res.status(202).json(response)
.catch (err) ->
if err instanceof updateLock.UpdatesLockedError
status = 423
else
status = 500
res.status(status).json({ Data: '', Error: err?.message or err or 'Unknown error' })
rebootOrShutdown(req, res, 'shutdown')
router.get '/v1/device/host-config', (req, res) ->
hostConfig.get()