Skip to content

[TASK] Test SERVICE_CRON_OPTS with log lines that the default level does not write - #630

Merged
Kanti merged 1 commit into
webdevops:masterfrom
andersundsehr:task/cron-log-level-test
Nov 17, 2026
Merged

Kanti merged 1 commit into
webdevops:masterfrom
andersundsehr:task/cron-log-level-test

Conversation

@Kanti

@Kanti Kanti commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

testCronRunsJobsInTheTimeZoneFromTheEnvironment also checked SERVICE_CRON_OPTS by looking for a cron log line in the file of LOG_STDOUT (#623). On Alpine, that check passed without the variable: BusyBox crond logs USER root pid … cmd echo ran at its default level 8 too. Since #623 removed the check of the command line of cron, nothing tests SERVICE_CRON_OPTS on Alpine.

The check is now a test of its own, testCronLogsAtTheLevelFromTheEnvironment, and looks for lines that the default level does not write:

  • Debian and Ubuntu (-L 15): the end of the job with its process id, CRON[…]: (root) END ([…] echo ran. The default writes only (root) CMD (echo ran …). This part is unchanged.
  • Alpine (-l 0): a step of the job, crond[…]: job: 0 echo ran. The default writes only USER root pid … cmd echo ran ….

A failure now names the variable and not TZ.

Related issues: none found.

Changes

  • ci/image-tests/Checks/ContainerEnvironmentChecks.php: testCronRunsJobsInTheTimeZoneFromTheEnvironment checks only TZ again; new testCronLogsAtTheLevelFromTheEnvironment.
  • Doc comments of ImageTestCase::cronOptions() and ServiceChecks::testServiceOptionsFromTheEnvironment().

No image changes; only the image tests.

How it was verified

Containers with a cron job, with and without SERVICE_CRON_OPTS, read through syslog-ng from the file of LOG_STDOUT:

Image Without the variable With the variable
php-nginx:8.5-alpine USER root pid 102 cmd echo ran only also user:root entry:, file root:, job: 0 echo ran, …
php:8.5 (Debian) (root) CMD (echo ran …) only (root) CMD ([92] echo ran …) and (root) END ([92] echo ran …)

Image tests, against the published images, and against the same images where cron.sh no longer passes SERVICE_CRON_OPTS to cron:

Image cron.sh passes the variable cron.sh ignores it
php-nginx:8.5-alpine all 186 tests pass 1 failure: testCronLogsAtTheLevelFromTheEnvironment
php:8.5 (Debian) all 138 tests pass 1 failure: testCronLogsAtTheLevelFromTheEnvironment

The old check would have passed on the Alpine image that ignores the variable: its log has crond[107]: USER root pid 301 cmd echo ran.

Rebased on master with #629; ci/console generate changes nothing. The CI run of this pull request runs the new test in the images that start cron, Debian and Alpine, amd64 and arm64.

…oes not write

BusyBox crond logs "USER root pid ... cmd" at its default level 8 too, so
the check of the cron log on Alpine passed without SERVICE_CRON_OPTS. It
now looks for the steps of the job (" job: 0 echo ran"), which only a lower
level logs; on Debian, the end of the job with its process id comes only
from -L 15 already. The check is a test of its own, so that a failure
names the variable and not TZ.
@sonarqubecloud

Copy link
Copy Markdown

@Kanti
Kanti marked this pull request as ready for review November 17, 2026 12:10
@Kanti
Kanti merged commit d9fdcaf into webdevops:master Nov 17, 2026
180 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant