Skip to content

Report why the mail.err cron test fails when it does - #111

Merged
AndrewSav merged 1 commit into
mailserver2:masterfrom
AndrewSav:test-137-diagnostics
Dec 1, 2026
Merged

AndrewSav merged 1 commit into
mailserver2:masterfrom
AndrewSav:test-137-diagnostics

Conversation

@AndrewSav

@AndrewSav AndrewSav commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Note

TLDR: I'm still chasing intermittent failures in the tests. This adds some more logging for the case linked above where it failed last time after merging to my fork after succeeding here.

  • What is the current behavior (you can also link to an open issue here) ?

    The test makes current-dbs.txt root-owned, runs the hourly clamav-unofficial-sigs job as cron would (as clamav), and expects the job's Permission denied error in /var/log/mail.err. The job's stderr goes there through logger -p mail.err (clamav-unofficial-sigs-cron.sh).

    In run 44396969569 (master, 1f66fe0), it failed. The log shows:

    1. The job ran as it should: exit status 0, no output (21:05:18.6 to 21:05:19.3).
    2. wait_for_log (Update fetchmail.pl to current PostfixAdmin #104) waited 10,117 ms, and /var/log/mail.err was never created. The ls /var/log from make logs (Report when a log check had to wait for rsyslog #106), taken at 21:05:30.6 after the suite stopped, shows no mail.err either.
    3. rsyslog writes every mail.* message to the container's stdout as well as to the files, and make logs dumped that stream. It has nothing between 21:05:15 and 21:05:30. The next two tests logged through the same path within the next second, and both of their lines are there.
    4. There is no update already running, skipping this run line from the wrapper for this test, and no Only one instance can run at the same time error from the script, so neither lock check stopped the job.

    So the job never reported the error. The line that fails, clamav-unofficial-sigs.sh:3191 (sort ... > "$current_dbs_file"), runs on every update, and I found nothing before it that exits without logging. The explanations left are:

    • current-dbs.txt was not root-owned when the job wrote it.
    • The script did not reach line 3191, by a path I haven't found.
    • logger or rsyslog lost the message.
    • The container's own hourly job, whose minute is random, overlapped the test. I think this is unlikely: an overlap would have logged a skip or its own error, and neither is there. The cron minute is not logged, though, so I can't rule it out.

    This is the only failure of this test in the fork's last 9 master runs.

  • What is the new behavior (if this is a feature change) ?

    The test checks the same thing, and the job and the image are unchanged. Two things are added to the test:

    • It runs the job with a small logger script first on its PATH. The script saves each call's arguments and input to a file under /tmp/sigs-diag/ and passes them on, unchanged, to /usr/bin/logger.
    • If the line does not show up, it writes this to the test output as TAP comments, before the assertion fails:
      • when the job started, and its exit status
      • the container's cron line, with its minute
      • the owner, inode and modification time of current-dbs.txt just before and just after the job
      • any clamav-unofficial-sigs script already running, and the contents of the pid directory
      • every call the job made to logger, with its priority and text, or (logger was not called)

    A passing run prints nothing extra.

    How to read the next failure:

    The report shows Meaning
    owner clamav before the job the file was not root-owned when the job wrote it
    the Permission denied line handed to logger logger or rsyslog lost it
    logger called without that line, or not called the script did not reach line 3191
    an update running at the start, or the cron minute equal to the start minute the container's hourly job overlapped the test

Type of change

  • Test (adding missing tests or correcting existing ones)

Status

  • Ready

Todo List

  • Implementation
  • Tests

How has this been tested ?

On this branch as pushed (f8dad99, on master 23a7bc2), with a fresh build:

  • Default suite: 140/140.

  • The failure path, against the same container: a copy of the test waiting for a line that never comes. It printed the full report, including the Permission denied line handed to logger at mail.err, and (none) for running updates, so the process listing no longer matches its own ps command:

    # diagnostics: job started at 00:37:57.750327808 UTC, exit status 0
    # cron line: 6 * * * *  clamav [ -x /usr/local/bin/clamav-unofficial-sigs-cron.sh ] && /usr/bin/bash /usr/local/bin/clamav-unofficial-sigs-cron.sh
    # current-dbs.txt before the job: root (inode 688795, modified 2026-12-01 00:37:55.402392497 +0000)
    # current-dbs.txt after the job: root (inode 688795, modified 2026-12-01 00:37:55.402392497 +0000)
    # updates running when the job started, and the pid directory:
    # (none)
    # total 0
    # what the job handed to logger:
    # --- /tmp/sigs-diag/logger.LhcqY7
    # logger -t clamav-unofficial-sigs -p mail.err
    # /usr/local/bin/clamav-unofficial-sigs.sh: line 3191: /var/lib/clamav-unofficial-sigs/configs/current-dbs.txt: Permission denied
    # --- /tmp/sigs-diag/logger.knlwzT
    # logger -t clamav-unofficial-sigs -p mail.warning
    

"cron job stderr goes to mail.err" fails now and then in CI. In run
44396969569 the job succeeded and printed nothing, but its error never
reached syslog at all: not in mail.err after 10 s, and not in the
mail.log stream either. So it is not rsyslog writing late.

The test now runs the job with a logger in front of the real one that
keeps a copy of what it is given. On failure it writes, as TAP comments,
the job's start time and status, the container's cron line, the owner of
current-dbs.txt just before and after the job, any update already
running, and everything the job handed to logger. Passing runs print
nothing extra.
@AndrewSav
AndrewSav merged commit 32a7ef9 into mailserver2:master Dec 1, 2026
9 checks passed
@AndrewSav
AndrewSav deleted the test-137-diagnostics branch December 1, 2026 19:37
AndrewSav added a commit to AndrewSav/mailserver that referenced this pull request Dec 5, 2026
"cron job stderr goes to mail.err" makes current-dbs.txt root-owned so that
the job, running as clamav, cannot write it. When the update at startup
fails, the file is first created by a job the tests run through su, whose
umask is 0002, so it is group-writable and clamav can still write it after
the chown. Set its mode as well. The diagnostics added in mailserver2#111 led to this
and are removed.

"mail.err does not exist" failed when rspamd's public fuzzy server was slow
to answer, which rspamd logs as an error. Ignore that message only; any
other line still fails the test.
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.

2 participants