From 1155d757e4937436a8fffb2ef81d1535e4579882 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Wed, 8 May 2019 11:01:20 +0100 Subject: [PATCH] Make delta application logs easier to parse for multicontainer Change-type: patch Signed-off-by: Cameron Diver --- src/application-manager.coffee | 2 ++ src/compose/images.ts | 5 ++++- src/lib/docker-utils.ts | 3 ++- test/14-application-manager.spec.coffee | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/application-manager.coffee b/src/application-manager.coffee index 1fd7d496..3a06148b 100644 --- a/src/application-manager.coffee +++ b/src/application-manager.coffee @@ -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) diff --git a/src/compose/images.ts b/src/compose/images.ts index 82c0ea2d..375cba4d 100644 --- a/src/compose/images.ts +++ b/src/compose/images.ts @@ -89,6 +89,7 @@ export class Images extends (EventEmitter as { image: Image, opts: FetchOptions, onFinish = _.noop, + serviceName: string, ): Promise { 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 { 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)) { diff --git a/src/lib/docker-utils.ts b/src/lib/docker-utils.ts index 8842158b..22be4398 100644 --- a/src/lib/docker-utils.ts +++ b/src/lib/docker-utils.ts @@ -68,6 +68,7 @@ export class DockerUtils extends DockerToolbelt { imgDest: string, deltaOpts: DeltaFetchOptions, onProgress: ProgressCallback, + serviceName: string, ): Promise { 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( diff --git a/test/14-application-manager.spec.coffee b/test/14-application-manager.spec.coffee index 999d8482..17c54e0f 100644 --- a/test/14-application-manager.spec.coffee +++ b/test/14-application-manager.spec.coffee @@ -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 }]) )