diff options
| author | Zuul <zuul@review.opendev.org> | 2026-07-08 16:33:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2026-07-08 16:33:45 +0000 |
| commit | 44b4d81399792f539716618953f2cafa64086a5c (patch) | |
| tree | 4699d7e068e6dd842a9f1f247ca2f150d60d5e27 /kolla/docker/cron | |
| parent | b3803eb9f951acd63018ab8ba69bcbd1a2de5c93 (diff) | |
| parent | db35ac8d793506bc43b62e7e39d27a75de1043ed (diff) | |
| download | kolla-44b4d81399792f539716618953f2cafa64086a5c.tar.gz kolla-44b4d81399792f539716618953f2cafa64086a5c.zip | |
Merge "Migrate to pyproject.toml"
Diffstat (limited to 'kolla/docker/cron')
| -rw-r--r-- | kolla/docker/cron/Dockerfile.j2 | 35 | ||||
| -rw-r--r-- | kolla/docker/cron/extend_start.sh | 21 | ||||
| -rwxr-xr-x | kolla/docker/cron/logrotate | 18 |
3 files changed, 74 insertions, 0 deletions
diff --git a/kolla/docker/cron/Dockerfile.j2 b/kolla/docker/cron/Dockerfile.j2 new file mode 100644 index 000000000..d3a9213ac --- /dev/null +++ b/kolla/docker/cron/Dockerfile.j2 @@ -0,0 +1,35 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} +{% block labels %} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" +{% endblock %} + +{% block cron_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{% if base_package_type == 'rpm' %} + {% set cron_packages = [ + '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', + 'logrotate' + ] %} +{% endif %} + +{{ macros.install_packages(cron_packages | customizable("packages")) }} + +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 644 /usr/local/bin/kolla_extend_start + +{{ macros.kolla_patch_sources() }} + +{% block cron_footer %}{% endblock %} +{% block footer %}{% endblock %} diff --git a/kolla/docker/cron/extend_start.sh b/kolla/docker/cron/extend_start.sh new file mode 100644 index 000000000..3476302e1 --- /dev/null +++ b/kolla/docker/cron/extend_start.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +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') + +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" + + 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 + + echo "[i] Cron schedule for logrotate is currently set to: ${CRON_LOGROTATE_CURRENT_SCHEDULE}." +fi diff --git a/kolla/docker/cron/logrotate b/kolla/docker/cron/logrotate new file mode 100755 index 000000000..1ac157001 --- /dev/null +++ b/kolla/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 |
