diff options
| author | Marcin Juszkiewicz <marcin.juszkiewicz+kolla@linaro.org> | 2022-04-05 16:53:34 +0200 |
|---|---|---|
| committer | Radosław Piliszek <radoslaw.piliszek@gmail.com> | 2022-09-27 07:40:06 +0000 |
| commit | 878b00013b01e3d02a704ce7c9fac1629cd1a705 (patch) | |
| tree | 218b3a4d1470a0c55006577d912d5369d60a8fb5 /docker/cron | |
| parent | ea3ed3f9332dbd7f369ca49806ee04000881c3c7 (diff) | |
| download | kolla-878b00013b01e3d02a704ce7c9fac1629cd1a705.tar.gz kolla-878b00013b01e3d02a704ce7c9fac1629cd1a705.zip | |
Move to CentOS Stream 9
OpenStack 'zed' requires Python 3.8+ so RHEL 8 family has to go.
This changeset moves to CentOS Stream 9 while move to RockyLinux 9 is
planned as final solution.
CI moved to CentOS Stream 9 nodes.
Depends-on: https://review.opendev.org/c/openstack/kolla-ansible/+/839715
Change-Id: I113b9984294cf8663d3fc0c8840320e1d40ea731
Diffstat (limited to 'docker/cron')
| -rw-r--r-- | docker/cron/Dockerfile.j2 | 5 | ||||
| -rw-r--r-- | docker/cron/extend_start.sh | 20 | ||||
| -rwxr-xr-x | docker/cron/logrotate | 18 |
3 files changed, 35 insertions, 8 deletions
diff --git a/docker/cron/Dockerfile.j2 b/docker/cron/Dockerfile.j2 index fbbd68500..860fae576 100644 --- a/docker/cron/Dockerfile.j2 +++ b/docker/cron/Dockerfile.j2 @@ -12,6 +12,11 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build 'cronie', 'logrotate' ] %} + +# NOTE(hrw): In RHEL 9 family it is done by systemd timer, we want cron to +# handle it. +COPY logrotate /etc/cron.daily/logrotate + {% elif base_package_type == 'deb' %} {% set cron_packages = [ 'cron', diff --git a/docker/cron/extend_start.sh b/docker/cron/extend_start.sh index 7f78e8500..3476302e1 100644 --- a/docker/cron/extend_start.sh +++ b/docker/cron/extend_start.sh @@ -3,15 +3,19 @@ CRON_LOGROTATE_CURRENT_PATH="$(find /etc/cron* -name logrotate)" CRON_LOGROTATE_CURRENT_SCHEDULE=$(echo "${CRON_LOGROTATE_CURRENT_PATH}" | sed -r 's/(.*)(hourly|daily|weekly|monthly)(.*)/\2/g') -# Pass only for hourly|daily|weekly|monthly -if [[ "${KOLLA_LOGROTATE_SCHEDULE:-undefined}" =~ hourly|daily|weekly|monthly ]]; then +if [ -z $CRON_LOGROTATE_CURRENT_PATH ]; then + echo "logrotate is not handled by cron" +else + # Pass only for hourly|daily|weekly|monthly + if [[ "${KOLLA_LOGROTATE_SCHEDULE:-undefined}" =~ hourly|daily|weekly|monthly ]]; then - CRON_LOGROTATE_DESIRED_PATH="/etc/cron.${KOLLA_LOGROTATE_SCHEDULE}/logrotate" + CRON_LOGROTATE_DESIRED_PATH="/etc/cron.${KOLLA_LOGROTATE_SCHEDULE}/logrotate" - if [[ "${CRON_LOGROTATE_CURRENT_PATH}" != "${CRON_LOGROTATE_DESIRED_PATH}" ]]; then - mv ${CRON_LOGROTATE_CURRENT_PATH} ${CRON_LOGROTATE_DESIRED_PATH} - CRON_LOGROTATE_CURRENT_SCHEDULE="${KOLLA_LOGROTATE_SCHEDULE}" + if [[ "${CRON_LOGROTATE_CURRENT_PATH}" != "${CRON_LOGROTATE_DESIRED_PATH}" ]]; then + mv ${CRON_LOGROTATE_CURRENT_PATH} ${CRON_LOGROTATE_DESIRED_PATH} + CRON_LOGROTATE_CURRENT_SCHEDULE="${KOLLA_LOGROTATE_SCHEDULE}" + fi fi -fi -echo "[i] Cron schedule for logrotate is currently set to: ${CRON_LOGROTATE_CURRENT_SCHEDULE}." + echo "[i] Cron schedule for logrotate is currently set to: ${CRON_LOGROTATE_CURRENT_SCHEDULE}." +fi diff --git a/docker/cron/logrotate b/docker/cron/logrotate new file mode 100755 index 000000000..1ac157001 --- /dev/null +++ b/docker/cron/logrotate @@ -0,0 +1,18 @@ +#!/bin/sh + +# skip in favour of systemd timer +if [ -d /run/systemd/system ]; then + exit 0 +fi + +# this cronjob persists removals (but not purges) +if [ ! -x /usr/sbin/logrotate ]; then + exit 0 +fi + +/usr/sbin/logrotate /etc/logrotate.conf +EXITVALUE=$? +if [ $EXITVALUE != 0 ]; then + /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" +fi +exit $EXITVALUE |
