Improve UX when apps.json is not present

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2018-11-27 14:09:44 +00:00
parent f56be737ee
commit ce543d820f
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
2 changed files with 11 additions and 0 deletions

View File

@ -13,6 +13,7 @@ validation = require './lib/validation'
systemd = require './lib/systemd'
updateLock = require './lib/update-lock'
{ singleToMulticontainerApp } = require './lib/migration'
{ ENOENT, EISDIR } = require './lib/errors'
DeviceConfig = require './device-config'
ApplicationManager = require './application-manager'
@ -383,6 +384,12 @@ module.exports = class DeviceState extends EventEmitter
commit: commitToPin,
app: appToPin,
}
# Ensure that this is actually a file, and not an empty path
# It can be an empty path because if the file does not exist
# on host, the docker daemon creates an empty directory when
# the bind mount is added
.catch ENOENT, EISDIR, ->
console.log('No apps.json file present, skipping preload')
.catch (err) =>
@eventTracker.track('Loading preloaded apps failed', { error: err })

View File

@ -25,6 +25,10 @@ export function EEXIST(err: CodedSysError): boolean {
return err.code === 'EEXIST';
}
export function EISDIR(err: CodedSysError): boolean {
return err.code === 'EISDIR';
}
export function UnitNotLoadedError(err: string[]): boolean {
return endsWith(err[0], 'not loaded.');
}