Merge pull request #1008 from balena-io/fix-bad-report

Don't drop failed api patch data
This commit is contained in:
CameronDiver 2019-06-20 05:25:11 -07:00 committed by GitHub
commit d8eeba3d46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -501,24 +501,27 @@ export class APIBinder {
);
}
await Bluebird.resolve(
this.sendReportPatch(stateDiff, { apiEndpoint, uuid }),
)
.catch(StatusError, (e: StatusError) => {
try {
await Bluebird.resolve(
this.sendReportPatch(stateDiff, { apiEndpoint, uuid }),
).timeout(conf.apiTimeout);
this.stateReportErrors = 0;
_.assign(this.lastReportedState.local, stateDiff.local);
_.assign(this.lastReportedState.dependent, stateDiff.dependent);
} catch (e) {
if (e instanceof 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
log.error(
`Non-200 response from API! Status code: ${e.statusCode} - message: ${
e.message
}`,
'Non-200 response from the API! Status code: ${e.statusCode} - message:',
e,
);
})
.timeout(conf.apiTimeout);
this.stateReportErrors = 0;
_.assign(this.lastReportedState.local, stateDiff.local);
_.assign(this.lastReportedState.dependent, stateDiff.dependent);
} else {
throw e;
}
}
}
private reportCurrentState(): null {