Correctly validate container contracts

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-10-02 15:48:17 +01:00
parent 5b48f791d9
commit d16403f654
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
2 changed files with 8 additions and 7 deletions

View File

@ -589,12 +589,13 @@ export class APIBinder {
}) })
.tapCatch(ContractValidationError, ContractViolationError, e => { .tapCatch(ContractValidationError, ContractViolationError, e => {
log.error(`Could not store target state for device: ${e}`); log.error(`Could not store target state for device: ${e}`);
this.logger.logSystemMessage( // the dashboard does not display lines correctly,
`Could not move to new release: ${e.message}`, // split them explcitly here
{}, const lines = e.message.split(/\r?\n/);
'targetStateRejection', lines[0] = `Could not move to new release: ${lines[0]}`;
false, for (const line of lines) {
); this.logger.logSystemMessage(line, {}, 'targetStateRejection', false);
}
}) })
.tapCatch( .tapCatch(
(e: unknown) => (e: unknown) =>

View File

@ -695,7 +695,7 @@ module.exports = class ApplicationManager extends EventEmitter
_.each app.services, (s) -> _.each app.services, (s) ->
if s.contract? if s.contract?
try try
validateContract(s) validateContract(s.contract)
catch e catch e
throw new ContractValidationError(s.serviceName, e.message) throw new ContractValidationError(s.serviceName, e.message)
serviceContracts[s.serviceName] = s.contract serviceContracts[s.serviceName] = s.contract