Repository navigation
fix(image): rotate logs as their owner so rotation works without CAP_FOWNER - #16
Merged
Merged
Conversation
added 3 commits
November 19, 2026 16:28
… CAP_FOWNER
In the container the control plane starts (cap_drop ALL + SETUID, SETGID,
DAC_OVERRIDE, CHOWN, read-only rootfs, no-new-privileges) logrotate ran as
root and failed on every run: copytruncate creates the copy, chowns it to
proxy and then sets the log's ACL on it, which needs ownership or
CAP_FOWNER ("error: setting ACL for /var/log/squid/access.log.1: Operation
not permitted"). It left an empty 0600 copy, never truncated the log, and
later runs renamed the empty files to *.backup; the errors went to
/dev/null. access.log grew without limit and log_retention_days deleted
nothing.
- logrotate.conf: "su proxy proxy" for access.log and cache.log, so the
rotation runs as the files' owner (seteuid via SETUID/SETGID, no new
capability; also what logrotate(8) recommends for directories a
non-privileged user controls).
- entrypoint: delete only empty files with logrotate's names
(access.log.<digit>*, cache.log.<digit>*) left by the old images, and say
how many; anything with content stays.
- a failed run logs one line to the container log: error count and the
first error.
- Docker integration tests with containers from the real DockerService:
rotation and retention, the upgrade from a 7.3.9 volume, a failed run
logged once; all three fail against the 7.3.9 and 7.3.7 images.
- docs: rotation, how to check it, what happens to the backlog after the
upgrade and how to trim it to the retention (T13).
… tests It passed against the broken rotation (an empty access.log.1.gz counted as a rotation, the history query read the never truncated access.log) and no runner called it. test_log_rotation_* in controlplane/tests/test_docker_integration.py (cp-docker-it in run.sh e2e) cover the same and fail against the broken images.
…2.gz trim command From the cold review: the backlog is deleted about log_retention_days + 1 to 2 days after the upgrade (one day until it becomes access.log.1, then log_retention_days rotations); the copytruncate window grows with the log, so the first rotation of a GB backlog can lose a few lines; the trim command for access.log.2.gz is written out in full.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Log rotation inside the container never succeeded. logrotate 3.21 copies the file's ACL onto the
rotated copy; as root without
CAP_FOWNER(the container drops all capabilities except SETUID,SETGID, DAC_OVERRIDE, CHOWN) that fails with
setting ACL for /var/log/squid/access.log.1: Operation not permitted. The error was hidden by2>/dev/null, soaccess.loggrew without limit(2.46 GB in three weeks on a production proxy) and empty 0600 leftovers piled up.
Fix
su proxy proxyin both logrotate stanzas, so logrotate acts as the file owner and needs noextra capability. No capability is added.
copytruncate loss window, and a tested command to trim the backlog by hand.
Tests
test_log_rotation_*(cp-docker-it, heavy tier): rotation with the realhardened container settings, leftover cleanup, error reporting.
scripts/tests/logrotate_smoke.shremoved, superseded by those tests.