Make delta application logs easier to parse for multicontainer

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-05-08 11:01:20 +01:00
parent 56bac3a7ea
commit 1155d757e4
4 changed files with 11 additions and 3 deletions

View File

@ -45,6 +45,7 @@ fetchAction = (service) ->
action: 'fetch'
image: imageForService(service)
serviceId: service.serviceId
serviceName: service.serviceName
}
# TODO: implement additional v2 endpoints
@ -138,6 +139,7 @@ module.exports = class ApplicationManager extends EventEmitter
# and it's relevant mostly for the legacy GET /v1/device endpoint
# that assumes a single-container app
@reportCurrentState(update_downloaded: true)
, step.serviceName
)
removeImage: (step) =>
@images.remove(step.image)

View File

@ -89,6 +89,7 @@ export class Images extends (EventEmitter as {
image: Image,
opts: FetchOptions,
onFinish = _.noop,
serviceName: string,
): Promise<null> {
if (this.imageFetchFailures[image.name] != null) {
// If we are retrying a pull within the backoff time of the last failure,
@ -148,7 +149,7 @@ export class Images extends (EventEmitter as {
try {
let id;
if (opts.delta && (opts as DeltaFetchOptions).deltaSource != null) {
id = await this.fetchDelta(image, opts, onProgress);
id = await this.fetchDelta(image, opts, onProgress, serviceName);
} else {
id = await this.fetchImage(image, opts, onProgress);
}
@ -598,6 +599,7 @@ export class Images extends (EventEmitter as {
image: Image,
opts: FetchOptions,
onProgress: (evt: FetchProgressEvent) => void,
serviceName: string,
): Promise<string> {
this.logger.logSystemEvent(LogTypes.downloadImageDelta, { image });
@ -609,6 +611,7 @@ export class Images extends (EventEmitter as {
image.name,
deltaOpts,
onProgress,
serviceName,
);
if (!Images.hasDigest(image.name)) {

View File

@ -68,6 +68,7 @@ export class DockerUtils extends DockerToolbelt {
imgDest: string,
deltaOpts: DeltaFetchOptions,
onProgress: ProgressCallback,
serviceName: string,
): Promise<string> {
const deltaSourceId =
deltaOpts.deltaSourceId != null
@ -77,7 +78,7 @@ export class DockerUtils extends DockerToolbelt {
const timeout = deltaOpts.deltaApplyTimeout;
const log = (str: string) =>
console.log(`delta(${deltaOpts.deltaSource}): ${str}`);
console.log(`delta([${serviceName}] ${deltaOpts.deltaSource}): ${str}`);
if (!_.includes([2, 3], deltaOpts.deltaVersion)) {
log(

View File

@ -226,6 +226,7 @@ describe 'ApplicationManager', ->
image: @applications.imageForService(target.local.apps[0].services[1])
serviceId: 24
appId: 1234
serviceName: 'anotherService'
}])
)
@ -264,7 +265,8 @@ describe 'ApplicationManager', ->
action: 'fetch'
image: @applications.imageForService(target.local.apps[0].services[0])
serviceId: 23
appId: 1234
appId: 1234,
serviceName: 'aservice'
}, { action: 'noop', appId: 1234 }])
)