Skip to content

test: prefer reading journalctl transport=syslog over /var/log/syslog#6896

Open
blackboxsw wants to merge 3 commits into
canonical:mainfrom
blackboxsw:ci-read-syslog-from-journalctl
Open

test: prefer reading journalctl transport=syslog over /var/log/syslog#6896
blackboxsw wants to merge 3 commits into
canonical:mainfrom
blackboxsw:ci-read-syslog-from-journalctl

Conversation

@blackboxsw
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw commented Jun 1, 2026

Proposed Commit Message

test: prefer reading journalctl transport=syslog over /var/log/syslog

Additional Context

Non-regression integration-test failure during 26.1 SRU testing. Affects 25.3 and earlier as well on noble and newer images.

Test Steps

CLOUD_INIT_PLATFORM=lxd_container CLOUD_INIT_CLOUD_INIT_SOURCE=NONE CLOUD_INIT_OS_IMAGE=noble  tox -e integration-tests -- tests/integration_tests/modules/test_keys_to_console.py::TestKeysToConsoleBlacklist
CLOUD_INIT_PLATFORM=lxd_container CLOUD_INIT_CLOUD_INIT_SOURCE=ppa:cloud-init-dev/daily CLOUD_INIT_OS_IMAGE=noble  tox -e integration-tests -- tests/integration_tests/modules/test_keys_to_console.py::TestKeysToConsoleBlacklist

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Recent versions of journalctl and rsyslog avoid mirroring
/dev/console messages to /var/log/syslog. Prefer to ask journalctl
directly about _TRANSPORT=syslog type messages to track what cloud-init
writes to console as this approach works in both legacy and current
rsyslog/journald behavior.
@blackboxsw blackboxsw force-pushed the ci-read-syslog-from-journalctl branch from e84aeae to 3e6a674 Compare June 1, 2026 14:43
Comment thread tests/integration_tests/util.py Outdated
# Prefer syslog transport categorized messages over presence of
# /var/log/syslog as recent versions of rsyslog will avoid mirroring
# /dev/console to syslog.
if client.execute(["which", "journalctl"]).ok:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any distro running systemd should have journalctl. I don't think we need this check.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've dropped this which check as we only support systemd environments at the moment in integration tests. I also renamed get_syslog_or_console to get_journal_syslog and reduced complexity for handling minimal images which don't contain rsyslogd. I re-ran integration tests successfully on minimal and generic cloud images for tests/integration_tests/modules/test_ssh_auth_key_fingerprints.py and tests/integration_tests/modules/test_keys_to_console.py with success on both jammy (systemd v 249) and noble (systemd v 255).

Comment thread tests/integration_tests/util.py Outdated
return get_console_log(client)
else:
# Prefer syslog transport categorized messages over presence of
# /var/log/syslog as recent versions of rsyslog will avoid mirroring
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this caused by rsyslog behavior changes across versions or is this just a config change of default behavior? I would assume the latter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually is due to systemd v255 changes via systemd-executor process sandboxes which means the direct writes to /dev/console are not automatically mirrored as events to rsyslog any more. See system-executor details in v255 Changelog. It seems a side-effect of this changeset now only initially persists the /dev/console messages directly to the binary journal instead of also refecting those events to rsyslog for event handling. The option we have, which was introducted in systemd v205, is to strictly consume the systemd event tags that are populated for _TRANSPORT=syslog. This does get us a structured syslog-only set of logs emiteed by cloud-init pre and post systemd v255.

I'll update this comment pointing at systemd-executor v255 instead of journalctl/rsyslog specifically.

Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates integration tests to read syslog-relevant output from journalctl instead of /var/log/syslog, addressing SRU-era non-regression failures on newer Ubuntu images (e.g., noble) where traditional syslog file mirroring can be incomplete.

Changes:

  • Replaced the /var/log/syslog-based helper with a new get_journal_syslog() helper in integration test utilities.
  • Updated affected integration tests to use get_journal_syslog() instead of get_syslog_or_console().
  • Simplified tests/integration_tests/util.py imports by removing the unused OS_IMAGE_TYPE import.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tests/integration_tests/util.py Replaces syslog/console helper with a journalctl-based log retrieval helper.
tests/integration_tests/modules/test_ssh_auth_key_fingerprints.py Switches fingerprint assertions to use the new journal-based helper.
tests/integration_tests/modules/test_keys_to_console.py Switches key-console blacklist assertions to use the new journal-based helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +579 to +586
def get_journal_syslog(client: "IntegrationInstance") -> str:
"""Syslog events are categorized _TRANSPORT=syslog from systemd v205."""
# Prefer syslog transport categorized messages over presence of
# /var/log/syslog as systemd v255 introduced systemd-executor
# which sandboxes unit processes resulting in direct writes to
# /dev/console being logged directly to journal binary instead
# of mirrored as rsyslog events.
return client.execute(["journalctl", "_TRANSPORT=syslog", "-b", "0"])
Comment thread tests/integration_tests/util.py Outdated
Comment thread tests/integration_tests/modules/test_keys_to_console.py Outdated
Comment thread tests/integration_tests/modules/test_ssh_auth_key_fingerprints.py Outdated
@blackboxsw
Copy link
Copy Markdown
Collaborator Author

Resolved copilot review comments.

@blackboxsw blackboxsw requested a review from holmanb June 4, 2026 17:29
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.

3 participants