Merge pull request #902 from balena-io/843-better-healthcheck

Don't treat a non-200 status response on patch as report errors
This commit is contained in:
CameronDiver 2019-02-12 14:28:03 +00:00 committed by GitHub
commit 775643d58b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

10
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "balena-supervisor", "name": "balena-supervisor",
"version": "9.6.3", "version": "9.7.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -7487,9 +7487,9 @@
"dev": true "dev": true
}, },
"pinejs-client-request": { "pinejs-client-request": {
"version": "5.1.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/pinejs-client-request/-/pinejs-client-request-5.1.0.tgz", "resolved": "https://registry.npmjs.org/pinejs-client-request/-/pinejs-client-request-5.2.0.tgz",
"integrity": "sha512-usofxkxvlIAYhzesZu7qTYyEISUWPFL9zHY/YItrcPSfN4qWvbY8ixl54kloqKgWS6nYyE72HyFKANzYsQ919w==", "integrity": "sha512-CqmhLgfdjdT6RCduZ+hi5Ne6iVPHF0689IU6RQL7go57kZNcrIXyi6WvKZ6HFmDdZmCtuAv9i/Y0EmMWXhbGjw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/bluebird": "^3.5.23", "@types/bluebird": "^3.5.23",
@ -8009,7 +8009,7 @@
}, },
"require-npm4-to-publish": { "require-npm4-to-publish": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://registry.npmjs.org/require-npm4-to-publish/-/require-npm4-to-publish-1.0.0.tgz", "resolved": "https://registry.npmjs.org/require-npm4-to-publish/-/require-npm4-to-publish-1.0.0.tgz",
"integrity": "sha1-5Z7D5ikQFT3Fu90MpA20IrLE2ec=", "integrity": "sha1-5Z7D5ikQFT3Fu90MpA20IrLE2ec=",
"dev": true, "dev": true,
"requires": { "requires": {

View File

@ -82,7 +82,7 @@
"morgan": "^1.9.1", "morgan": "^1.9.1",
"mz": "^2.7.0", "mz": "^2.7.0",
"network-checker": "^0.1.1", "network-checker": "^0.1.1",
"pinejs-client-request": "^5.1.0", "pinejs-client-request": "^5.2.0",
"prettier": "^1.15.3", "prettier": "^1.15.3",
"request": "^2.51.0", "request": "^2.51.0",
"resin-lint": "^2.0.1", "resin-lint": "^2.0.1",

View File

@ -3,7 +3,7 @@ import * as bodyParser from 'body-parser';
import * as express from 'express'; import * as express from 'express';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Path from 'path'; import * as Path from 'path';
import { PinejsClientRequest } from 'pinejs-client-request'; import { PinejsClientRequest, StatusError } from 'pinejs-client-request';
import * as deviceRegister from 'resin-register-device'; import * as deviceRegister from 'resin-register-device';
import * as url from 'url'; import * as url from 'url';
@ -460,7 +460,18 @@ export class APIBinder {
await Bluebird.resolve( await Bluebird.resolve(
this.sendReportPatch(stateDiff, { apiEndpoint, uuid }), this.sendReportPatch(stateDiff, { apiEndpoint, uuid }),
).timeout(conf.apiTimeout); )
.catch(StatusError, (e: StatusError) => {
// We don't want this to be classed as a report error, as this will cause
// the watchdog to kill the supervisor - and killing the supervisor will
// not help in this situation
console.error(
`Non-200 response from API! Status code: ${e.statusCode} - message: ${
e.message
}`,
);
})
.timeout(conf.apiTimeout);
this.stateReportErrors = 0; this.stateReportErrors = 0;
_.assign(this.lastReportedState.local, stateDiff.local); _.assign(this.lastReportedState.local, stateDiff.local);