mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-23 23:42:29 +00:00
In /v1/update, return 202 when we're not updating immediately
We also add a catch to any errors when getting configuration, and send 503 in this case, even if it's unlikely. Change-type: patch Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
This commit is contained in:
parent
8f07bf62de
commit
9961ebb41d
@ -920,17 +920,33 @@ export class APIBinder {
|
|||||||
router.post('/v1/update', (req, res) => {
|
router.post('/v1/update', (req, res) => {
|
||||||
apiBinder.eventTracker.track('Update notification');
|
apiBinder.eventTracker.track('Update notification');
|
||||||
if (apiBinder.readyForUpdates) {
|
if (apiBinder.readyForUpdates) {
|
||||||
this.config.get('instantUpdates').then(instantUpdates => {
|
this.config
|
||||||
if (instantUpdates) {
|
.get('instantUpdates')
|
||||||
apiBinder.getAndSetTargetState(req.body.force, true).catch(_.noop);
|
.then(instantUpdates => {
|
||||||
} else {
|
if (instantUpdates) {
|
||||||
console.log(
|
apiBinder
|
||||||
'Ignoring update notification because instant updates are disabled',
|
.getAndSetTargetState(req.body.force, true)
|
||||||
);
|
.catch(_.noop);
|
||||||
}
|
res.sendStatus(204);
|
||||||
});
|
} else {
|
||||||
|
console.log(
|
||||||
|
'Ignoring update notification because instant updates are disabled',
|
||||||
|
);
|
||||||
|
res.sendStatus(202);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
const msg =
|
||||||
|
err.message != null
|
||||||
|
? err.message
|
||||||
|
: err != null
|
||||||
|
? err
|
||||||
|
: 'Unknown error';
|
||||||
|
res.status(503).send(msg);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.sendStatus(202);
|
||||||
}
|
}
|
||||||
res.sendStatus(204);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
|
Loading…
Reference in New Issue
Block a user