mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
enhance: After a reconnect we always check the containers to attempt to resurrect or else we wait until a event comes in which it may not
This commit is contained in:
parent
1081d615ee
commit
38810df96b
1 changed files with 4 additions and 7 deletions
|
@ -569,12 +569,6 @@ func (d *DockerSource) WatchContainer(ctx context.Context, monitChan chan *Conta
|
|||
return nil
|
||||
|
||||
case event := <-eventsChan:
|
||||
// Reset backoff on successful event
|
||||
if errorRetryBackoff > initialBackoff {
|
||||
errorRetryBackoff = initialBackoff
|
||||
d.logger.Debug("Successfully receiving Docker events, reset backoff timer")
|
||||
}
|
||||
|
||||
if event.Action == dockerTypesEvents.ActionStart || event.Action == dockerTypesEvents.ActionDie {
|
||||
if err := d.checkContainers(ctx, monitChan, deleteChan); err != nil {
|
||||
d.logger.Warnf("Failed to check containers: %v", err)
|
||||
|
@ -633,14 +627,17 @@ func (d *DockerSource) WatchContainer(ctx context.Context, monitChan chan *Conta
|
|||
|
||||
default:
|
||||
// No immediate error, seems to have reconnected successfully
|
||||
d.logger.Info("Successfully reconnected to Docker events")
|
||||
errorRetryBackoff = initialBackoff
|
||||
d.logger.Info("Successfully reconnected to Docker events")
|
||||
eventsChan = newEventsChan
|
||||
errChan = newErrChan
|
||||
goto reconnected
|
||||
}
|
||||
}
|
||||
reconnected:
|
||||
// We check containers after a reconnection because the docker daemon might have restarted
|
||||
// and the container tombs may have self deleted
|
||||
d.checkContainers(ctx, monitChan, deleteChan)
|
||||
// Continue in the main loop with new channels
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue