Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Add log rotation for Gunicorn access and error logs #3

Closed
wants to merge 6 commits into from

Conversation

weiiwang01
Copy link
Contributor

The original plan for log rotation was to use the RotatingFileHandler logging handler. However, the RotatingFileHandler doesn't work in multiprocessing mode, as noted in https://bugs.python.org/issue43107. So instead, in this pull request, using a small Python script to perform the log rotation.

@weiiwang01 weiiwang01 requested a review from a team as a code owner April 3, 2024 05:48
Copy link

@cbartz cbartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some minor comments

paas_app_charmer/_gunicorn/logrotate.py Outdated Show resolved Hide resolved
paas_app_charmer/_gunicorn/logrotate.py Show resolved Hide resolved
tests/unit/flask/test_charm.py Show resolved Hide resolved
cbartz
cbartz previously approved these changes Apr 3, 2024
Copy link

github-actions bot commented Apr 3, 2024

Test coverage for e716c55

Name                                           Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------------------------
paas_app_charmer/__init__.py                       1      0      0      0   100%
paas_app_charmer/_gunicorn/__init__.py             0      0      0      0   100%
paas_app_charmer/_gunicorn/charm.py              116     29     18      6    72%   60-62, 147-148, 150-151, 171->exit, 181-185, 190, 196-201, 205-206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246
paas_app_charmer/_gunicorn/charm_state.py         63      1      6      1    97%   194
paas_app_charmer/_gunicorn/logrotate.py           35     14     10      1    58%   46-63
paas_app_charmer/_gunicorn/observability.py       25      0      2      0   100%
paas_app_charmer/_gunicorn/secret_storage.py      14      1      0      0    93%   39
paas_app_charmer/_gunicorn/webserver.py           76      5     16      2    92%   19, 155, 167-173
paas_app_charmer/_gunicorn/wsgi_app.py            60      1     22      1    98%   80
paas_app_charmer/database_migration.py            34      0      2      0   100%
paas_app_charmer/databases.py                     38      3     13      2    90%   82, 97-98
paas_app_charmer/django/__init__.py                2      0      0      0   100%
paas_app_charmer/django/charm.py                  45     13     10      0    65%   72-77, 89, 97-114
paas_app_charmer/exceptions.py                     5      0      0      0   100%
paas_app_charmer/flask/__init__.py                 2      0      0      0   100%
paas_app_charmer/flask/charm.py                   37      0      6      0   100%
paas_app_charmer/helpers.py                        9      0      2      1    91%   18->20
paas_app_charmer/secret_storage.py                40      6     16      4    79%   50, 54->53, 55->57, 85, 103-108
------------------------------------------------------------------------------------------
TOTAL                                            602     73    123     18    86%

Static code analysis report

Run started:2024-04-03 10:31:51.740433

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 1290
  Total lines skipped (#nosec): 0
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 2

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Copy link
Contributor

@jdkandersson jdkandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to discuss this more before we can make progress, the design thinking is not complete yet

@canonical canonical deleted a comment from jdkandersson Apr 4, 2024
@canonical canonical deleted a comment from jdkandersson Apr 4, 2024
@weiiwang01 weiiwang01 closed this Apr 4, 2024
@weiiwang01 weiiwang01 deleted the log-rotate branch September 3, 2024 09:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants