@@ -280,6 +280,7 @@ func (a *App) Monitor(ctx context.Context, filterOptions container.FilterOptions
280280 slog .Info ("Stopping engine monitor" )
281281 return ctx .Err ()
282282 case evt := <- evtCh :
283+ slog .Info ("Received event." , "value" , evt )
283284 switch evt .Type {
284285 case events .ContainerEventType :
285286 // Note: health checks will run command inside the containers periodically, and this results
@@ -315,26 +316,33 @@ func (a *App) Monitor(ctx context.Context, filterOptions container.FilterOptions
315316
316317 switch evt .Action {
317318 case events .ActionExecDie , events .ActionCreate , events .ActionStart , events .ActionStop , events .ActionPause , events .ActionUnPause , events .ActionHealthStatusHealthy , events .ActionHealthStatusUnhealthy :
318- go func () {
319+ go func (evt events. Message ) {
319320 // Delay before trigger update to allow the service status to be updated
320321 time .Sleep (500 * time .Millisecond )
321322 if err := a .Update (container.FilterOptions {
322323 IDs : []string {evt .Actor .ID },
324+
325+ // Preserve default filter options
326+ Names : filterOptions .Names ,
327+ Labels : filterOptions .Labels ,
328+ Types : filterOptions .Types ,
329+ ExcludeNames : filterOptions .ExcludeNames ,
330+ ExcludeWithLabel : filterOptions .ExcludeWithLabel ,
323331 }); err != nil {
324332 slog .Warn ("Error updating container state." , "err" , err )
325333 }
326- }()
334+ }(evt )
327335 case events .ActionDestroy , events .ActionRemove , events .ActionDie :
328336 slog .Info ("Container removed/destroyed" , "container" , evt .Actor .ID , "attributes" , evt .Actor .Attributes )
329337 // TODO: Trigger a removal instead of checking the whole state
330338 // Lookup container name by container id (from the entity store) as lookup by name won't work for container-groups
331- go func () {
339+ go func (evt events. Message ) {
332340 // Delay before trigger update to allow the service status to be updated
333341 time .Sleep (500 * time .Millisecond )
334- if err := a .Update (container. FilterOptions {} ); err != nil {
342+ if err := a .Update (filterOptions ); err != nil {
335343 slog .Warn ("Error updating container state." , "err" , err )
336344 }
337- }()
345+ }(evt )
338346 }
339347
340348 if a .config .EnableEngineEvents {
@@ -345,8 +353,6 @@ func (a *App) Monitor(ctx context.Context, filterOptions container.FilterOptions
345353 }
346354 }
347355 }
348-
349- slog .Info ("Received event." , "value" , evt )
350356 case err := <- errCh :
351357 if errors .Is (err , io .EOF ) {
352358 slog .Info ("No more events" )
0 commit comments