~dashmage/charm-logrotated:bug-2019990/random-time-cronjob

Last commit made on 2023-06-01
Get this branch:
git clone -b bug-2019990/random-time-cronjob https://git.launchpad.net/~dashmage/charm-logrotated
Only Ashley James can upload to this branch. If you are Ashley James please log in for upload directions.

Branch merges

Branch information

Name:
bug-2019990/random-time-cronjob
Repository:
lp:~dashmage/charm-logrotated

Recent commits

af917de... by Ashley James

Implement random time functionality for daily cronjob.

- The "random" functionality was not working earlier since the Ubuntu
  cron package does not support the feature. So a new method was
  added to generate a random time within a range. This will provide
  the random time to be placed in /etc/crontab for the daily cronjob.
- Remove condition to check if `logrotate-cronjob-frequency` is
 `daily` before applying the cron daily schedule.
- Modify existing unit tests to accomodate the changes with the random
  time functionality.
- Fix validation of random time and add another unit test for the
  validation.
- Edit config.yaml to add a clear disclaimer about
  `update-cron-daily-schedule`.

3cddd62... by Ashley James

Remove call to install_cronjob during charm's cronjob execution.

- The install_cronjob method is used to place the charm's cronjob
  (charm-logrotate) file in the right location at cron.{hourly, daily,
  weekly, monthly}. It also takes care of modifying the cron.daily time
  for controlling the schedule for /etc/cron.daily/logrotate cronjob.
- The cronjob is used to update the /etc/logrotate.d conf files
  with the latest configuration specified by the charm. As some packages
  might change these conf files, updating them regularly through the
  cron job would ensure that the charm's configuration take precedence.
- The cronjob does not need to call the install_cronjob method
  because the cronjob is already set up as part of the install/
  config-changed hooks. It can also be manually triggered via the
  action. The charm's cronjob would only need to update the logrotate
  files at a regular interval and not install the cronjob again.

10ab2f6... by Ashley James

Manage charm's daily cronjob from /etc/crontab instead of root user's crontab.

Reviewed-on: https://code.launchpad.net/~dashmage/charm-logrotated/+git/charm-logrotated/+merge/443242
Reviewed-by: Eric Chen <email address hidden>
Reviewed-by: 🤖 prod-jenkaas-bootstack <email address hidden>
Reviewed-by: JamesLin <email address hidden>

13acd7b... by Ashley James

Remove cron daily job from root user crontab.

Currently while modifying cron daily job execution time, it is
updated in the root user's crontab (/var/spool/cron/crontabs/root).
This leads to a duplicate execution along with the execution of
cron.daily scripts in /etc/crontab.

This commit aims to manage the execution of the charms' daily cron job
solely from the system crontab, /etc/crontab. It also fixes the existing
unit test `test_cron_daily_schedule` and mocks the crontab instead of
directly writing to it.

53248e0... by Ashley James

Fix flaky functional test

- Use tenacity.Retrying while checking for file in
`test_reconfigure_cronjob_frequency`

55f7ed6... by Mert Kirpici

LP #2017795

Reviewed-on: https://code.launchpad.net/~mertkirpici/charm-logrotated/+git/charm-logrotated/+merge/442359
Reviewed-by: 🤖 prod-jenkaas-bootstack <email address hidden>
Reviewed-by: Erhan Sunar <email address hidden>
Reviewed-by: Chi Wai CHAN <email address hidden>

7316795... by Mert Kirpici

fix: cleanup old cronjobs upon config change

A change in cronjob frequency used to leave the old cronjobs behind,
causing unnecessary execution. This patch is mitigating that behavior
and also adds some tests.

Works-on: 2017795
Signed-off-by: Mert Kırpıcı <email address hidden>

017fd99... by Chi Wai CHAN

Add "size" directive for config option "override". This is mutually exclusive with "interval" directive, and if both "size" and "interval" are provided, "size" takes the precedence.

Reviewed-on: https://code.launchpad.net/~raychan96/charm-logrotated/+git/charm-logrotated/+merge/442228
Reviewed-by: Eric Chen <email address hidden>
Reviewed-by: 🤖 prod-jenkaas-bootstack <email address hidden>
Reviewed-by: Erhan Sunar <email address hidden>

e5f3e29... by Chi Wai CHAN

Add examples for "size" directive in config.yaml.

cf8e129... by Chi Wai CHAN

Add functional test for config option "override".