Repository navigation
ci(cassandra): save the server log when a pytest shard fails - #1532
Conversation
devtools/run-cassandra-tests starts the server daemonized, and a daemonized server writes its log to syslog. The cassandra-pytest job printed only the pytest output, so a request that answered 500 left no server-side line in CI. On failure the job now writes the server's journal entries (journalctl -t extenddb) to a file and uploads it as an artifact named server-log-cassandra-pytest-<shard>, kept for 7 days. init output is not included: init prints to the job log and never to syslog. Checked with actionlint and shellcheck, a dry run of the step with stand-ins for sudo and journalctl, and a server started with the job's configuration on a local Cassandra node whose log was searched for the passwords and keys the run used.
The server log artifact is now named per attempt (server-log-cassandra-pytest-<shard>-<attempt>), so a re-run that also fails no longer replaces the first attempt's log. Both steps also run when the job is cancelled, which a timeout or a cancel of the run does. if-no-files-found is dropped: the step always creates the file. The [logging] block in devtools/run-cassandra-tests says the artifact relies on the info level. Checked with actionlint and shellcheck and a dry run of the step.
devtools/run-cassandra-tests creates a random admin password for each run and passes it to the test suite. Under GitHub Actions it now registers the password with ::add-mask:: right after creating it, so the runner hides it in any later job log output. Outside GitHub Actions nothing changes. Checked with bash -n, shellcheck (no new findings) and a run of the block with GITHUB_ACTIONS set to true, empty and false.
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks. Both new steps run only after a failure or a cancel, so they cannot turn a passing job red. The journal step ends in || true, and matrix.shard with the run attempt keeps each artifact name unique. The daemonized server logs to syslog under the tag extenddb, so journalctl -t extenddb selects its lines, as in the other workflows.
bash -n devtools/run-cassandra-tests passes. The new mask lines print one ::add-mask:: line when GITHUB_ACTIONS is true, and nothing otherwise. shellcheck and actionlint report no finding that main does not have already. CI passed, and the branch merges with main. I did not run a cancelled job, so this review does not check that the cancelled() steps run after a timeout-minutes cancel.
No other PR saves the Cassandra server log. #1527 edits the same workflow to skip jobs, and the two PRs change different steps.
What
When a
cassandra-pytestshard fails or is cancelled, the job saves the server's log as an artifact namedserver-log-cassandra-pytest-<shard>-<attempt>, kept for 7 days. Each attempt gets its own artifact, so a re-run keeps the first attempt's log.devtools/run-cassandra-testsstartsextenddb servedaemonized. A daemonized server writes its log to syslog (LogTarget::Syslogincrates/app/src/cmd_serve.rs), so the job log holds only the pytest output. The new step reads the journal withjournalctl -t extenddband uploads it. Other workflows print the last 500 journal lines into the job log. This job uploads the whole journal, so a 500 from early in a shard is kept however many lines follow it.Only lines from the server process are saved.
extenddb initprints to the job log and does not write to syslog, so its output is not in the artifact. The artifact relies on the server's log level staying atinfo, and a comment at the[logging]block indevtools/run-cassandra-testssays so.The steps also run on a cancelled job. A shard cancelled by a timeout, or by a cancel of the whole run, saves its log too. This matters if merge groups start cancelling the other runs of a group after the first failure, as #1527 proposes.
A separate commit masks the random admin password that
devtools/run-cassandra-testscreates. Under GitHub Actions the script registers it with::add-mask::, so the runner hides it in the job log.Why
Refs #610, #1204
Both issues report a
cassandra-pytestrequest that answered 500, with no server-side line in the job log. The server logs the storage error behind a 500, so the next failure keeps its cause.#879 is a time-budget failure. At
infothe server logs no per-request timing, so this log is unlikely to explain it.Testing done
actionlint1.7.7 withshellcheck0.10.0 onintegration-cassandra.ymlbash -nandshellcheckondevtools/run-cassandra-testscleanupare on main tooif: failure() || cancelled(), and the artifact name includes the attemptsudoandjournalctl: journal has lines, journal empty,journalctlfailsGITHUB_ACTIONSset totrue, empty andfalse::add-mask::line only fortruejournalctlwith-o short-iso-preciseon Ubuntu 24.04 (systemd 255)[logging]settings (info,pretty) on Cassandra 4.1, 13 pytest files on auth, IAM, console, ABAC, AssumeRole, stream contention and transaction conflicts (277 passed, 10 failed, 34 errors, mostly 30 s read timeouts on a shared node)cassandra:cassandra,password=orpass:followed by a value, the config file's key values,Signature=,X-Amz-Security-Token, bcrypt hashes,AKIAorASIAkey IDs, and any base64 string of 30 or more characters. The 64 lines withAuthorizationare "Authorization denied" lines that name a principal, action and resource. The Cassandra login is the image defaultcassandra/cassandra, and the startup line prints it ascassandra:***@127.0.0.1:9042/...That server ran in the foreground with stderr written to a file. A daemonized server uses the same tracing filter and format with a syslog writer instead (
serve_innerincrates/server/src/serve.rs), so the same lines would reach syslog.journald can drop lines from a process that logs fast. Its notice about dropped lines is not tagged
extenddb, so the artifact would not show it. A 500-line journal sample from a SQLite job covered about 10 minutes, about 1 line per second, so this is unlikely.Open question
The artifact is kept for 7 days so a failure can be read before it expires. Is a shorter or longer retention preferred?