@@ -33,7 +33,7 @@ class Logger {
33
33
this . findExistingContainers = findExistingContainers === 'true' ;
34
34
this . logSizeLimit = logSizeLimit ;
35
35
this . containerLoggers = [ ] ;
36
- this . logSize = 0 ;
36
+ this . totalLogSize = 0 ;
37
37
this . taskLogger = undefined ;
38
38
this . buildFinishedPromise = buildFinishedPromise || Q . resolve ( ) ;
39
39
this . finishedContainers = 0 ;
@@ -54,7 +54,7 @@ class Logger {
54
54
} ) ;
55
55
this . _readState ( ) ;
56
56
this . _handleBuildFinished ( ) ;
57
- this . _updateStateInterval = setInterval ( this . _updateStateFile . bind ( this ) , 1000 ) ;
57
+ this . _updateStateInterval = setInterval ( this . _updateStateFile . bind ( this ) , 3000 ) ;
58
58
}
59
59
60
60
/**
@@ -173,13 +173,7 @@ class Logger {
173
173
logLimitExceeded ( ) {
174
174
// TODO in the future when we allow a workflow to use multuple dinds, this will not be correct
175
175
// we need to get the total size of logs from all dinds
176
- return this . logSizeLimit && this . _getTotalLogSize ( ) > this . logSizeLimit ;
177
- }
178
-
179
- _getTotalLogSize ( ) {
180
- return _ . reduce ( this . containerLoggers , ( sum , containerLogger ) => {
181
- return sum + containerLogger . logSize ;
182
- } , 0 ) ;
176
+ return this . logSizeLimit && this . totalLogSize > this . logSizeLimit ;
183
177
}
184
178
185
179
/**
@@ -263,7 +257,7 @@ class Logger {
263
257
} ) ;
264
258
this . containerLoggers . push ( containerLogger ) ;
265
259
containerLogger . on ( 'message.logged' , this . _updateTotalLogSize . bind ( this ) ) ;
266
- containerLogger . once ( 'end' , this . _handleContainerStreamEnd . bind ( this ) ) ;
260
+ containerLogger . once ( 'end' , this . _handleContainerStreamEnd . bind ( this , containerId ) ) ;
267
261
268
262
containerLogger . start ( )
269
263
. done ( ( ) => {
@@ -287,9 +281,9 @@ class Logger {
287
281
_ . set ( this , 'state.logsStatus.missingLogs' , writeCalls - resolvedCalls - rejectedCalls ) ;
288
282
}
289
283
290
- _updateTotalLogSize ( ) {
291
- this . logSize = this . _getTotalLogSize ( ) ;
292
- this . taskLogger . setLogSize ( this . logSize ) ;
284
+ _updateTotalLogSize ( size ) {
285
+ this . totalLogSize += size ;
286
+ this . taskLogger . setLogSize ( this . totalLogSize ) ;
293
287
}
294
288
295
289
_updateLastLoggingDate ( ) {
@@ -301,9 +295,16 @@ class Logger {
301
295
clearInterval ( this . _updateStateInterval ) ;
302
296
} else {
303
297
this . _writeNewState ( true ) ;
304
-
305
298
if ( this . showProgress ) {
299
+ const activeContainerLoggers = this . containerLoggers . filter (
300
+ ( containerLogger ) => this . state . containers [ containerLogger . containerId ] . status === ContainerHandlingStatus . LISTENING
301
+ ) ;
302
+ const buffers = activeContainerLoggers . reduce ( ( acc , cur ) => {
303
+ acc [ cur . containerId ] = cur . bufferUsed ;
304
+ return acc ;
305
+ } , { } ) ;
306
306
logger . debug ( `logger progress update: ${ JSON . stringify ( this . state . logsStatus ) } ` ) ;
307
+ logger . debug ( `buffers: ${ JSON . stringify ( buffers ) } ` ) ;
307
308
}
308
309
}
309
310
}
@@ -376,9 +377,10 @@ class Logger {
376
377
} ) ;
377
378
}
378
379
379
- _handleContainerStreamEnd ( ) {
380
+ _handleContainerStreamEnd ( containerId ) {
380
381
this . finishedContainers ++ ;
381
382
this . finishedContainersEmitter . emit ( 'end' ) ;
383
+ this . state . containers [ containerId ] = { status : ContainerHandlingStatus . FINISHED } ;
382
384
}
383
385
384
386
// do not call before build is finished
0 commit comments