Skip to content

Reduce notification delay - #4768

Draft
vmartinv wants to merge 1 commit into
crowdsecurity:masterfrom
vmartinv:csplugin-threshold-flush
Draft

vmartinv wants to merge 1 commit into
crowdsecurity:masterfrom
vmartinv:csplugin-threshold-flush

Conversation

@vmartinv

@vmartinv vmartinv commented Oct 18, 2026 •

Copy link
Copy Markdown

Takes the time to block an address into sub-second territory.

A bouncer polls LAPI, every 10s by default. Pushing new bans to the firewall with a notification plugin (http plugin -> small endpoint that adds the IP to the bouncer's set) brings that down to ~1s, but no lower: with group_threshold set, the watcher only flushes on its 1s ticker, so every notification waits up to a second. This PR flushes as soon as the threshold is reached, so a ban reaches the firewall in well under a second.

The 6-alert burst in TestBrokerRunGroupThreshold used to be delivered as 4 + 2 because both batches landed before a tick; now the first 4 go out immediately, so the test sends 4 and expects one notification.

How it was tested

go test ./pkg/csplugin/ -race. The new TestPluginAlertCountWatcherFlushesImmediately fails without the change and passes with it.

Checklist

  • One concern only.
  • No break to LAPI/CAPI payloads, database schema, config keys, or cscli -o json|raw output.
  • A human has reviewed this diff line by line.
  • A human has tested this change, not only an agent.

AI assistance used: mostly

🤖 Generated with Claude Code

https://claude.ai/code/session_01XuiYfhB3KFGAAioDt2dPus

@github-actions

Copy link
Copy Markdown

@vmartinv: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@github-actions

Copy link
Copy Markdown

@vmartinv: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

With group_threshold set, the watcher only flushed on its 1s ticker.
Flush as soon as the threshold is reached instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XuiYfhB3KFGAAioDt2dPus
@vmartinv
vmartinv force-pushed the csplugin-threshold-flush branch from 570921c to bcd4f3d Compare October 18, 2026 10:47
@vmartinv vmartinv changed the title fix(csplugin): flush notifications as soon as group_threshold is met Reduce notification delay Oct 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant