[#1659] audit: Fix duplicated request logs
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 1m6s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m17s
Tests and linters / Run gofumpt (pull_request) Successful in 2m36s
Tests and linters / Staticcheck (pull_request) Successful in 2m56s
Tests and linters / Tests (pull_request) Successful in 3m3s
Tests and linters / Tests with -race (pull_request) Successful in 3m0s
Tests and linters / Lint (pull_request) Successful in 3m5s
Tests and linters / gopls check (pull_request) Successful in 3m40s
DCO action / DCO (pull_request) Successful in 26s
Build / Build Components (pull_request) Successful in 1m26s

When we do `object put` with audit enabled we get two entries in
logs: with and without object id.
This fix is supposed to keep only one audit log entry with OID.

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
Ekaterina Lebedeva 2025-03-03 04:21:53 +03:00
parent 0991077cb3
commit cab33ead2e

View file

@ -163,7 +163,7 @@ func (a *auditPutStream) Send(ctx context.Context, req *object.PutRequest) error
if err != nil {
a.failed = true
}
if !errors.Is(err, util.ErrAbortStream) { // CloseAndRecv will not be called, so log here
if !errors.Is(err, util.ErrAbortStream) && a.objectID != nil { // CloseAndRecv will not be called, so log here
audit.LogRequestWithKey(ctx, a.log, objectGRPC.ObjectService_Put_FullMethodName, a.key,
audit.TargetFromContainerIDObjectID(a.containerID, a.objectID),
!a.failed)