audit: Fix duplicated log in Patch method #1666

Merged
dstepanov-yadro merged 1 commit from elebedeva/frostfs-node:fix/duplicated-logs-patch into master 2025-03-07 13:27:08 +00:00
Member

Same problem as in #1659.

When we do object patch with audit enabled we get several duplicated entries in logs.

info	audit/request.go:42	audit event log record	{"operation": "/neo.fs.v2.object.ObjectService/Patch", "object": "CDxA4SNw4u3nzn1SBGjfXR5dE615CvcUCjUYYUraTFsJ/5cXfJWrG1vAE4yHcp6MV43YTAcVcQQS3eWzGTDPjj8UN", "subject": "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "success": true, "trace_id": "5b5bcb19cbec341d196173def9c6cef7"}
info	audit/request.go:42	audit event log record	{"operation": "/neo.fs.v2.object.ObjectService/Patch", "object": "CDxA4SNw4u3nzn1SBGjfXR5dE615CvcUCjUYYUraTFsJ/7KHFjFWJrSKWPjHQ2C3cbi94H9coxugwN1qQhr5G2GVU", "subject": "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "success": true, "trace_id": "5b5bcb19cbec341d196173def9c6cef7"}

Now:

info	audit/request.go:42	audit event log record	{"operation": "/neo.fs.v2.object.ObjectService/Patch", "object": "ADdhY7LDYmHjSd1RJnmzWm1WzXBk57s4K6Xjsf3Vo4v8/HkRQbTnw9GvTy1KgNd3qewrmy85TRJU4vUMHtktDxaNs", "subject": "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "success": true, "trace_id": "7af928f8d2cb1048fc83b0b6e8f14eab"}

Signed-off-by: Ekaterina Lebedeva ekaterina.lebedeva@yadro.com

Same problem as in #1659. When we do `object patch` with audit enabled we get several duplicated entries in logs. ``` info audit/request.go:42 audit event log record {"operation": "/neo.fs.v2.object.ObjectService/Patch", "object": "CDxA4SNw4u3nzn1SBGjfXR5dE615CvcUCjUYYUraTFsJ/5cXfJWrG1vAE4yHcp6MV43YTAcVcQQS3eWzGTDPjj8UN", "subject": "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "success": true, "trace_id": "5b5bcb19cbec341d196173def9c6cef7"} info audit/request.go:42 audit event log record {"operation": "/neo.fs.v2.object.ObjectService/Patch", "object": "CDxA4SNw4u3nzn1SBGjfXR5dE615CvcUCjUYYUraTFsJ/7KHFjFWJrSKWPjHQ2C3cbi94H9coxugwN1qQhr5G2GVU", "subject": "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "success": true, "trace_id": "5b5bcb19cbec341d196173def9c6cef7"} ``` Now: ``` info audit/request.go:42 audit event log record {"operation": "/neo.fs.v2.object.ObjectService/Patch", "object": "ADdhY7LDYmHjSd1RJnmzWm1WzXBk57s4K6Xjsf3Vo4v8/HkRQbTnw9GvTy1KgNd3qewrmy85TRJU4vUMHtktDxaNs", "subject": "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "success": true, "trace_id": "7af928f8d2cb1048fc83b0b6e8f14eab"} ``` Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva added 1 commit 2025-03-07 10:00:36 +00:00
[#XXXX] audit: Fix duplicated log in Patch method
Some checks failed
DCO action / DCO (pull_request) Failing after 41s
Vulncheck / Vulncheck (pull_request) Successful in 1m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m22s
Build / Build Components (pull_request) Successful in 1m25s
Tests and linters / Tests with -race (pull_request) Successful in 3m33s
Tests and linters / gopls check (pull_request) Successful in 3m45s
Tests and linters / Tests (pull_request) Successful in 4m22s
Tests and linters / Run gofumpt (pull_request) Successful in 4m32s
Tests and linters / Lint (pull_request) Successful in 4m47s
Tests and linters / Staticcheck (pull_request) Successful in 4m43s
3e28d71121
When we do `object patch` with audit enabled we get several
duplicated entries in logs.

`object patch` request is logged in 2 places:
1. `(*auditPatchStream) CloseAndRecv()` - when the client closes
   the request stream or when stream gets aborted.
2. `(*auditPatchStream) Send()` - when stream was NOT aborted.

`Send()` doesn't check if `err != nil` before logging.
It led to to logging on every `Send()` call.

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
requested reviews from storage-core-committers, storage-core-developers 2025-03-07 10:00:37 +00:00
elebedeva force-pushed fix/duplicated-logs-patch from 3e28d71121 to 598bcd16e3 2025-03-07 10:01:43 +00:00 Compare
fyrchik approved these changes 2025-03-07 10:47:40 +00:00
dstepanov-yadro approved these changes 2025-03-07 13:26:36 +00:00
dstepanov-yadro merged commit bd61f7bf0a into master 2025-03-07 13:27:08 +00:00
achuprov approved these changes 2025-03-07 13:27:15 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1666
No description provided.