mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +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
|
return nil
|
||||||
|
|
||||||
case event := <-eventsChan:
|
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 event.Action == dockerTypesEvents.ActionStart || event.Action == dockerTypesEvents.ActionDie {
|
||||||
if err := d.checkContainers(ctx, monitChan, deleteChan); err != nil {
|
if err := d.checkContainers(ctx, monitChan, deleteChan); err != nil {
|
||||||
d.logger.Warnf("Failed to check containers: %v", err)
|
d.logger.Warnf("Failed to check containers: %v", err)
|
||||||
|
@ -633,14 +627,17 @@ func (d *DockerSource) WatchContainer(ctx context.Context, monitChan chan *Conta
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// No immediate error, seems to have reconnected successfully
|
// No immediate error, seems to have reconnected successfully
|
||||||
d.logger.Info("Successfully reconnected to Docker events")
|
|
||||||
errorRetryBackoff = initialBackoff
|
errorRetryBackoff = initialBackoff
|
||||||
|
d.logger.Info("Successfully reconnected to Docker events")
|
||||||
eventsChan = newEventsChan
|
eventsChan = newEventsChan
|
||||||
errChan = newErrChan
|
errChan = newErrChan
|
||||||
goto reconnected
|
goto reconnected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 in the main loop with new channels
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue