Skip to content

fix(watch): stop re-printing cloud audit rows when the dedup set hits its limit - #445

Open
leninworld wants to merge 1 commit into
solongate:mainfrom
leninworld:fix-watch-cloud-dedup-issue-223
Open

leninworld wants to merge 1 commit into
solongate:mainfrom
leninworld:fix-watch-cloud-dedup-issue-223

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

solongate watch prints cloud audit entries it already showed once its dedup set passes 4096 IDs. pollCloud replaced the set with an empty map before checking the current batch, so every entry in that batch (up to 50 newest rows) was printed again, each time the limit was crossed.

The dedup now runs first and the set is bounded afterwards: newCloudEntries returns the entries whose IDs aren't in seen, marks the batch as seen, and only when the set has grown past seenLimit keeps just the current batch's IDs. Each poll asks for the newest 50 entries, so an ID older than the current batch can't come back in the next poll, and nothing already shown is printed twice. This is the same approach as the Live panel fix for #205 (evict IDs that fell out of the window instead of wiping everything). The rows are built exactly as before.

Tests: TestNewCloudEntriesShrinksAfterDedup in watch_test.go starts with a set already over the limit that holds two of the batch's three IDs. It expects only the new entry back and a set of exactly the three batch IDs. main has no separate helper, so I checked the base behaviour by putting the old order (wipe, then check) into the helper: the test then fails with len(fresh) = 3, want 1.

Tested with Go 1.26.11 on macOS (arm64), in packages/cli:

  • go test ./observability/ passes; go vet ./observability/ is clean; gofmt -l is empty for both changed files.
  • go test -count=1 ./... passes except cli/policy (TestProtectAdd, TestProtectList), whose TempDir cleanup fails with operation not permitted on the protected file. It fails the same way on main here, so it's my environment.

I didn't run solongate watch against a live cloud account, so the 4096-entry case is covered by the unit test only.

Fixes #223

…ate#223)

pollCloud wiped the whole seen map once it passed seenLimit, right before
checking the current batch, so the newest entries that had already been
printed were printed again. Check the batch first, then keep only the
batch's IDs when the set is over the limit; older IDs cannot return in the
next newest-50 poll.

Signed-off-by: Lenin Mookiah <2639584+leninworld@users.noreply.github.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity · 0 duplication

Metric Results
Complexity 15
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

✅ No blocking issues noticed

No blocking findings were identified. The implementation has a recommended scenario covered, but regression coverage is missing for the at-or-below-limit case and for batches containing only previously seen IDs.

Test suggestions

  • A batch containing both previously seen and new IDs is deduplicated, and an over-limit set is replaced with the current batch IDs.
  • A set at or below the limit retains its existing IDs while adding new batch IDs.
  • A batch containing only previously seen IDs produces no fresh entries.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. A set at or below the limit retains its existing IDs while adding new batch IDs.
2. A batch containing only previously seen IDs produces no fresh entries.

TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli/observability: pollCloud dedup map full wipe re-emits duplicate cloud audit entries

1 participant