Skip to content

Commit

Permalink
🐛 Fix logic for update max failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuHa committed Apr 29, 2024
1 parent fc41962 commit 2fc152e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,13 @@ func handleNextServeHTTP(bouncer *Bouncer, remoteIP string, rw http.ResponseWrit
}

func handleStreamTicker(bouncer *Bouncer) {
bouncer.log.Debug(fmt.Sprintf("handleStreamTicker:start isCrowdsecStreamHealthy:%t", isCrowdsecStreamHealthy))
if err := handleStreamCache(bouncer); err != nil {
updateFailure++
if updateFailure >= bouncer.updateMaxFailure || bouncer.updateMaxFailure == -1 {
bouncer.log.Debug(fmt.Sprintf("handleStreamTicker:%d failure to reach crowdsec", updateFailure))
if updateFailure >= bouncer.updateMaxFailure && bouncer.updateMaxFailure != -1 {
isCrowdsecStreamHealthy = false
}
updateFailure++
bouncer.log.Error(err.Error())
} else {
isCrowdsecStreamHealthy = true
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ services:
- "traefik.http.middlewares.crowdsec.plugin.bouncer.enabled=true"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.loglevel=DEBUG"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdsecappsecenabled=true"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdsecmode=stream"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.UpdateIntervalSeconds=10"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.UpdateMaxFailure=-1"
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdseclapikey=40796d93c2958f9e58345514e67740e5="

crowdsec:
Expand Down

0 comments on commit 2fc152e

Please sign in to comment.