[client] introduce client-side event aggregation#6627
Conversation
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
…gregation window Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
…mpv6 Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds aggregating netflow storage, retry-and-ack delivery in the manager, new aggregation fields across protobuf and HTTP schemas, and a mutex unlock adjustment in the GRPC client send path. ChangesNetflow aggregation and reliable delivery
Flow GRPC client locking
Estimated code review effort: 4 (Complex) | ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@client/internal/netflow/manager.go`:
- Around line 223-232: The event retry queue update in the flow sending path is
happening after the first send attempt, which allows a fast ACK to delete the
event before it is tracked. Update the logic in the event loop around m.send,
m.eventsWithoutAcks.StoreEvent, and the related retry path at the other
mentioned block so each event is stored in eventsWithoutAcks before any send
attempt. Keep the existing send/logging behavior in send and the ACK cleanup in
receiveACKs/DeleteEvents unchanged, but ensure the queue insertion happens first
for every event.
- Around line 257-287: The retry path in manager.go is creating a backoff timer
in the send loop, but that value is immediately replaced by the fixed retry
interval, so the exponential backoff never takes effect. Update the retry logic
in the event loop around m.send, retryBackoff.NextBackOff, and m.retryInterval
so failures actually wait using the backoff delay, and only reset to the normal
retry interval after a successful pass; also avoid creating a timer that gets
overwritten without being used.
- Around line 118-130: `startSender()` and `startRetries()` can both reach
`m.send()` at the same time, so writes to the flow stream are still concurrent
even though `GRPCClient.Send()` only protects access to `c.stream`. Update the
send path in the netflow manager to serialize the actual `stream.Send()` call,
either by adding a dedicated mutex around `m.send()`/`GRPCClient.Send()` or by
funneling all outbound flow messages through a single writer goroutine; use the
`startSender`, `startRetries`, and `m.send` symbols to place the fix.
In `@client/internal/netflow/store/memory.go`:
- Around line 73-78: The reset snapshot returned by ResetAggregationWindow() is
missing rnd, which can cause a nil dereference later when GetAggregatedEvents()
handles unknown protocols. Update the snapshot creation in
ResetAggregationWindow() so the returned AggregatingMemory carries over or
initializes rnd before aggregation continues, and make sure the same fix is
applied in the other reset path referenced by the comment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f351fb17-db1c-475a-81c5-52f293b3d3f8
⛔ Files ignored due to path filters (2)
flow/proto/flow.pb.gois excluded by!**/*.pb.goflow/proto/flow_grpc.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (9)
client/internal/netflow/logger/logger.goclient/internal/netflow/manager.goclient/internal/netflow/manager_integration_test.goclient/internal/netflow/store/event_aggregation_test.goclient/internal/netflow/store/memory.goclient/internal/netflow/types/types.goflow/proto/flow.protoshared/management/http/api/openapi.ymlshared/management/http/api/types.gen.go
Release artifactsBuilt for PR head
GHCR images (amd64)
This comment is updated by the Release workflow. Artifact links expire according to the workflow retention policy. |
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@client/internal/netflow/manager.go`:
- Line 287: Fix the codespell failure by correcting the typo in the comment
inside the netflow retry logic, where resetBackoff is used; update the word
“absense” to the proper spelling in that conditional comment so the surrounding
manager.go code passes spell checking.
- Around line 281-289: Guard the retry timer setup in `Manager` so
`time.NewTimer` is never given the `backoff.Stop` value from
`retryBackoff.NextBackOff()`. In the retry path inside `m.send(e)`, check the
returned duration before creating the timer; if the backoff is exhausted, fall
back to `m.retryInterval` instead of using the stopped backoff value. Keep the
change localized to the retry loop logic and the `retryBackoff`/`resetBackoff`
handling in `Manager`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1e3d7165-57f6-4526-9c82-cfcb834d6ced
📒 Files selected for processing (3)
client/internal/netflow/manager.goclient/internal/netflow/store/memory.goflow/client/client.go
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
|



Describe your changes
This is the same as #6394, but using a branch in the main repo.
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
netbirdio/docs#800
Summary by CodeRabbit
window_start,window_end) and counters (num_of_starts,num_of_ends,num_of_drops).