btlqql opened a new pull request, #7148:
URL: https://github.com/apache/rocketmq-dashboard/pull/7148
## What is the purpose of the change
`POST /api/audit-logs/cleanup` deletes at most `CLEANUP_BATCH_SIZE *
CLEANUP_MAX_BATCHES` = 500 x 20 = 10 000 rows per call, but answered with the
deleted count alone. A deployment with more than 10 000 expired rows was told
the retention window had been applied while older rows survived, and the caller
had no way to see it: `AuditService.cleanupLogs` returned a bare `int` from
`AuditRepository.deleteBefore`, so "the sweep deleted everything it found" and
"the sweep ran out of budget" looked identical. The response now carries the
ceiling signal next to the count.
## Brief changelog
- `AuditCleanupResultVO`: new response VO with `deleted` and `truncated`,
documenting that a truncated sweep must not be reported as a complete cleanup.
- `AuditService.cleanupLogs`: returns the VO, computes `truncated` from the
per-call row ceiling (`CLEANUP_BATCH_SIZE * CLEANUP_MAX_BATCHES`) instead of
dropping the signal, and logs a warning naming the ceiling, the cutoff age and
the deleted count when it is hit. The validation and the bounded delete call
are unchanged.
- `AuditController.cleanupLogs`: returns `Result<AuditCleanupResultVO>`, so
the JSON gains `truncated` next to the existing `deleted` (additive; the
previous field and its type are untouched).
- `AuditServiceTest`: the existing bounded-batch test now asserts the flag
is false, plus `cleanupLogsReportsTheCeilingInsteadOfACompleteSweepTest`, which
stubs a ceiling-sized deletion and expects `truncated = true`.
- `AuditControllerTest`: existing stubbings moved to the VO, plus
`cleanupLogsShouldDiscloseASweepThatHitItsCeilingTest`, which asserts
`$.data.deleted = 10000` and `$.data.truncated = true`.
## Verifying this change
- red: `cd server && mvn -o -B -ntp test
-Dtest='AuditControllerTest#cleanupLogsShouldDiscloseASweepThatHitItsCeilingTest'`
on the unmodified trunk -> `java.lang.AssertionError: No value at JSON path
"$.data.truncated"` / `Caused by: com.jayway.jsonpath.PathNotFoundException: No
results for path: $['data']['truncated']`; `[ERROR] Tests run: 1, Failures: 1,
Errors: 0` (log: `audit-cleanup-red.log`). The assertion compiles against the
old contract, so this is a behavioural red, not a compile failure.
- green: `cd server && mvn -o -B -ntp test
-Dtest='AuditServiceTest,AuditControllerTest'` -> `Tests run: 13, Failures: 0,
Errors: 0 -- in AuditControllerTest`, `Tests run: 22, Failures: 0, Errors: 0 --
in AuditServiceTest`, `Tests run: 35, Failures: 0, Errors: 0`, `BUILD SUCCESS`,
and `checkstyle: You have 0 Checkstyle violations` (log:
`audit-cleanup-green.log`).
Not verified here: no live MySQL deployment with more than 10 000 expired
rows was involved - the contract is pinned by the service and MockMvc tests.
Two limits are worth stating:
- `truncated` means the sweep consumed its entire per-call ceiling, so
expired rows *may* remain. A table whose expired rows exactly equal 10 000 also
reports `true`; proving that a row remains would need an extra existence probe
in the repository, which this change does not add.
- The web page still toasts `audit.cleanupSuccess` (the day window) and does
not read the flag: `web/src/api/ops.ts` types the response as `{ data: {
deleted: number } }`, and surfacing the new field in the UI needs the shared
i18n catalogue, which is outside this change. The endpoint contract is the part
this PR fixes.
## Checklist
- [x] one issue, one PR: Fixes #5976
- [x] regression test added on both sides of the contract (service and
endpoint)
- [x] targeted suites re-run, Checkstyle clean
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]