Skip to content

Add size-based HAProxy log rotation with hourly checks - #673

Merged
Thanhphan1147 merged 14 commits into
mainfrom
copilot/bug-fix-logrotate-configuration
Oct 9, 2026
Merged

Thanhphan1147 merged 14 commits into
mainfrom
copilot/bug-fix-logrotate-configuration

Conversation

Copilot AI commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

  • Rotation policy: Add maxsize 1G while preserving daily rotation, seven retained logs, compression, and the rsyslog reopen hook.
  • Scheduling: Apply an hourly logrotate timer override on install and upgrade, with one-minute accuracy.
  • Ownership: Keep rotation configuration root-owned; preserve existing ownership defaults for other rendered files.
  • Coverage: Add policy, ownership, and upgrade tests; update the changelog and exclude generated virtualenv symlinks.

Why we need it

High-traffic ingresses can exhaust disk space before time-based rotation runs, causing unit errors and service disruption. Size-triggered rotation with hourly checks reduces that risk without adding charm configuration options.

Checklist

  • I followed the contributing guide
  • I added or updated the documentation (if applicable)
  • I updated docs/changelog.md with user-relevant changes
  • I added a change artifact for user-relevant changes in docs/release-notes/artifacts. If no change artifact is necessary, I tagged the PR with the label no-release-note.
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and integration)
  • If integration test modules are used: I updated the workflow configuration
    (e.g., in .github/workflows/integration_tests.yaml, ensure the modules list is correct)
  • If this PR involves a Grafana dashboard: I added a screenshot of the dashboard
  • If this PR involves Terraform: terraform fmt passes and tflint reports no errors

Test plan

354 unit tests passed. Isolated logrotate checks covered repeated same-day size rotation, daily behavior, compression, and retention. Lint, Bandit, CodeQL, and secret scans passed.

Review focus

  • The timer override checks all system logrotate policies hourly; their individual rotation rules remain unchanged.
  • 1G is a rotation threshold, not a hard cap: logs can grow beyond it between checks.
  • No new dependencies, public charm APIs, or workflow changes. Existing deployments receive the new policy on upgrade.

Copilot AI and others added 2 commits October 6, 2026 17:15
Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>
Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix lack of logrotate configuration to prevent disk exhaustion Add size-based HAProxy log rotation with hourly checks Oct 6, 2026
Copilot AI requested a review from Thanhphan1147 October 6, 2026 17:18
Comment thread haproxy-operator/src/haproxy.py
Comment thread haproxy-operator/templates/haproxy.logrotate.j2
Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>
Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>
@Thanhphan1147

Copy link
Copy Markdown
Collaborator

[merge bot]: This PR is now being monitored to automatically rerun failing tests

Comment thread haproxy-operator/src/haproxy.py Outdated
@Thanhphan1147

Copy link
Copy Markdown
Collaborator

@copilot add logrotate to .custom_wordlist

Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>

Copilot AI commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add logrotate to .custom_wordlist

Added logrotate to docs/.custom_wordlist.txt in commit 0fb91e3. The documentation spelling check passes across all 39 files.

Co-authored-by: Thanhphan1147 <42444001+Thanhphan1147@users.noreply.github.com>
@Thanhphan1147
Thanhphan1147 merged commit 39f59f5 into main Oct 9, 2026
181 of 189 checks passed
@Thanhphan1147
Thanhphan1147 deleted the copilot/bug-fix-logrotate-configuration branch October 9, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Lack of logrotate configuration causes disk exhaustion and unit crashes for high-traffic ingresses

5 participants