[#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
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
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>
This commit is contained in:
parent
471aeeaff3
commit
3e28d71121
1 changed files with 1 additions and 1 deletions
|
@ -224,7 +224,7 @@ func (a *auditPatchStream) Send(ctx context.Context, req *object.PatchRequest) e
|
|||
if err != nil {
|
||||
a.failed = true
|
||||
}
|
||||
if !errors.Is(err, util.ErrAbortStream) { // CloseAndRecv will not be called, so log here
|
||||
if err != nil && !errors.Is(err, util.ErrAbortStream) { // CloseAndRecv will not be called, so log here
|
||||
audit.LogRequestWithKey(ctx, a.log, objectGRPC.ObjectService_Patch_FullMethodName, a.key,
|
||||
audit.TargetFromContainerIDObjectID(a.containerID, a.objectID),
|
||||
!a.failed)
|
||||
|
|
Loading…
Add table
Reference in a new issue