Skip to content

Fix logs always truncating

Mitchell Nielsen requested to merge fix-logs-always-truncating into master

Summary

Fix log file overwrite on open

Fixes the log file being overwritten upon os.OpenFile.
For some reason this was causing the file to be opened
with 0 bytes, creating the impression that the file
was always being truncated.

With this change, we first ensure the file exists, then
check its size, and only truncate if the size exceeds
the configured maximum.

Changelog: fixed

Context: https://gitlab.com/gitlab-org/charts/components/gitlab-logger/-/merge_requests/10#note_1228176086

Testing

docker-compose -f docker-compose.truncate-logs.yml build && docker-compose -f docker-compose.truncate-logs.yml up

Ensure that the script exists 0.

Edited by Mitchell Nielsen

Merge request reports