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 => {
log.error(`Could not store target state for device: ${e}`);
this.logger.logSystemMessage(
`Could not move to new release: ${e.message}`,
{},
'targetStateRejection',
false,
);
// the dashboard does not display lines correctly,
// split them explcitly here
const lines = e.message.split(/\r?\n/);
lines[0] = `Could not move to new release: ${lines[0]}`;
for (const line of lines) {
this.logger.logSystemMessage(line, {}, 'targetStateRejection', false);
}
})
.tapCatch(
(e: unknown) =>

View File

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